Class: CobraCommander::Change

Inherits:
Object
  • Object
show all
Defined in:
lib/cobra_commander/change.rb

Overview

Calculates and prints affected components & files

Constant Summary collapse

InvalidSelectionError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(umbrella, results, branch) ⇒ Change

Returns a new instance of Change.



11
12
13
14
15
16
17
# File 'lib/cobra_commander/change.rb', line 11

def initialize(umbrella, results, branch)
  @root_dir = Dir.chdir(umbrella.path) { `git rev-parse --show-toplevel`.chomp }
  @results = results
  @branch = branch
  @umbrella = umbrella
  @affected = Affected.new(@umbrella, changes)
end

Instance Method Details

#run!Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cobra_commander/change.rb', line 19

def run!
  assert_valid_result_choice
  if selected_result?("json")
    puts @affected.json_representation
  else
    show_full if selected_result?("full")
    tests_to_run
  end
rescue InvalidSelectionError => e
  puts e.message
end