Class: Synvert::Core::Rewriter::GemSpec
- Inherits:
-
Object
- Object
- Synvert::Core::Rewriter::GemSpec
- Defined in:
- lib/synvert/core/rewriter/gem_spec.rb
Overview
GemSpec checks and compares gem version.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of gem_spec.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name, version) ⇒ GemSpec
constructor
Initialize a GemSpec.
-
#match? ⇒ Boolean
Check if the specified gem version in Gemfile.lock matches gem_spec comparator.
Constructor Details
#initialize(name, version) ⇒ GemSpec
Initialize a GemSpec.
16 17 18 19 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 16 def initialize(name, version) @name = name @version = version end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of gem_spec.
10 11 12 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 10 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 10 attr_reader :name, :version |
Instance Method Details
#match? ⇒ Boolean
Check if the specified gem version in Gemfile.lock matches gem_spec comparator.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 24 def match? gemfile_lock_path = File.(File.join(Configuration.path, 'Gemfile.lock')) # if Gemfile.lock does not exist, just ignore this check return true unless File.exist?(gemfile_lock_path) ENV['BUNDLE_GEMFILE'] = Configuration.path # make sure bundler reads Gemfile.lock in the correct path parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path)) parser.specs.any? { |spec| Gem::Dependency.new(@name, @version).match?(spec) } end |