Sha256: 797b737144680fbef1961f25132c24902db2ebdf45a1061722e8f269b4282a39

Contents?: true

Size: 803 Bytes

Versions: 20

Compression:

Stored size: 803 Bytes

Contents

class Standard::CreatesConfigStore
  class SetsTargetRubyVersion
    def call(options_config, standard_config)
      options_config["AllCops"]["TargetRubyVersion"] = normalize_version(
        max_rubocop_supported_version(standard_config[:ruby_version])
      )
    end

    private

    def max_rubocop_supported_version(desired_version)
      return desired_version unless Gem::Version.correct?(desired_version)

      rubocop_supported_version = Gem::Version.new("2.5")
      if desired_version < rubocop_supported_version
        rubocop_supported_version
      else
        desired_version
      end
    end

    def normalize_version(version)
      return version unless Gem::Version.correct?(version)

      major, minor = version.segments
      "#{major}.#{minor}".to_f # lol
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
standard-1.16.1 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.16.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.15.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.14.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.13.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.12.1 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.12.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.11.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.10.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.9.1 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.9.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/standard-1.8.0/lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.8.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.7.3 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.7.2 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.7.1 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.7.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.6.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.5.0 lib/standard/creates_config_store/sets_target_ruby_version.rb
standard-1.4.0 lib/standard/creates_config_store/sets_target_ruby_version.rb