Sha256: 7eb55cd73d3121e2b2b81af3be0858a94c8cbf7fcd1f05a53bb5f4d2c327da5e

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module TheBathOfZahn
  module Utility
    class Extractor
      def rules_rails
        @rules_rails ||=
          rules_styleguide.select { |key, _value| key =~ %r{^Rails/} }
      end

      def rules_plain
        @rules_plain ||=
          rules_styleguide.reject { |key, _value| key =~ %r{^Rails/} }
      end

      private

      def rules_settings
        @rules_settings ||=
          begin
            path = File.join(path_to_rubocop, "config", "default.yml")
            YAML.load_file(path)
          end
      end

      def rules_enabled
        @rules_enabled ||=
          begin
            path = File.join(path_to_rubocop, "config", "enabled.yml")
            YAML.load_file(path)
          end
      end

      def rules_styleguide
        @rules_styleguide ||=
          rules_enabled.select { |_, v| v["StyleGuide"] }
            .map { |name, config| [name, config.merge(settings_for(name))] }
            .to_h
      end

      def settings_for(name)
        rules_settings[name] || {}
      end

      def path_to_rubocop
        `bundle show rubocop`.chomp
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
the_bath_of_zahn-0.0.5 lib/the_bath_of_zahn/utility/extractor.rb
the_bath_of_zahn-0.0.4 lib/the_bath_of_zahn/utility/extractor.rb
the_bath_of_zahn-0.0.3 lib/the_bath_of_zahn/utility/extractor.rb