cevennes 0.13.0 → 1.0.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +43 -6
- data/lib/cevennes.rb +2 -2
- 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: ea7e96b87743825f65f95ecda2fd3d9bae8d74a5
|
4
|
+
data.tar.gz: 2ebe50c32f0889d5dcc92ecdb029feb9e390cef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52dc9eed861868b48bb28601e6c99f74b2770d95cc5263c33bc978978d9336be2418e336eed560d777016ec6a698c4887624e5c6513ad98b2843749de614a08
|
7
|
+
data.tar.gz: ef83bf46e2c16a34d7dcf34da8d4edcc335eb9568356bfac0d20fb624fc8115a74692cf62bff52d7443bb51b82850a8f095b1c606e4f5701f5daafddc41b906e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,16 +6,53 @@
|
|
6
6
|
|
7
7
|
Diffs CSVs by lines, focusing on a single ID
|
8
8
|
|
9
|
+
|
9
10
|
## usage
|
10
11
|
|
11
|
-
|
12
|
+
Given two CSV strings and an identifier name, cevennes may compute a diff:
|
13
|
+
```ruby
|
14
|
+
require 'cevennes'
|
15
|
+
|
16
|
+
cvs0 = %{
|
17
|
+
id,name,age
|
18
|
+
0,John,33
|
19
|
+
1,Jean-Baptiste,43
|
20
|
+
3,Luke,21
|
21
|
+
}.strip + "\n"
|
22
|
+
cvs1 = %{
|
23
|
+
id,name,age
|
24
|
+
0,John,33
|
25
|
+
1,Jean-Baptiste,44
|
26
|
+
4,Matthew,20
|
27
|
+
}.strip + "\n"
|
28
|
+
|
29
|
+
d = Cevennes.diff('id', cvs0, cvs1)
|
12
30
|
```
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
31
|
+
|
32
|
+
`d` will yield:
|
33
|
+
```ruby
|
34
|
+
[
|
35
|
+
[ 'keys', 1, [ 'id', 'name', 'age' ],
|
36
|
+
1, [ 'id', 'name', 'age' ] ],
|
37
|
+
[ 'stats',
|
38
|
+
{ '=' => 1, '!' => 1, '-' => 1, '+' => 1,
|
39
|
+
'l0' => 3, 'l1' => 3 } ],
|
40
|
+
[ '=', 2, [ '0', 'John', '33'],
|
41
|
+
2, nil ],
|
42
|
+
[ '!', 3, [ '1', 'Jean-Baptiste', '43' ],
|
43
|
+
3, [ '1', 'Jean-Baptiste', '44' ] ],
|
44
|
+
[ '-', 4, [ '3', 'Luke', '21'],
|
45
|
+
-1, nil ],
|
46
|
+
[ '+', -1, nil,
|
47
|
+
4, [ '4', 'Matthew', '20' ] ]
|
48
|
+
]
|
18
49
|
```
|
50
|
+
It's a list where the first entry is a recap of the keys used in the old and the new CSV strings (the integer is the line number (starting at 1) where the keys where found.
|
51
|
+
|
52
|
+
The second entry is a summary of the changes, altered `!` line count, removed `-` line count, added `+` line count, old length `l0`, new length `l1`, and unchanged `=` line count.
|
53
|
+
|
54
|
+
The remaining entries are the (non-)changes themselves, from line 1 to the end.
|
55
|
+
|
19
56
|
|
20
57
|
## LICENSE
|
21
58
|
|
data/lib/cevennes.rb
CHANGED
@@ -4,7 +4,7 @@ require 'csv'
|
|
4
4
|
|
5
5
|
module Cevennes
|
6
6
|
|
7
|
-
VERSION = '0.
|
7
|
+
VERSION = '1.0.0'
|
8
8
|
|
9
9
|
class << self
|
10
10
|
|
@@ -39,7 +39,7 @@ module Cevennes
|
|
39
39
|
s['l0'] = h0.length
|
40
40
|
s['l1'] = h1.length
|
41
41
|
|
42
|
-
[ [ 'keys', ks0, ks1 ], [ 'stats', s ] ] + d
|
42
|
+
[ [ 'keys', *ks0, *ks1 ], [ 'stats', s ] ] + d
|
43
43
|
end
|
44
44
|
|
45
45
|
protected
|