goldmine 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/goldmine/hash_miner.rb +2 -1
- data/lib/goldmine/version.rb +1 -1
- data/test/test_goldmine.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c686bfb600cadea453033f457a751ce8538b00af
|
4
|
+
data.tar.gz: 1216c9ddd41197c6f25c1017039b0d2428a20105
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3baf5482a83183114999ed3d705ff8c97b6bc5b0cb9a3ae02e64f0eb9af378ea8fc4a8e39e5003f6da9eb8fae275407bb541f6eb51880e886205a72843f7532e
|
7
|
+
data.tar.gz: acf22665e1acf226ef31274021da2ceb406ef3a268555abb7f597fccc3b08ba7290f81ef9789b684073455b4f9c316a0d889208375c240da57e34600c0a978fd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -151,10 +151,10 @@ This feature is useful when you need to do things like export to CSV or build us
|
|
151
151
|
mined.to_a
|
152
152
|
# result:
|
153
153
|
[
|
154
|
-
["Name has an 'e'", ">= 21 years old", "
|
155
|
-
[false, true, 2],
|
156
|
-
[true, true, 2],
|
157
|
-
[true, false, 1]
|
154
|
+
["Name has an 'e'", ">= 21 years old", "Percent of Total", "Count"],
|
155
|
+
[false, true, 0.4, 2],
|
156
|
+
[true, true, 0.4, 2],
|
157
|
+
[true, false, 0.2, 1]
|
158
158
|
]
|
159
159
|
```
|
160
160
|
|
data/lib/goldmine/hash_miner.rb
CHANGED
@@ -84,11 +84,12 @@ module Goldmine
|
|
84
84
|
rows = map do |pair|
|
85
85
|
[].tap do |row|
|
86
86
|
row.concat pair.first.values
|
87
|
+
row << sprintf("%.2f", (pair.last.size / source_data.size.to_f)).to_f
|
87
88
|
row << pair.last.size
|
88
89
|
end
|
89
90
|
end
|
90
91
|
rows = rows.sort_by(&block) if block_given?
|
91
|
-
header = pivoted_keys.map(&:to_s)
|
92
|
+
header = [pivoted_keys.map(&:to_s), "Percent of Total", "Count"].flatten
|
92
93
|
rows.insert 0, header
|
93
94
|
rows
|
94
95
|
end
|
data/lib/goldmine/version.rb
CHANGED
data/test/test_goldmine.rb
CHANGED
@@ -67,7 +67,7 @@ class TestGoldmine < PryTest::Test
|
|
67
67
|
record[:age] >= 21
|
68
68
|
end
|
69
69
|
|
70
|
-
expected = [["Name has an 'e'", ">= 21 years old", "
|
70
|
+
expected = [["Name has an 'e'", ">= 21 years old", "Percent of Total", "Count"], [true, false, 0.2, 1], [false, true, 0.4, 2], [true, true, 0.4, 2]]
|
71
71
|
|
72
72
|
# block is sort_by
|
73
73
|
tabular_data = mined.to_a do |row|
|