differential 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fa747f8e377b675d626c4c49cd31f84a73ca9bf8
4
- data.tar.gz: 4c3af655ca69988cffa9928a3debb84eaeb8206b
2
+ SHA256:
3
+ metadata.gz: aff1c3bc13783c56a247f1b98cba64325353025acc9a6a7066faeafc0ed13648
4
+ data.tar.gz: 5f7ef17c708fd0aeb0d526e1b2730443aa3238ac911d3f2f991fd077d77631a1
5
5
  SHA512:
6
- metadata.gz: 6758f520698fa56574aa43b44e52a798db2c116200abea0ecbae1f14df36171d8f407e4755522ff70b95ac6328fc6117511a2efa11c8552bea0ed59e7d167eb9
7
- data.tar.gz: b9e7a247c19f542fdc06783b324612d4a1d7ee6f7f8c43ece8f2925a175be1b13b0ac113cd852138f1d412eb621b0f2951a85685cfa1b2f353a9bc5e54e9b4f3
6
+ metadata.gz: '02695fa3ae5f6a79832b20ab712686cfb8c73870b5db4b09a4401d5ea3ea17e7a1d4adf1196275d450584d78dcac82a3a78a48fe0db0bcf9a2e7b2a035b0d449'
7
+ data.tar.gz: dd6a57d4355e960d241f93b60c308244ae1e941cff08be46cc2cec3a73ce2dce573d75cdae356835d919da383ad92775addf99d3517c1abc4b77c102ebccd89e
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  /tmp
4
+ /coverage
@@ -3,3 +3,6 @@ Metrics/LineLength:
3
3
 
4
4
  Metrics/BlockLength:
5
5
  ExcludedMethods: ['it', 'describe', 'context']
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.3
@@ -1 +1 @@
1
- 2.3.7
1
+ 2.6.0
@@ -1,10 +1,20 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=1d6125e1405ca3b6b88d283e48958d8996eda8f3ece262fd0714e3a0463df3c3
1
4
  language: ruby
2
5
  rvm:
3
- - 2.3.1
4
- - 2.3.7
5
- - 2.3.8
6
- - 2.6.0
6
+ # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
+ - 2.3.8
8
+ - 2.4.5
9
+ - 2.5.3
10
+ - 2.6.0
7
11
  cache: bundler
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
8
16
  script:
