differential 1.0.4 → 1.0.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/differential/calculator/group.rb +5 -1
- data/lib/differential/calculator/item.rb +1 -1
- data/lib/differential/calculator/report.rb +4 -0
- data/lib/differential/version.rb +1 -1
- data/spec/differential/calculator/group_spec.rb +27 -3
- data/spec/differential/calculator/report_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338faf87efae2afbc60eaa95b20fbfe0cddbf410
|
4
|
+
data.tar.gz: 91afe0b117f23e33f86be2df86169fa23111152c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a27dc65828848113eba8c0128ac39d791e2962e29ec7cfaa44e01bba160a057f5fff7b1d43d35de3fad9337316d67d75a6033e733810f41f7dd55f2d6c7c812
|
7
|
+
data.tar.gz: fd0615b537efe24c4df38615abe47f082447dc3299d60724978aac18e6c0d4c926a9dbf694bf06677fafbf630d7349c24894755036df6f45601dbe8a5b65cc4b
|
data/Gemfile.lock
CHANGED
@@ -22,7 +22,11 @@ module Differential
|
|
22
22
|
def initialize(id)
|
23
23
|
raise ArgumentError, 'id is required' unless id
|
24
24
|
|
25
|
-
@id = id
|
25
|
+
@id = id.is_a?(::Differential::Parser::Id) ? id : ::Differential::Parser::Id.new(id)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sorted_items
|
29
|
+
items.sort_by { |item| item.id.value }
|
26
30
|
end
|
27
31
|
|
28
32
|
def items
|
data/lib/differential/version.rb
CHANGED
@@ -10,11 +10,35 @@
|
|
10
10
|
require './spec/spec_helper'
|
11
11
|
|
12
12
|
describe ::Differential::Calculator::Group do
|
13
|
-
let(:
|
13
|
+
let(:group_id) { 'matt' }
|
14
14
|
|
15
|
-
let(:group) { ::Differential::Calculator::Group.new(
|
15
|
+
let(:group) { ::Differential::Calculator::Group.new(group_id) }
|
16
16
|
|
17
17
|
it 'should initialize correctly' do
|
18
|
-
expect(group.id).to eq(
|
18
|
+
expect(group.id).to eq(group_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#sorted_items should be lexicographically sorted' do
|
22
|
+
unsorted_ids = [
|
23
|
+
'zYx',
|
24
|
+
'123',
|
25
|
+
'aBC',
|
26
|
+
'1 AC.'
|
27
|
+
]
|
28
|
+
|
29
|
+
unsorted_ids.each do |unsorted_id|
|
30
|
+
record = ::Differential::Parser::Record.new(id: unsorted_id,
|
31
|
+
group_id: group_id,
|
32
|
+
value: 1,
|
33
|
+
data: {})
|
34
|
+
|
35
|
+
group.add(record, ::Differential::Calculator::Side::A)
|
36
|
+
end
|
37
|
+
|
38
|
+
actual_ids = group.sorted_items.map { |i| i.id.value }
|
39
|
+
|
40
|
+
expected_ids = unsorted_ids.sort
|
41
|
+
|
42
|
+
expect(actual_ids).to eq(expected_ids)
|
19
43
|
end
|
20
44
|
end
|
@@ -134,4 +134,30 @@ describe ::Differential::Calculator::Report do
|
|
134
134
|
expect(group2_item2.delta).to eq(group_2_minus2.value)
|
135
135
|
end
|
136
136
|
end
|
137
|
+
|
138
|
+
it '#sorted_groups should be lexicographically sorted' do
|
139
|
+
report = ::Differential::Calculator::Report.new
|
140
|
+
|
141
|
+
unsorted_ids = [
|
142
|
+
'zYx',
|
143
|
+
'123',
|
144
|
+
'aBC',
|
145
|
+
'1 AC.'
|
146
|
+
]
|
147
|
+
|
148
|
+
unsorted_ids.each do |unsorted_id|
|
149
|
+
record = ::Differential::Parser::Record.new(id: '1',
|
150
|
+
group_id: unsorted_id,
|
151
|
+
value: 1,
|
152
|
+
data: {})
|
153
|
+
|
154
|
+
report.add(record, ::Differential::Calculator::Side::A)
|
155
|
+
end
|
156
|
+
|
157
|
+
actual_ids = report.sorted_groups.map { |i| i.id.value }
|
158
|
+
|
159
|
+
expected_ids = unsorted_ids.sort
|
160
|
+
|
161
|
+
expect(actual_ids).to eq(expected_ids)
|
162
|
+
end
|
137
163
|
end
|
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.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard-rspec
|