Class: PuppetBox::ResultSet
- Inherits:
-
Object
- Object
- PuppetBox::ResultSet
- Defined in:
- lib/puppetbox/result_set.rb
Instance Method Summary collapse
-
#class_size(node_name) ⇒ Object
The count of how many classes we presently have saved for a given node.
- #data ⇒ Object
-
#initialize ⇒ ResultSet
constructor
A new instance of ResultSet.
-
#node_size ⇒ Object
The count of how many nodes we presently have saved.
- #passed? ⇒ Boolean
- #save(node_name, class_name, result) ⇒ Object
-
#test_size ⇒ Object
The count of how many tests this result_set contains for all nodes and classes.
Constructor Details
#initialize ⇒ ResultSet
Returns a new instance of ResultSet.
3 4 5 |
# File 'lib/puppetbox/result_set.rb', line 3 def initialize @results = {} end |
Instance Method Details
#class_size(node_name) ⇒ Object
The count of how many classes we presently have saved for a given node
47 48 49 50 51 52 53 54 55 |
# File 'lib/puppetbox/result_set.rb', line 47 def class_size(node_name) if @results.has_key?(node_name) size = @results[node_name].size else size = 0 end size end |
#data ⇒ Object
37 38 39 |
# File 'lib/puppetbox/result_set.rb', line 37 def data @results end |
#node_size ⇒ Object
The count of how many nodes we presently have saved
42 43 44 |
# File 'lib/puppetbox/result_set.rb', line 42 def node_size @results.size end |
#passed? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/puppetbox/result_set.rb', line 29 def passed? @results.map { |node_name, class_results_hash| class_results_hash.map { |class_name, class_results| class_results.passed? }.all? }.all? end |
#save(node_name, class_name, result) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puppetbox/result_set.rb', line 7 def save(node_name, class_name, result) # check we didn't make a stupid programming error if result.class != ::PuppetBox::Result raise "result to save must be instance of PuppetBox::Result" end # if this is the first set of results for this node then we need to make # a hash to contain the results if ! @results.has_key?(node_name) @results[node_name] = {} end # We can only run the same class on each node once, if we attempt to do so # again, if @results[node_name].has_key?(class_name) raise "Duplicate results for class #{class_name} detected, You can " \ "only test the same class once per node. Check your test configuration" else @results[node_name][class_name] = result end end |
#test_size ⇒ Object
The count of how many tests this result_set contains for all nodes and classes
59 60 61 62 63 |
# File 'lib/puppetbox/result_set.rb', line 59 def test_size @results.map {|node_name, classes| classes.size }.reduce(:+) end |