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.
18 19 20 21 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 18 def initialize(name, version) @name = name @version = version end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of gem_spec.
12 13 14 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 12 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 12 attr_reader :name, :version |
Instance Method Details
#match? ⇒ Boolean
Check if the specified gem version in Gemfile.lock matches gem_spec comparator.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/synvert/core/rewriter/gem_spec.rb', line 26 def match? return true unless Configuration.strict gemfile_lock_path = File.(File.join(Configuration.root_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.root_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 |