Class: Knapsack::Distributors::BaseDistributor

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack/distributors/base_distributor.rb

Direct Known Subclasses

LeftoverDistributor, ReportDistributor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ BaseDistributor

Returns a new instance of BaseDistributor.



6
7
8
9
10
11
# File 'lib/knapsack/distributors/base_distributor.rb', line 6

def initialize(args={})
  @report = args[:report] || default_report
  @ci_node_total = args[:ci_node_total] || config.ci_node_total
  @ci_node_index = args[:ci_node_index] || config.ci_node_index
  @spec_pattern = args[:spec_pattern] || config.spec_pattern
end

Instance Attribute Details

#node_specsObject (readonly)

Returns the value of attribute node_specs.



4
5
6
# File 'lib/knapsack/distributors/base_distributor.rb', line 4

def node_specs
  @node_specs
end

#reportObject (readonly)

Returns the value of attribute report.



4
5
6
# File 'lib/knapsack/distributors/base_distributor.rb', line 4

def report
  @report
end

#spec_patternObject (readonly)

Returns the value of attribute spec_pattern.



4
5
6
# File 'lib/knapsack/distributors/base_distributor.rb', line 4

def spec_pattern
  @spec_pattern
end

Instance Method Details

#all_specsObject



36
37
38
# File 'lib/knapsack/distributors/base_distributor.rb', line 36

def all_specs
  @all_specs ||= Dir[spec_pattern]
end

#assign_spec_files_to_nodeObject



30
31
32
33
34
# File 'lib/knapsack/distributors/base_distributor.rb', line 30

def assign_spec_files_to_node
  default_node_specs
  @node_index = 0
  post_assign_spec_files_to_node
end

#ci_node_indexObject



17
18
19
# File 'lib/knapsack/distributors/base_distributor.rb', line 17

def ci_node_index
  @ci_node_index.to_i
end

#ci_node_totalObject



13
14
15
# File 'lib/knapsack/distributors/base_distributor.rb', line 13

def ci_node_total
  @ci_node_total.to_i
end

#specs_for_current_nodeObject



21
22
23
# File 'lib/knapsack/distributors/base_distributor.rb', line 21

def specs_for_current_node
  specs_for_node(ci_node_index)
end

#specs_for_node(node_index) ⇒ Object



25
26
27
28
# File 'lib/knapsack/distributors/base_distributor.rb', line 25

def specs_for_node(node_index)
  assign_spec_files_to_node
  post_specs_for_node(node_index)
end