greenhat 0.3.2 → 0.3.3

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
  SHA256:
3
- metadata.gz: db336e98cd2a446c371d866d068eb9b485f9782b2ea7182f4b4da651011e2083
4
- data.tar.gz: 90b1858171c14ebe93e3a0ff42dffe2965602835f8f2cc98178f6a81ec816352
3
+ metadata.gz: ac7b0e70e5a13dc6f8f88a4f12fec812e38e7d838537abe83b7d4dc2e8b43663
4
+ data.tar.gz: 84246bc31bd38af74e9f4f8d95f2f7ffa1ca33978dc0d0862ec0b50eaff20196
5
5
  SHA512:
6
- metadata.gz: 94d78c52d3e4b800ac90798d8030dfa9962c7e7c628bd8b636f5471fcf2c35044aa044a91edbd412827db2daf36117ab47cfecc4c6a85e49875e3e6d7756e1d0
7
- data.tar.gz: fad9f87be4735b5d028ccc7e251fce423de9cf0d440253b65dbaddbc36b268234ffedc7277f9207131692bcf8ea74cd9a4b70c433f55e158b6cd30aae73edf1d
6
+ metadata.gz: ba104ea8d7b4e52babf8bdf27ea4f3dbdb9e92820589881bab639a01e8558c355389a0f10b3c17dbe5c7ac881f10364ad06ec0c973934f06d735f948bb57fbd3
7
+ data.tar.gz: a2013229826758ca61335f5cf8d58c3a4a4206e656dce084f90781c264e4930c5c3fd09b7475a43dd31819bc2562e85e5799de775cc5db9dfaa3f73c0228ac3a
@@ -368,7 +368,7 @@ module GreenHat
368
368
 
369
369
  # Loop through Stats, Separate Hash/Tables
370
370
  stats.map do |field|
371
- occurrences = filter_count_occurrences(results, field)
371
+ occurrences = filter_count_occurrences(results, field, flags)
372
372
 
373
373
  # Total Occurences
374
374
  total = occurrences.values.sum
@@ -405,10 +405,17 @@ module GreenHat
405
405
  end
406
406
 
407
407
  # Helper to Count occurrences
408
- def self.filter_count_occurrences(results, field)
408
+ def self.filter_count_occurrences(results, field, flags = {})
409
409
  results.each_with_object(Hash.new(0)) do |entry, counts|
410
410
  if entry.key? field
411
- counts[entry[field]] += 1
411
+ # Rounding in pagination breaks stats
412
+ key = if flags.key?(:round) && entry[field].numeric?
413
+ entry[field].to_f.round(flags.round)
414
+ else
415
+ entry[field]
416
+ end
417
+
418
+ counts[key] += 1
412
419
  else
413
420
  counts['None'.pastel(:bright_black)] += 1
414
421
  end
@@ -1,3 +1,3 @@
1
1
  module GreenHat
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greenhat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davin Walker