Class: Synvert::Core::Rewriter::RubyVersion
- Inherits:
-
Object
- Object
- Synvert::Core::Rewriter::RubyVersion
- Defined in:
- lib/synvert/core/rewriter/ruby_version.rb
Overview
GemSpec checks and compares ruby version.
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(version) ⇒ RubyVersion
constructor
Initialize a ruby_version.
-
#match? ⇒ Boolean
Check if the specified ruby version matches current ruby version.
Constructor Details
#initialize(version) ⇒ RubyVersion
Initialize a ruby_version.
11 12 13 |
# File 'lib/synvert/core/rewriter/ruby_version.rb', line 11 def initialize(version) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/synvert/core/rewriter/ruby_version.rb', line 6 def version @version end |
Instance Method Details
#match? ⇒ Boolean
Check if the specified ruby version matches current ruby version.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/synvert/core/rewriter/ruby_version.rb', line 18 def match? return true unless Configuration.strict if File.exist?(File.join(Configuration.root_path, '.ruby-version')) version_file = '.ruby-version' elsif File.exist?(File.join(Configuration.root_path, '.rvmrc')) version_file = '.rvmrc' end return true unless version_file version = File.read(File.join(Configuration.root_path, version_file)) version = version.match(/(\d+\.\d+\.\d+)/)[0] Gem::Version.new(version) >= Gem::Version.new(@version) end |