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.
-
#remote ⇒ Object
Returns the value of attribute remote.
-
#source ⇒ Object
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #__materialize__ ⇒ Object
- #full_name ⇒ Object
- #identifier ⇒ 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
generic, generic_local_platform
Constructor Details
#initialize(name, version, platform, source = nil) ⇒ LazySpecification
Returns a new instance of LazySpecification.
13 14 15 16 17 18 19 20 |
# File 'lib/bundler/lazy_specification.rb', line 13 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)
77 78 79 80 81 82 83 |
# File 'lib/bundler/lazy_specification.rb', line 77 def method_missing(method, *args, &blk) raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification return super unless respond_to?(method) @specification.send(method, *args, &blk) end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
10 11 12 |
# File 'lib/bundler/lazy_specification.rb', line 10 def dependencies @dependencies end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/bundler/lazy_specification.rb', line 10 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
10 11 12 |
# File 'lib/bundler/lazy_specification.rb', line 10 def platform @platform end |
#remote ⇒ Object
Returns the value of attribute remote.
11 12 13 |
# File 'lib/bundler/lazy_specification.rb', line 11 def remote @remote end |
#source ⇒ Object
Returns the value of attribute source.
11 12 13 |
# File 'lib/bundler/lazy_specification.rb', line 11 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/bundler/lazy_specification.rb', line 10 def version @version end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/bundler/lazy_specification.rb', line 30 def ==(other) identifier == other.identifier end |
#__materialize__ ⇒ Object
55 56 57 |
# File 'lib/bundler/lazy_specification.rb', line 55 def __materialize__ @specification = source.specs.search(Gem::Dependency.new(name, version)).last end |
#full_name ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bundler/lazy_specification.rb', line 22 def full_name if platform == Gem::Platform::RUBY || platform.nil? "#{@name}-#{@version}" else "#{@name}-#{@version}-#{platform}" end end |
#identifier ⇒ Object
67 68 69 |
# File 'lib/bundler/lazy_specification.rb', line 67 def identifier @__identifier ||= [name, version, source, platform, dependencies].hash end |
#respond_to?(*args) ⇒ Boolean
59 60 61 |
# File 'lib/bundler/lazy_specification.rb', line 59 def respond_to?(*args) super || @specification ? @specification.respond_to?(*args) : nil end |
#satisfies?(dependency) ⇒ Boolean
34 35 36 |
# File 'lib/bundler/lazy_specification.rb', line 34 def satisfies?(dependency) @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version)) end |
#to_lock ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bundler/lazy_specification.rb', line 38 def to_lock out = String.new if platform == Gem::Platform::RUBY || platform.nil? out << " #{name} (#{version})\n" else out << " #{name} (#{version}-#{platform})\n" end dependencies.sort_by(&:to_s).uniq.each do |dep| next if dep.type == :development out << " #{dep.to_lock}\n" end out end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/bundler/lazy_specification.rb', line 63 def to_s @__to_s ||= "#{name} (#{version})" end |