trick_bag 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b83787b4b4a7182fb18c9cbcd6eb7d3fcf6a18b
4
- data.tar.gz: 8b0ff5d556e5d0da614f680672a31553484458b0
3
+ metadata.gz: 7c735881db9b16262fde9e1753bbf19a2d3f09a2
4
+ data.tar.gz: bae4754d55eb643fdd1d0ecfb66533b0bd984c13
5
5
  SHA512:
6
- metadata.gz: 049f3157a32ece02aa9b5d55aecc639de6463d2c1f7738577be6840291232a7efdb391ae49e47ee6a013cf805e41e139cab502abc500912b1a03d9f1a61797f0
7
- data.tar.gz: 89bbbc2ded12adca468ad8e3298363d62ba29b29bb53f6823ffe409cc28ddfd9fe822aa993bf724d139d943df4db49ac3892feb1f573847d99f12a5646afeef8
6
+ metadata.gz: 2ca095d4e271a8e963a6d1bba1541699e0bfc33ee7dc1db9adee2dc6dc1669a582144dd55b24ebd3f15d62a1e7960ad382df7ddf9b1b48ae9ab3e90afa359a62
7
+ data.tar.gz: a1100d716519313fe9158210264217cebc99283924cf7fcd612714d1ae1563f7e0f2b4296d3505701d8f8c4d756d0c340b5589d3fa337e588f7219bee741779e
data/RELEASE_NOTES.md CHANGED
@@ -1,7 +1,13 @@
1
+ ## v0.49.0
2
+
3
+ * Corrected name from from_array to from_enumerable.
4
+
5
+
1
6
  ## v0.48.0
2
7
 
3
8
  * Add TrickBag::Numeric::MultiCounter#total_count and #percent_of_total_hash.
4
9
 
10
+
5
11
  ## v0.47.0
6
12
 
7
13
  * Remove array_as_multiline_string; it's too similar to array.join("\n").
@@ -15,7 +15,7 @@ class MultiCounter
15
15
  @counts = Hash.new(0)
16
16
  end
17
17
 
18
- def self.from_array(values, name = '')
18
+ def self.from_enumerable(values, name = '')
19
19
  m_counter = MultiCounter.new(name)
20
20
  values.each { |value| m_counter.increment(value) }
21
21
  m_counter
@@ -74,3 +74,48 @@ class MultiCounter
74
74
  end
75
75
  end
76
76
  end
77
+
78
+
79
+ =begin
80
+
81
+ Here is a sample script that exercises some of this class' features:
82
+
83
+ #!/usr/bin/env ruby
84
+
85
+ require 'trick_bag'
86
+ require 'awesome_print'
87
+
88
+ data = %w(Open New Open Closed Open New Closed Open Open Open)
89
+ m_counter = TrickBag::Numeric::MultiCounter.from_enumerable(data, 'Status for Issue #123')
90
+ puts "\nMultiCounter hash:"
91
+ ap m_counter.to_hash
92
+
93
+ puts "\nNumber Open:"
94
+ puts m_counter['Open']
95
+
96
+ pc_totals = m_counter.percent_of_total_hash
97
+ puts "\nPercents of Total:"
98
+ ap pc_totals
99
+
100
+
101
+ # Output is:
102
+ #
103
+ # MultiCounter hash:
104
+ # {
105
+ # "Open" => 6,
106
+ # "New" => 2,
107
+ # "Closed" => 2
108
+ # }
109
+ #
110
+ # Number Open:
111
+ # 6
112
+ #
113
+ # Percents of Total:
114
+ # {
115
+ # "Open" => 0.6,
116
+ # "New" => 0.2,
117
+ # "Closed" => 0.2
118
+ # }
119
+
120
+ =end
121
+
@@ -1,3 +1,3 @@
1
1
  module TrickBag
2
- VERSION = "0.48.0"
2
+ VERSION = "0.49.0"
3
3
  end
@@ -31,13 +31,13 @@ module Numeric
31
31
  end
32
32
 
33
33
  specify 'creating from an array works correctly' do
34
- m_counter = MultiCounter.from_array(sample_data)
34
+ m_counter = MultiCounter.from_enumerable(sample_data)
35
35
  expect(m_counter.total_count).to eq(10)
36
36
  expect(m_counter['Open']).to eq(6)
37
37
  end
38
38
 
39
39
  specify 'percent_of_total_hash is correctly calculated' do
40
- ptotal_hash = MultiCounter.from_array(sample_data).percent_of_total_hash
40
+ ptotal_hash = MultiCounter.from_enumerable(sample_data).percent_of_total_hash
41
41
  expect(ptotal_hash['Open']).to eq(0.6)
42
42
  expect(ptotal_hash['Closed']).to eq(0.2)
43
43
  expect(ptotal_hash['New']).to eq(0.2)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trick_bag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.48.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Bennett