9
- - bundle exec rubocop
10
- - bundle exec rspec
17
+ - bundle exec rubocop
18
+ - bundle exec rspec
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -1,3 +1,12 @@
1
+ ## 1.1.0 (January 31, 2019)
2
+
3
+ Maintenance Update + 1 Enhancement
4
+
5
+ * Ruby to min version 2.3.8
6
+ * Updated Rubocop
7
+ * Updated README
8
+ * Minor performance optimization: Allow input to be a reader (responds to #each.)
9
+
1
10
  ## 1.0.6 (January 11, 2019)
2
11
 
3
12
  - Added Data Peeking for groups and items (group#data_peek, item#data_peek methods).
@@ -1,14 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- differential (1.0.6)
4
+ differential (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ ansi (1.5.0)
9
10
  ast (2.4.0)
10
11
  coderay (1.1.2)
11
12
  diff-lcs (1.3)
13
+ docile (1.3.1)
12
14
  ffi (1.9.25)
13
15
  formatador (0.2.5)
14
16
  guard (2.15.0)
@@ -25,7 +27,9 @@ GEM
25
27
  guard (~> 2.1)
26
28
  guard-compat (~> 1.1)
27
29
  rspec (>= 2.99.0, < 4.0)
28
- jaro_winkler (1.5.1)
30
+ hirb (0.7.3)
31
+ jaro_winkler (1.5.2)
32
+ json (2.1.0)
29
33
  listen (3.1.5)
30
34
  rb-fsevent (~> 0.9, >= 0.9.4)
31
35
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -36,8 +40,8 @@ GEM
36
40
  notiffany (0.1.1)
37
41
  nenv (~> 0.1)
38
42
  shellany (~> 0.0)
39
- parallel (1.12.1)
40
- parser (2.5.3.0)
43
+ parallel (1.13.0)
44
+ parser (2.6.0.0)
41
45
  ast (~> 2.4.0)
42
46
  powerpack (0.1.2)
43
47
  pry (0.12.2)
@@ -60,19 +64,28 @@ GEM
60
64
  diff-lcs (>= 1.2.0, < 2.0)
61
65
  rspec-support (~> 3.8.0)
62
66
  rspec-support (3.8.0)
63
- rubocop (0.59.2)
67
+ rubocop (0.63.1)
64
68
  jaro_winkler (~> 1.5.1)
65
69
  parallel (~> 1.10)
66
70
  parser (>= 2.5, != 2.5.1.1)
67
71
  powerpack (~> 0.1)
68
72
  rainbow (>= 2.2.2, < 4.0)
69
73
  ruby-progressbar (~> 1.7)
70
- unicode-display_width (~> 1.0, >= 1.0.1)
74
+ unicode-display_width (~> 1.4.0)
71
75
  ruby-progressbar (1.10.0)
72
76
  ruby_dep (1.5.0)
73
77
  shellany (0.0.1)
78
+ simplecov (0.16.1)
79
+ docile (~> 1.1)
80
+ json (>= 1.8, < 3)
81
+ simplecov-html (~> 0.10.0)
82
+ simplecov-console (0.4.2)
83
+ ansi
84
+ hirb
85
+ simplecov
86
+ simplecov-html (0.10.2)
74
87
  thor (0.20.3)
75
- unicode-display_width (1.4.0)
88
+ unicode-display_width (1.4.1)
76
89
 
77
90
  PLATFORMS
78
91
  ruby
@@ -81,7 +94,9 @@ DEPENDENCIES
81
94
  differential!
82
95
  guard-rspec (~> 4.7)
83
96
  rspec (~> 3.8)
84
- rubocop (~> 0.59)
97
+ rubocop (~> 0.63.1)
98
+ simplecov (~> 0.16.1)
99
+ simplecov-console (~> 0.4.2)
85
100
 
86
101
  BUNDLED WITH
87
- 1.17.1
102
+ 1.17.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Differential
2
2
 
3
- [![Build Status](https://travis-ci.org/bluemarblepayroll/differential.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/differential)
3
+ [![Gem Version](https://badge.fury.io/rb/differential.svg)](https://badge.fury.io/rb/differential) [![Build Status](https://travis-ci.org/bluemarblepayroll/differential.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/differential) [![Maintainability](https://api.codeclimate.com/v1/badges/6874556c14fe97ce898e/maintainability)](https://codeclimate.com/github/bluemarblepayroll/differential/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/6874556c14fe97ce898e/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/differential/test_coverage)
4
4
 
5
5
  Have you ever had two numerical-based data sets of mostly the same data and you wanted to see the summations and deltas of each data set at the report, group, and line level? Look no further! Differential allows you to pass in two data sets and it will calculate all that for you.
6
6
 
@@ -251,12 +251,12 @@ Note: ensure you have proper authorization before trying to publish new versions
251
251
  After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
252
252
 
253
253
  1. Merge Pull Request into master
254
- 2. Update [lib/differential/version.rb](https://github.com/bluemarblepayroll/differential/blob/master/lib/differential/version.rb) [version number](https://semver.org/)
255
- 3. Bundle
256
- 4. Update CHANGELOG.md
257
- 5. Commit & Push master to remote and ensure CI builds master successfully
254
+ 2. Update ```lib/differential/version.rb``` using [semantic versioning](https://semver.org/)
255
+ 3. Install dependencies: ```bundle```
256
+ 4. Update ```CHANGELOG.md``` with release notes
257
+ 5. Commit & push master to remote and ensure CI builds master successfully
258
258
  6. Build the project locally: `gem build differential`
259
- 7. Publish package to NPM: `gem push differential-X.gem` where X is the version to push
259
+ 7. Publish package to RubyGems: `gem push differential-X.gem` where X is the version to push
260
260
  8. Tag master with new version: `git tag <version>`
261
261
  9. Push tags remotely: `git push origin --tags`
262
262
 
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'differential'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start
@@ -21,9 +21,11 @@ Gem::Specification.new do |s|
21
21
  s.homepage = 'https://github.com/bluemarblepayroll/differential'
22
22
  s.license = 'MIT'
23
23
 
24
- s.required_ruby_version = '>= 2.3.1'
24
+ s.required_ruby_version = '>= 2.3.8'
25
25
 
26
26
  s.add_development_dependency('guard-rspec', '~>4.7')
27
27
  s.add_development_dependency('rspec', '~> 3.8')
28
- s.add_development_dependency('rubocop', '~> 0.59')
28
+ s.add_development_dependency('rubocop', '~>0.63.1')
29
+ s.add_development_dependency('simplecov', '~>0.16.1')
30
+ s.add_development_dependency('simplecov-console', '~>0.4.2')
29
31
  end
@@ -23,8 +23,8 @@ module Differential
23
23
  reader = ::Differential::Parser::Reader.new(reader_config)
24
24
  report = ::Differential::Calculator::Report.new
25
25
 
26
- reader.each(dataset_a) { |record| report.add(record, A) }
27
- reader.each(dataset_b) { |record| report.add(record, B) }
26
+ dataset_a.each { |hash| report.add(reader.read(hash), A) }
27
+ dataset_b.each { |hash| report.add(reader.read(hash), B) }
28
28
 
29
29
  report
30
30
  end
@@ -31,30 +31,21 @@ module Differential
31
31
  @group_id_key = group_id_key
32
32
  end
33
33
 
34
- def each(hashes)
35
- return enum_for(:each) unless block_given?
36
-
37
- array(hashes).each do |hash|
38
- next unless hash
39
-
40
- record = read(hash)
41
- yield record
42
- end
43
- end
44
-
45
- private
46
-
47
34
  def read(hash)
48
35
  id = make_record_id(hash)
49
36
  group_id = make_group_id(hash)
50
37
  value = hash[value_key]
51
38
 
52
- ::Differential::Parser::Record.new(id: id,
53
- group_id: group_id,
54
- value: value,
55
- data: hash)
39
+ ::Differential::Parser::Record.new(
40
+ id: id,
41
+ group_id: group_id,
42
+ value: value,
43
+ data: hash
44
+ )
56
45
  end
57
46
 
47
+ private
48
+
58
49
  def make_record_id(hash)
59
50
  record_id_key_array.map { |k| hash[k] }
60
51
  end
@@ -74,8 +65,12 @@ module Differential
74
65
  def array(hashes)
75
66
  if hashes.is_a?(Hash)
76
67
  [hashes]
77
- else
68
+ # If the consumer passed in a value that responds to each (is enumerable-like) then
69
+ # we can accept that as is.
70
+ elsif !hashes.respond_to?(:each)
78
71
  Array(hashes)
72
+ else
73
+ hashes
79
74
  end
80
75
  end
81
76
  end
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Differential
11
- VERSION = '1.0.6'
11
+ VERSION = '1.1.0'
12
12
  end
@@ -27,10 +27,10 @@ describe ::Differential::Calculator::Group do
27
27
  ]
28
28
 
29
29
  unsorted_ids.each do |unsorted_id|
30
- record = ::Differential::Parser::Record.new(id: unsorted_id,
30
+ record = ::Differential::Parser::Record.new(id: unsorted_id,
31
31
  group_id: group_id,
32
- value: 1,
33
- data: {})
32
+ value: 1,
33
+ data: {})
34
34
 
35
35
  group.add(record, ::Differential::Calculator::Side::A)
36
36
  end
@@ -43,10 +43,10 @@ describe ::Differential::Calculator::Group do
43
43
  end
44
44
 
45
45
  it 'should peek at data based on first item it finds' do
46
- record = ::Differential::Parser::Record.new(id: '1',
46
+ record = ::Differential::Parser::Record.new(id: '1',
47
47
  group_id: group_id,
48
- value: 1,
49
- data: { name: 'Millie' })
48
+ value: 1,
49
+ data: { name: 'Millie' })
50
50
 
51
51
  group.add(record, ::Differential::Calculator::Side::A)
52
52
 
@@ -146,10 +146,10 @@ describe ::Differential::Calculator::Report do
146
146
  ]
147
147
 
148
148
  unsorted_ids.each do |unsorted_id|
149
- record = ::Differential::Parser::Record.new(id: '1',
149
+ record = ::Differential::Parser::Record.new(id: '1',
150
150
  group_id: unsorted_id,
151
- value: 1,
152
- data: {})
151
+ value: 1,
152
+ data: {})
153
153
 
154
154
  report.add(record, ::Differential::Calculator::Side::A)
155
155
  end
@@ -20,14 +20,14 @@ describe ::Differential do
20
20
  ]
21
21
 
22
22
  reader_config = {
23
- record_id_key: :name,
24
- value_key: :minutes,
25
- group_id_key: :transport
23
+ record_id_key: :name,
24
+ value_key: :minutes,
25
+ group_id_key: :transport
26
26
  }
27
27
 
28
- report = ::Differential.calculate(dataset_a: dataset_a,
29
- dataset_b: dataset_b,
30
- reader_config: reader_config)
28
+ report = ::Differential.calculate(dataset_a: dataset_a,
29
+ dataset_b: dataset_b,
30
+ reader_config: reader_config)
31
31
 
32
32
  expect(report.groups.length).to eq(2)
33
33
  end
@@ -12,9 +12,9 @@ require './spec/spec_helper'
12
12
  describe ::Differential::Parser::Reader do
13
13
  it 'should initialize correctly' do
14
14
  hash = {
15
- record_id_key: :name,
16
- value_key: :minutes,
17
- group_id_key: :transport
15
+ record_id_key: :name,
16
+ value_key: :minutes,
17
+ group_id_key: :transport
18
18
  }
19
19
 
20
20
  reader = ::Differential::Parser::Reader.new(hash)
@@ -26,97 +26,36 @@ describe ::Differential::Parser::Reader do
26
26
 
27
27
  context 'When reading just id and value' do
28
28
  it 'should properly create a record from a hash' do
29
- reader = ::Differential::Parser::Reader.new(record_id_key: :name,
30
- value_key: :minutes)
29
+ reader = ::Differential::Parser::Reader.new(record_id_key: :name,
30
+ value_key: :minutes)
31
31
 
32
- hashes = [
33
- {
34
- name: 'Matt',
35
- minutes: 34
36
- }
37
- ]
32
+ hash = {
33
+ name: 'Matt',
34
+ minutes: 34
35
+ }
38
36
 
39
- records = []
40
- reader.each(hashes) do |record|
41
- records << record
42
- end
43
-
44
- record = records.first
45
- hash = hashes.first
37
+ record = reader.read(hash)
46
38
 
47
39
  expect(record.id).to eq(hash[:name])
48
40
  expect(record.group_id).to eq('')
49
41
  expect(record.value).to eq(hash[:minutes])
50
42
  expect(record.data).to eq(hash)
51
43
  end
52
-
53
- it 'should skip null records' do
54
- reader = ::Differential::Parser::Reader.new(record_id_key: :name,
55
- value_key: :minutes)
56
-
57
- hashes = [nil]
58
-
59
- records = []
60
- reader.each(hashes) do |record|
61
- records << record
62
- end
63
-
64
- expect(records.length).to eq(0)
65
- end
66
- end
67
-
68
- it 'should read non-array input' do
69
- reader = ::Differential::Parser::Reader.new(record_id_key: :name,
70
- value_key: :minutes)
71
-
72
- hashes = {
73
- name: 'Matt',
74
- minutes: 34
75
- }
76
-
77
- records = []
78
- reader.each(hashes) do |record|
79
- records << record
80
- end
81
-
82
- expect(records.length).to eq(1)
83
- end
84
-
85
- it 'should read null input' do
86
- reader = ::Differential::Parser::Reader.new(record_id_key: :name,
87
- value_key: :minutes)
88
-
89
- hashes = nil
90
-
91
- records = []
92
- reader.each(hashes) do |record|
93
- records << record
94
- end
95
-
96
- expect(records.length).to eq(0)
97
44
  end
98
45
 
99
46
  context 'When reading singular keys' do
100
47
  it 'should properly create a record from a hash' do
101
- reader = ::Differential::Parser::Reader.new(record_id_key: :name,
102
- value_key: :minutes,
48
+ reader = ::Differential::Parser::Reader.new(record_id_key: :name,
49
+ value_key: :minutes,
103
50
  group_id_key: :transport)
104
51
 
105
- hashes = [
106
- {
107
- name: 'Matt',
108
- minutes: 34,
109
- transport: 'Train'
110
- }
111
- ]
112
-
113
- records = []
114
- reader.each(hashes) do |record|
115
- records << record
116
- end
52
+ hash = {
53
+ name: 'Matt',
54
+ minutes: 34,
55
+ transport: 'Train'
56
+ }
117
57
 
118
- record = records.first
119
- hash = hashes.first
58
+ record = reader.read(hash)
120
59
 
121
60
  expect(record.id).to eq(hash[:name])
122
61
  expect(record.group_id).to eq(hash[:transport])
@@ -127,27 +66,19 @@ describe ::Differential::Parser::Reader do
127
66
 
128
67
  context 'When reading multiple id keys' do
129
68
  it 'should properly create a record from a hash' do
130
- reader = ::Differential::Parser::Reader.new(record_id_key: %i[first last],
131
- value_key: :minutes,
132
- group_id_key: %i[transport direction])
133
-
134
- hashes = [
135
- {
136
- first: 'Matt',
137
- last: 'Smith',
138
- minutes: 34,
139
- transport: 'Train',
140
- direction: 'Outbound'
141
- }
142
- ]
143
-
144
- records = []
145
- reader.each(hashes) do |record|
146
- records << record
147
- end
148
-
149
- record = records.first
150
- hash = hashes.first
69
+ reader = ::Differential::Parser::Reader.new(record_id_key: %i[first last],
70
+ value_key: :minutes,
71
+ group_id_key: %i[transport direction])
72
+
73
+ hash = {
74
+ first: 'Matt',
75
+ last: 'Smith',
76
+ minutes: 34,
77
+ transport: 'Train',
78
+ direction: 'Outbound'
79
+ }
80
+
81
+ record = reader.read(hash)
151
82
 
152
83
  expect(record.id).to eq("#{hash[:first]}:#{hash[:last]}")
153
84
  expect(record.id.data).to eq([hash[:first], hash[:last]])
@@ -10,3 +10,8 @@
10
10
  require 'ostruct'
11
11
 
12
12
  require './lib/differential'
13
+
14
+ require 'simplecov'
15
+ require 'simplecov-console'
16
+ SimpleCov.formatter = SimpleCov::Formatter::Console
17
+ SimpleCov.start
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: differential
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2019-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-rspec
@@ -44,21 +44,50 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.59'
47
+ version: 0.63.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.59'
54
+ version: 0.63.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.16.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.16.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov-console
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.4.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.4.2
55
83
  description: |2
56
84
  Differential is a numeric-based library will compare two datasets and give you three
57
85
  levels of comparison: report, group, and item level.
58
86
  Each level provides the sum of each dataset and the difference.
59
87
  email:
60
88
  - mruggio@bluemarblepayroll.com
61
- executables: []
89
+ executables:
90
+ - console
62
91
  extensions: []
63
92
  extra_rdoc_files: []
64
93
  files:
@@ -73,6 +102,7 @@ files:
73
102
  - Guardfile
74
103
  - LICENSE
75
104
  - README.md
105
+ - bin/console
76
106
  - differential.gemspec
77
107
  - lib/differential.rb
78
108
  - lib/differential/calculator/calculator.rb
@@ -109,15 +139,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
139
  requirements:
110
140
  - - ">="
111
141
  - !ruby/object:Gem::Version
112
- version: 2.3.1
142
+ version: 2.3.8
113
143
  required_rubygems_version: !ruby/object:Gem::Requirement
114
144
  requirements:
115
145
  - - ">="
116
146
  - !ruby/object:Gem::Version
117
147
  version: '0'
118
148
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.5.2.3
149
+ rubygems_version: 3.0.1
121
150
  signing_key:
122
151
  specification_version: 4
123
152
  summary: Dataset Differential Engine