Class: WhatTheGem::Gem::Bundled
Defined Under Namespace
Classes: NoBundle, NotBundled
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(spec) ⇒ Bundled
37
38
39
|
# File 'lib/whatthegem/gem/bundled.rb', line 37
def initialize(spec)
@spec = spec
end
|
Instance Attribute Details
Returns the value of attribute spec.
35
36
37
|
# File 'lib/whatthegem/gem/bundled.rb', line 35
def spec
@spec
end
|
Class Method Details
.fetch(name) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/whatthegem/gem/bundled.rb', line 26
def self.fetch(name)
return NoBundle.new(name) unless File.exists?('Gemfile') && File.exists?('Gemfile.lock')
definition = Bundler::Definition.build('Gemfile', 'Gemfile.lock', nil)
spec = definition.locked_gems.specs.detect { |s| s.name == name } or return NotBundled.new(name)
spec.send(:__materialize__)
new(spec)
end
|
Instance Method Details
#materialized? ⇒ Boolean
45
46
47
|
# File 'lib/whatthegem/gem/bundled.rb', line 45
def materialized?
!spec.instance_variable_get('@specification').nil?
end
|
#present? ⇒ Boolean
41
42
43
|
# File 'lib/whatthegem/gem/bundled.rb', line 41
def present?
true
end
|
49
50
51
52
53
54
55
56
|
# File 'lib/whatthegem/gem/bundled.rb', line 49
def to_h
{
type: 'bundled',
name: spec.name,
version: spec.version.to_s,
dir: materialized? ? spec.gem_dir : '(not installed)'
}
end
|