Class: MetadataCop::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
# File 'lib/metadatacop/runner.rb', line 5

def initialize(options = {})
  @options = options
  @ran = false
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/metadatacop/runner.rb', line 3

def options
  @options
end

Instance Method Details

#offensesObject



10
11
12
# File 'lib/metadatacop/runner.rb', line 10

def offenses
  @offenses ||= {}
end

#ran?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/metadatacop/runner.rb', line 31

def ran?
  @ran
end

#run(*paths) ⇒ Object



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

def run(*paths)
  paths.flatten.each_with_object(offenses) do |file, h|
    file_offenses = process_file(file).flatten

    h[file] ||= []
    h[file] += file_offenses
  end

  @ran = true

  offenses
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/metadatacop/runner.rb', line 27

def success?
  offenses.empty? && ran?
end