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
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/base/plugin.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/standard-1.33.0/lib/standard/base/plugin.rb
standard-1.33.0 lib/standard/base/plugin.rb