Class: RubyInstaller::Build::Gems::InstallSpec
- Inherits:
-
Object
- Object
- RubyInstaller::Build::Gems::InstallSpec
- Includes:
- Utils
- Defined in:
- lib/ruby_installer/build/gems.rb
Constant Summary
Constants included from Utils
Utils::GEM_ROOT, Utils::WINDOWS_CMD_SHEBANG
Instance Attribute Summary collapse
-
#gem_build ⇒ Object
Returns the value of attribute gem_build.
-
#gem_cmd ⇒ Object
Returns the value of attribute gem_cmd.
-
#gem_install_opts ⇒ Object
Returns the value of attribute gem_install_opts.
-
#gem_name ⇒ Object
Returns the value of attribute gem_name.
-
#gem_version ⇒ Object
Returns the value of attribute gem_version.
Instance Method Summary collapse
-
#initialize(gem_name) ⇒ InstallSpec
constructor
A new instance of InstallSpec.
- #install ⇒ Object
- #run(*args) ⇒ Object
- #run_capture_output(*args) ⇒ Object
Methods included from Utils
#eval_file, #gem_expand_file, #msys_sh, #ovl_compile_erb, #ovl_expand_file, #ovl_glob, #ovl_read_file, #q_inno, #rubyinstaller_build_gem_files, #with_env
Constructor Details
#initialize(gem_name) ⇒ InstallSpec
Returns a new instance of InstallSpec.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 = ("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 |
Instance Attribute Details
#gem_build ⇒ Object
Returns the value of attribute gem_build.
11 12 13 |
# File 'lib/ruby_installer/build/gems.rb', line 11 def gem_build @gem_build end |
#gem_cmd ⇒ Object
Returns the value of attribute gem_cmd.
13 14 15 |
# File 'lib/ruby_installer/build/gems.rb', line 13 def gem_cmd @gem_cmd end |
#gem_install_opts ⇒ Object
Returns the value of attribute gem_install_opts.
14 15 16 |
# File 'lib/ruby_installer/build/gems.rb', line 14 def gem_install_opts @gem_install_opts end |
#gem_name ⇒ Object
Returns the value of attribute gem_name.
9 10 11 |
# File 'lib/ruby_installer/build/gems.rb', line 9 def gem_name @gem_name end |
#gem_version ⇒ Object
Returns the value of attribute gem_version.
10 11 12 |
# File 'lib/ruby_installer/build/gems.rb', line 10 def gem_version @gem_version end |
Instance Method Details
#install ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# 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) ⇒ Object
51 52 53 54 55 |
# 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) ⇒ Object
57 58 59 60 |
# File 'lib/ruby_installer/build/gems.rb', line 57 def run_capture_output(*args) puts args.join(" ") IO.popen(args, &:read) end |