Class: RuboCop::TargetRuby

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/target_ruby.rb

Overview

The kind of Ruby that code inspected by RuboCop is written in.

Defined Under Namespace

Classes: BundlerLockFile, Default, RuboCopConfig, RubyVersionFile, Source

Constant Summary collapse

DEFAULT_VERSION =
KNOWN_RUBIES.first

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TargetRuby

Returns a new instance of TargetRuby.



127
128
129
# File 'lib/rubocop/target_ruby.rb', line 127

def initialize(config)
  @config = config
end

Class Method Details

.supported_versionsObject



120
121
122
# File 'lib/rubocop/target_ruby.rb', line 120

def self.supported_versions
  KNOWN_RUBIES
end

Instance Method Details

#rubocop_version_with_supportObject



143
144
145
146
147
148
149
# File 'lib/rubocop/target_ruby.rb', line 143

def rubocop_version_with_support
  if supported?
    RuboCop::Version.version
  else
    OBSOLETE_RUBIES[version]
  end
end

#sourceObject



131
132
133
# File 'lib/rubocop/target_ruby.rb', line 131

def source
  @source ||= SOURCES.each.lazy.map { |c| c.new(@config) }.detect(&:version)
end

#supported?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/rubocop/target_ruby.rb', line 139

def supported?
  KNOWN_RUBIES.include?(version)
end

#versionObject



135
136
137
# File 'lib/rubocop/target_ruby.rb', line 135

def version
  source.version
end