Sha256: dc259f5ad6bb874f04eea5806d7eb939948673323beb53fb6338956f6369d6d5

Contents?: true

Size: 1.86 KB

Versions: 91

Compression:

Stored size: 1.86 KB

Contents

module Standard::Base
  class Plugin < LintRoller::Plugin
    def initialize(config)
      @config = config
    end

    def about
      LintRoller::About.new(
        name: "standard-base",
        version: VERSION,
        homepage: "https://github.com/standardrb/standard",
        description: "Configuration for RuboCop's built-in rules"
      )
    end

    def supported?(context)
      true
    end

    def rules(context)
      LintRoller::Rules.new(
        type: :path,
        config_format: :rubocop,
        value: determine_yaml_path(context.target_ruby_version)
      )
    end

    private

    def determine_yaml_path(desired_version)
      desired_version = Gem::Version.new(desired_version) unless desired_version.is_a?(Gem::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.1")
        "ruby-2.0.yml"
      elsif desired_version < Gem::Version.new("2.2")
        "ruby-2.1.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"
      elsif desired_version < Gem::Version.new("3.1")
        "ruby-3.0.yml"
      elsif desired_version < Gem::Version.new("3.2")
        "ruby-3.1.yml"
      elsif desired_version < Gem::Version.new("3.3")
        "ruby-3.2.yml"
      else
        default
      end

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

Version data entries

91 entries across 91 versions & 3 rubygems

Version Path
standard-1.37.0 lib/standard/base/plugin.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
standard-1.35.0.1 lib/standard/base/plugin.rb
standard-1.34.0.1 lib/standard/base/plugin.rb
standard-1.35.1 lib/standard/base/plugin.rb
standard-1.35.0 lib/standard/base/plugin.rb
standard-1.34.0 lib/standard/base/plugin.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb