class PhusionPassenger::PlatformInfo::Depcheck::Dependency
def apt_get_install(package_name)
def apt_get_install(package_name) install_instructions("Please install it with <b>apt-get install #{package_name}</b>") end
def check
def check @install_comments = nil @check_result ||= @checker.call end
def check_for_command(name, *args)
def check_for_command(name, *args) result = find_command(name, *args) if result { :found => true, "Location" => result } else false end end
def check_for_header(header_name, language = :c, flags = nil)
def check_for_header(header_name, language = :c, flags = nil) if result = PlatformInfo.find_header(header_name, language, flags) { :found => true, "Location" => result } else false end end
def check_for_ruby_library(name)
def check_for_ruby_library(name) begin require(name) { :found => true } rescue LoadError if defined?(Gem) false else begin require 'rubygems' require(name) { :found => true } rescue LoadError false end end end end
def check_for_ruby_tool(name)
def check_for_ruby_tool(name) result = locate_ruby_tool(name) if result { :found => true, "Location" => result } else false end end
def check_syntax_aspect(description)
def check_syntax_aspect(description) if !yield raise description end end
def define_checker(&block)
def define_checker(&block) @checker = block end
def emerge(package_name)
def emerge(package_name) install_instructions("Please install it with <b>emerge -av #{package_name}</b>") end
def find_command(command, *args)
def find_command(command, *args) PlatformInfo.find_command(command, *args) end
def gem_command
def gem_command PlatformInfo.gem_command(:sudo => true) || 'gem' end
def gem_install(package_name)
def gem_install(package_name) install_instructions("Please make sure RubyGems is installed, then run " + "<b>#{gem_command} install #{package_name}</b>") end
def initialize(&block)
def initialize(&block) instance_eval(&block) check_syntax_aspect("Name must be given") { !!@name } check_syntax_aspect("A checker must be given") { !!@checker } end
def install_comments(value = nil)
def install_comments(value = nil) value ? @install_comments = value : @install_comments end
def install_instructions(value = nil)
def install_instructions(value = nil) if value @install_instructions = value else if @install_instructions @install_instructions elsif @website result = "Please download it from <b>#{@website}</b>" result << "\n(#{@website_comments})" if @website_comments result else "Search Google for '#{@name}'." end end end
def install_osx_command_line_tools
def install_osx_command_line_tools PhusionPassenger.require_passenger_lib 'platform_info/compiler' if PlatformInfo.xcode_select_version.to_s >= "2333" install_instructions "Please install the Xcode command line tools: " + "<b>sudo xcode-select --install</b>" else install_instructions "Please install Xcode, then install the command line tools " + "though the menu <b>Xcode -> Preferences -> Downloads -> Components</b>" end end
def linux_distro_tags
def linux_distro_tags PlatformInfo.linux_distro_tags end
def locate_ruby_tool(name)
def locate_ruby_tool(name) PlatformInfo.locate_ruby_tool(name) end
def name(value = nil)
def name(value = nil) value ? @name = value : @name end
def on(platform)
def on(platform) return if @on_invoked invoke = false if (linux_distro_tags || []).include?(platform) invoke = true else case platform when :linux invoke = true if PlatformInfo.os_name =~ /linux/ when :freebsd invoke = true if PlatformInfo.os_name =~ /freebsd/ when :macosx invoke = true if PlatformInfo.os_name == "macosx" when :solaris invoke = true if PlatformInfo.os_name =~ /solaris/ when :other_platforms invoke = true end end if invoke yield @on_invoked = true end end
def ruby_command
def ruby_command PlatformInfo.ruby_command end
def urpmi(package_name)
def urpmi(package_name) install_instructions("Please install it with <b>urpmi #{package_name}</b>") end
def website(value = nil)
def website(value = nil) value ? @website = value : @website end
def website_comments(value = nil)
def website_comments(value = nil) value ? @website_comments = value : @website_comments end
def yum_install(package_name, options = {})
def yum_install(package_name, options = {}) if options[:epel] install_instructions("Please enable <b>EPEL</b>, then install with <b>yum install #{package_name}</b>") else install_instructions("Please install it with <b>yum install #{package_name}</b>") end end