Class: RuboCop::TargetRuby::BundlerLockFile Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Source
|
|
Instance Chain:
self,
Source
|
|
Inherits: |
RuboCop::TargetRuby::Source
|
Defined in: | lib/rubocop/target_ruby.rb |
Overview
The lock file of Bundler may identify the target ruby version.
Class Method Summary
Instance Attribute Summary
Instance Method Summary
- #name Internal use only
- #bundler_lock_file_path private Internal use only
- #find_version private Internal use only
Source
- Inherited
Instance Method Details
#bundler_lock_file_path (private)
[ GitHub ]# File 'lib/rubocop/target_ruby.rb', line 225
def bundler_lock_file_path @config.bundler_lock_file_path end
#find_version (private)
[ GitHub ]# File 'lib/rubocop/target_ruby.rb', line 198
def find_version lock_file_path = bundler_lock_file_path return nil unless lock_file_path in_ruby_section = false File.foreach(lock_file_path) do |line| # If ruby is in Gemfile.lock or gems.lock, there should be two lines # towards the bottom of the file that look like: # RUBY VERSION # ruby W.X.YpZ # We ultimately want to match the "ruby W.X.Y.pZ" line, but there's # extra logic to make sure we only start looking once we've seen the # "RUBY VERSION" line. in_ruby_section ||= line.match(/^\s*RUBY\s*VERSION\s*$/) next unless in_ruby_section # We currently only allow this feature to work with MRI ruby. If # jruby (or something else) is used by the project, it's lock file # will have a line that looks like: # RUBY VERSION # ruby W.X.YpZ (jruby x.x.x.x) # The regex won't match in this situation. result = line.match(/^\s*ruby\s+(\d+\.\d+)[p.\d]*\s*$/) return result.captures.first.to_f if result end end
#name
[ GitHub ]# File 'lib/rubocop/target_ruby.rb', line 192
def name "`#{bundler_lock_file_path}`" end