Class: CobraCommander::Affected

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

Overview

Calculates directly & transitively affected components

Instance Method Summary collapse

Constructor Details

#initialize(umbrella, changes) ⇒ Affected

Returns a new instance of Affected.



6
7
8
9
10
# File 'lib/cobra_commander/affected.rb', line 6

def initialize(umbrella, changes)
  @umbrella = umbrella
  @changes = changes
  run!
end

Instance Method Details

#directlyObject



20
21
22
# File 'lib/cobra_commander/affected.rb', line 20

def directly
  @directly.map(&method(:affected_component))
end

#json_representationObject

rubocop:disable Metrics/MethodLength



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cobra_commander/affected.rb', line 28

def json_representation # rubocop:disable Metrics/MethodLength
  {
    changed_files: @changes,
    directly_affected_components: directly,
    transitively_affected_components: transitively,
    test_scripts: scripts,
    component_names: names,
    languages: {
      ruby: contains_ruby?,
      javascript: contains_js?,
    },
  }.to_json
end

#namesObject



12
13
14
# File 'lib/cobra_commander/affected.rb', line 12

def names
  @names ||= all_affected.map(&:name)
end

#scriptsObject



16
17
18
# File 'lib/cobra_commander/affected.rb', line 16

def scripts
  @scripts ||= paths.map { |path| File.join(path, "test.sh") }
end

#transitivelyObject



24
25
26
# File 'lib/cobra_commander/affected.rb', line 24

def transitively
  @transitively.map(&method(:affected_component))
end