Class: Ramaze::GemSetup
Overview
Class responsible for installing and loading all the gems.
Instance Method Summary (collapse)
-
- (Object) gem(name, version = nil, options = {})
Adds the given gem to the list of required gems.
-
- (GemSetup) initialize(options = {}) { ... }
constructor
Creates a new instance of the class and saves the parameters that were set.
-
- (Object) install_gem(name, options)
Tell Rubygems to install a gem.
-
- (Object) run(&block)
Executes the data inside the block, loading all the gems and optionally installing them.
-
- (Object) setup
Tries to install all the gems.
-
- (Object) setup_gem(name, options)
First try to activate, install and try to activate again if activation fails the first time.
-
- (Object) temp_argv(extconf)
Prepare ARGV for rubygems installer.
Constructor Details
- (GemSetup) initialize(options = {}) { ... }
Creates a new instance of the class and saves the parameters that were set.
45 46 47 48 49 50 51 |
# File 'lib/ramaze/setup.rb', line 45 def initialize( = {}, &block) @gems = [] = .dup @verbose = .delete(:verbose) run(&block) end |
Instance Method Details
- (Object) gem(name, version = nil, options = {})
Adds the given gem to the list of required gems.
80 81 82 83 84 85 86 87 88 |
# File 'lib/ramaze/setup.rb', line 80 def gem(name, version = nil, = {}) if version.respond_to?(:merge!) = version else [:version] = version end @gems << [name, ] end |
- (Object) install_gem(name, options)
Tell Rubygems to install a gem.
135 136 137 138 139 140 141 142 |
# File 'lib/ramaze/setup.rb', line 135 def install_gem(name, ) installer = Gem::DependencyInstaller.new() temp_argv([:extconf]) do log "Installing gem #{name}" installer.install(name, [:version]) end end |
- (Object) run(&block)
Executes the data inside the block, loading all the gems and optionally installing them.
61 62 63 64 65 |
# File 'lib/ramaze/setup.rb', line 61 def run(&block) return unless block_given? instance_eval(&block) setup end |
- (Object) setup
Tries to install all the gems.
96 97 98 99 100 101 102 103 |
# File 'lib/ramaze/setup.rb', line 96 def setup require 'rubygems' require 'rubygems/dependency_installer' @gems.each do |name, | setup_gem(name, ) end end |
- (Object) setup_gem(name, options)
First try to activate, install and try to activate again if activation fails the first time.
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ramaze/setup.rb', line 114 def setup_gem(name, ) version = [[:version]].compact lib_name = [:lib] || name log "Activating gem #{name}" activate(name, lib_name, *version) # Gem not installed yet rescue Gem::LoadError install_gem(name, ) activate(name, lib_name, *version) end |
- (Object) temp_argv(extconf)
Prepare ARGV for rubygems installer
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/ramaze/setup.rb', line 151 def temp_argv(extconf) if extconf ||= [:extconf] old_argv = ARGV.clone ARGV.replace(extconf.split(' ')) end yield ensure ARGV.replace(old_argv) if extconf end |