Sha256: aaa4e7c6f6b24ec620d847615eef44bece06796ce771b64f2d79e807d0579322

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

module Koality
  module Runner
    class RailsBestPractices

      attr_reader :output_file, :rbp_options

      def initialize(options)
        require 'rails_best_practices'

        @output_file = options.output_file(:rails_bp_error_file)
        @rbp_options = translate_options(options)
      end

      def run
        analyzer = ::RailsBestPractices::Analyzer.new('.', rbp_options)

        Koality::Reporter::RailsBestPractices.start do |reporter|
          analyzer.analyze
          reporter.report(analyzer.errors)
        end

        File.open(output_file, 'w') do |f|
          f << analyzer.errors.count
        end
      end

      private

      def translate_options(options)
        {
          'silent' => true,
          'only' => regexp_list(options[:rails_bp_accept_patterns]),
          'exclude' => regexp_list(options[:rails_bp_ignore_patterns])
        }
      end

      def regexp_list(list)
        list.map { |item| Regexp.new item }
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koality-1.0.1 lib/koality/runner/rails_best_practices.rb