Sha256: a81bc4e7bb2a12036b9a83203325ab6c6c62d94a9b64179e5f766dc9738bdc10

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require "pathname"

class Standard::CreatesConfigStore
  class AssignsRubocopYaml
    def call(config_store, standard_config)
      config_store.options_config = rubocop_yaml_path(standard_config[:ruby_version])
      config_store.instance_variable_get("@options_config")
    end

    private

    def rubocop_yaml_path(desired_version)
      default = "base.yml"

      file_name = if !Gem::Version.correct?(desired_version)
        default
      elsif desired_version < Gem::Version.new("1.9")
        "ruby-1.8.yml"
      elsif desired_version < Gem::Version.new("2.0")
        "ruby-1.9.yml"
      elsif desired_version < Gem::Version.new("2.3")
        "ruby-2.2.yml"
      elsif desired_version < Gem::Version.new("2.4")
        "ruby-2.3.yml"
      elsif desired_version < Gem::Version.new("2.5")
        "ruby-2.4.yml"
      elsif desired_version < Gem::Version.new("2.6")
        "ruby-2.5.yml"
      elsif desired_version < Gem::Version.new("3.0")
        "ruby-2.7.yml"
      else
        default
      end

      Pathname.new(__dir__).join("../../../config/#{file_name}")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
standard-1.7.0 lib/standard/creates_config_store/assigns_rubocop_yaml.rb
standard-1.6.0 lib/standard/creates_config_store/assigns_rubocop_yaml.rb
standard-1.5.0 lib/standard/creates_config_store/assigns_rubocop_yaml.rb
standard-1.4.0 lib/standard/creates_config_store/assigns_rubocop_yaml.rb