Class: Terracop::Runner
- Inherits:
-
Object
- Object
- Terracop::Runner
- Defined in:
- lib/terracop/runner.rb
Overview
Executes Terracop on a given state file.
Instance Method Summary collapse
-
#initialize(type, file, formatter) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize(type, file, formatter) ⇒ Runner
Returns a new instance of Runner.
6 7 8 9 10 11 |
# File 'lib/terracop/runner.rb', line 6 def initialize(type, file, formatter) @formatter = Formatters.const_get(formatter.to_s.capitalize).new @type = type @file = file end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/terracop/runner.rb', line 13 def run offenses = state.map do |instance| Terracop::Cop.run_for( instance[:type], instance[:name], instance[:index], instance[:attributes] ) end print formatted(offenses) offenses.flatten.count end |
#state ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/terracop/runner.rb', line 26 def state @state ||= begin if @file load_state_from_file(@type, @file) else load_state_from_terraform end end end |