Module: Puggernaut::Gems
- Defined in:
- lib/puggernaut/gems.rb
Defined Under Namespace
Classes: SimpleStruct
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
-
.gemset ⇒ Object
Returns the value of attribute gemset.
-
.gemsets ⇒ Object
readonly
Returns the value of attribute gemsets.
-
.versions ⇒ Object
readonly
Returns the value of attribute versions.
Class Method Summary collapse
- .activate(*gems) ⇒ Object
- .dependencies ⇒ Object
- .development_dependencies ⇒ Object
- .gemset_names ⇒ Object
- .gemspec(reload = false) ⇒ Object
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/puggernaut/gems.rb', line 9 def config @config end |
.gemset ⇒ Object
Returns the value of attribute gemset.
10 11 12 |
# File 'lib/puggernaut/gems.rb', line 10 def gemset @gemset end |
.gemsets ⇒ Object (readonly)
Returns the value of attribute gemsets.
10 11 12 |
# File 'lib/puggernaut/gems.rb', line 10 def gemsets @gemsets end |
.versions ⇒ Object (readonly)
Returns the value of attribute versions.
10 11 12 |
# File 'lib/puggernaut/gems.rb', line 10 def versions @versions end |
Class Method Details
.activate(*gems) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/puggernaut/gems.rb', line 30 def activate(*gems) begin require 'rubygems' unless defined?(::Gem) rescue LoadError puts "rubygems library could not be required" if @config.warn end self.gemset ||= gemset_from_loaded_specs gems.flatten.collect { |g| g.to_sym }.each do |name| version = @versions[name] vendor = File.("../../../vendor/#{name}/lib", __FILE__) if File.exists?(vendor) $:.unshift vendor elsif defined?(gem) gem name.to_s, version else puts "#{name} #{"(#{version})" if version} failed to activate" if @config.warn end end end |
.dependencies ⇒ Object
52 53 54 |
# File 'lib/puggernaut/gems.rb', line 52 def dependencies dependency_filter(@gemspec.dependencies, @gemset) end |
.development_dependencies ⇒ Object
56 57 58 |
# File 'lib/puggernaut/gems.rb', line 56 def development_dependencies dependency_filter(@gemspec.development_dependencies, @gemset) end |
.gemset_names ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/puggernaut/gems.rb', line 89 def gemset_names ( [ :default ] + @gemsets[gemspec.name.to_sym].inject([]) { |array, (key, value)| array.push(key) if value.is_a?(::Hash) || value.nil? array } ).uniq end |
.gemspec(reload = false) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/puggernaut/gems.rb', line 99 def gemspec(reload=false) if @gemspec && !reload @gemspec else data = YAML::load(File.read(@config.gemspec)) rescue {} @gemspec = SimpleStruct.new(data) end end |