class RubyInstaller::Build::Gems::InstallSpec

Attributes

gem_build[RW]
gem_cmd[RW]
gem_install_opts[RW]
gem_name[RW]
gem_version[RW]

Public Class Methods

new(gem_name) click to toggle source
# File lib/ruby_installer/build/gems.rb, line 16
def initialize(gem_name)
  @gem_name = gem_name.dup
  @gem_cmd = "gem"
  @gem_install_opts = []

  begin
    fname = ovl_expand_file("gems/#{gem_name}.yaml")
  rescue Errno::ENOENT
  else
    yaml = YAML.load_file(fname)
    raise ArgumentError, "Not a Hash in #{fname}" unless yaml.is_a?(Hash)

    yaml.each do |key, value|
      send("#{key}=", value)
    end
  end
end

Public Instance Methods

install() click to toggle source
# File lib/ruby_installer/build/gems.rb, line 34
def install
  if gem_build
    out = run_capture_output(gem_cmd, "build", gem_build)
    if out =~ /File: (.*)/
      gem_file = $1
    else
      raise "Failed to build #{gem_name}"
    end
  end

  if gem_version
    version_opts = ["--version", gem_version]
  end

  run(gem_cmd, "install", *gem_install_opts, gem_file || gem_name, *version_opts)
end
run(*args) click to toggle source
# File lib/ruby_installer/build/gems.rb, line 51
def run(*args)
  puts args.join(" ")
  res = system(*args)
  raise "Command failed: #{args.join(" ")}" unless res
end
run_capture_output(*args) click to toggle source
# File lib/ruby_installer/build/gems.rb, line 57
def run_capture_output(*args)
  puts args.join(" ")
  IO.popen(args, &:read)
end