class PhusionPassenger::PlatformInfo::Depcheck::Dependency

Public Class Methods

new(&block) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 68
def initialize(&block)
  instance_eval(&block)
  check_syntax_aspect("Name must be given") { !!@name }
  check_syntax_aspect("A checker must be given") { !!@checker }
end

Public Instance Methods

check() click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 74
def check
  @install_comments = nil
  @check_result ||= @checker.call
end
install_comments(value = nil) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 109
def install_comments(value = nil)
  value ? @install_comments = value : @install_comments
end
install_instructions(value = nil) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 93
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
name(value = nil) click to toggle source

DSL for specs ###

# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 81
def name(value = nil)
  value ? @name = value : @name
end
website(value = nil) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 85
def website(value = nil)
  value ? @website = value : @website
end
website_comments(value = nil) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 89
def website_comments(value = nil)
  value ? @website_comments = value : @website_comments
end

Private Instance Methods

apt_get_install(package_name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 237
def apt_get_install(package_name)
  install_instructions("Please install it with <b>apt-get install #{package_name}</b>")
end
check_for_command(name, *args) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 126
def check_for_command(name, *args)
  result = find_command(name, *args)
  if result
    { :found => true,
      "Location" => result }
  else
    false
  end
end
check_for_header(header_name, language = :c, flags = nil) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 146
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
check_for_ruby_library(name) click to toggle source
  if find_command(compiler)
    command = "#{compiler} #{compiler_flags} #{cflags} " +
      "#{source_file} -o #{output_file} #{linkflags}"
    [!!system(command)]
  else
    [:unknown, "Cannot check: compiler '#{compiler}' not found."]
  end
ensure
  File.unlink(source_file) rescue nil
  File.unlink(output_file) rescue nil
end

end

# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 193
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
check_for_ruby_tool(name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 136
def check_for_ruby_tool(name)
  result = locate_ruby_tool(name)
  if result
    { :found => true,
      "Location" => result }
  else
    false
  end
end
check_syntax_aspect(description) { || ... } click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 114
def check_syntax_aspect(description)
  if !yield
    raise description
  end
end
define_checker(&block) click to toggle source

DSL for specs ###

# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 122
def define_checker(&block)
  @checker = block
end
emerge(package_name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 253
def emerge(package_name)
  install_instructions("Please install it with <b>emerge -av #{package_name}</b>")
end
find_command(command, *args) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 282
def find_command(command, *args)
  PlatformInfo.find_command(command, *args)
end
gem_command() click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 278
def gem_command
  PlatformInfo.gem_command(:sudo => true) || 'gem'
end
gem_install(package_name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 257
def gem_install(package_name)
  install_instructions("Please make sure RubyGems is installed, then run " +
    "<b>#{gem_command} install #{package_name}</b>")
end
install_osx_command_line_tools() click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 262
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
linux_distro_tags() click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 286
def linux_distro_tags
  PlatformInfo.linux_distro_tags
end
locate_ruby_tool(name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 290
def locate_ruby_tool(name)
  PlatformInfo.locate_ruby_tool(name)
end
on(platform) { || ... } click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 212
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
ruby_command() click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 274
def ruby_command
  PlatformInfo.ruby_command
end
urpmi(package_name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 241
def urpmi(package_name)
  install_instructions("Please install it with <b>urpmi #{package_name}</b>")
end
yum_install(package_name, options = {}) click to toggle source
# File src/ruby_supportlib/phusion_passenger/platform_info/depcheck.rb, line 245
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