Class: Bundler::LazySpecification
- Inherits:
-
Object
- Object
- Bundler::LazySpecification
- Includes:
- MatchPlatform
- Defined in:
- lib/bundler/lazy_specification.rb
Constant Summary
Constants included from GemHelpers
GemHelpers::GENERICS, GemHelpers::GENERIC_CACHE
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#source ⇒ Object
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #__materialize__ ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, version, platform, source = nil) ⇒ LazySpecification
constructor
A new instance of LazySpecification.
- #respond_to?(*args) ⇒ Boolean
- #satisfies?(dependency) ⇒ Boolean
- #to_lock ⇒ Object
- #to_s ⇒ Object
Methods included from MatchPlatform
Methods included from GemHelpers
Constructor Details
#initialize(name, version, platform, source = nil) ⇒ LazySpecification
Returns a new instance of LazySpecification.
11 12 13 14 15 16 17 18 |
# File 'lib/bundler/lazy_specification.rb', line 11 def initialize(name, version, platform, source = nil) @name = name @version = version @dependencies = [] @platform = platform @source = source @specification = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (private)
61 62 63 64 65 66 67 68 |
# File 'lib/bundler/lazy_specification.rb', line 61 def method_missing(method, *args, &blk) if Gem::Specification.new.respond_to?(method) raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification @specification.send(method, *args, &blk) else super end end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/bundler/lazy_specification.rb', line 8 def dependencies @dependencies end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/bundler/lazy_specification.rb', line 8 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
8 9 10 |
# File 'lib/bundler/lazy_specification.rb', line 8 def platform @platform end |
#source ⇒ Object
Returns the value of attribute source.
9 10 11 |
# File 'lib/bundler/lazy_specification.rb', line 9 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/bundler/lazy_specification.rb', line 8 def version @version end |
Instance Method Details
#__materialize__ ⇒ Object
47 48 49 |
# File 'lib/bundler/lazy_specification.rb', line 47 def __materialize__ @specification = source.specs.search(Gem::Dependency.new(name, version)).last end |
#full_name ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bundler/lazy_specification.rb', line 20 def full_name if platform == Gem::Platform::RUBY or platform.nil? then "#{@name}-#{@version}" else "#{@name}-#{@version}-#{platform}" end end |
#respond_to?(*args) ⇒ Boolean
51 52 53 |
# File 'lib/bundler/lazy_specification.rb', line 51 def respond_to?(*args) super || @specification.respond_to?(*args) end |
#satisfies?(dependency) ⇒ Boolean
28 29 30 |
# File 'lib/bundler/lazy_specification.rb', line 28 def satisfies?(dependency) @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version)) end |
#to_lock ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bundler/lazy_specification.rb', line 32 def to_lock if platform == Gem::Platform::RUBY or platform.nil? out = " #{name} (#{version})\n" else out = " #{name} (#{version}-#{platform})\n" end dependencies.sort_by {|d| d.name }.each do |dep| next if dep.type == :development out << " #{dep.to_lock}\n" end out end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/bundler/lazy_specification.rb', line 55 def to_s "#{name} (#{version})" end |