Class: Koality::Runner::RailsBestPractices

Inherits:
Object
  • Object
show all
Defined in:
lib/koality/runner/rails_best_practices.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RailsBestPractices

Returns a new instance of RailsBestPractices.



7
8
9
10
11
12
# File 'lib/koality/runner/rails_best_practices.rb', line 7

def initialize(options)
  require 'rails_best_practices'

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

Instance Attribute Details

#output_fileObject (readonly)

Returns the value of attribute output_file.



5
6
7
# File 'lib/koality/runner/rails_best_practices.rb', line 5

def output_file
  @output_file
end

#rbp_optionsObject (readonly)

Returns the value of attribute rbp_options.



5
6
7
# File 'lib/koality/runner/rails_best_practices.rb', line 5

def rbp_options
  @rbp_options
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/koality/runner/rails_best_practices.rb', line 14

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