class WhatTheGem::Gem::Bundled
Constants
- NoBundle
- NotBundled
Attributes
spec[R]
Public Class Methods
fetch(name)
click to toggle source
# 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
new(spec)
click to toggle source
# File lib/whatthegem/gem/bundled.rb, line 37 def initialize(spec) @spec = spec end
Public Instance Methods
materialized?()
click to toggle source
# File lib/whatthegem/gem/bundled.rb, line 45 def materialized? !spec.instance_variable_get('@specification').nil? end
present?()
click to toggle source
# File lib/whatthegem/gem/bundled.rb, line 41 def present? true end
to_h()
click to toggle source
# 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