cvg 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +6 -0
- data/README.md +6 -2
- data/bin/cvg +21 -20
- data/features/basic.feature +21 -3
- data/lib/cvg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGYyMzdiYzVmMjM0MDI5Y2MzMGNjN2QwNjdkNWM0ZDdlOGZhZDM1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2IyN2E4ZDM5MDZiYzQwOTBiMmViNWJiMmM2YWIyZDMxMWNkNDQ4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGEyMjk2ODM0MmNjNjQ1NjllM2RiZWFhN2FlZDdlZTA5N2RmNzNlMjIyNWI1
|
10
|
+
ZWJhYjIxYzk5NGVjNWVmZGQ3NjlmNTc1Y2NlYmRlY2QxY2NmYWU5MzMzZTRm
|
11
|
+
Y2Q3MjJmYWZiYzVjZWU5MTgyMWMyNmE4MGYzMDY5Zjk0Yjg4ZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTliZjBlY2ZlM2JlZThhM2Y5YWFmYzk0NWEyNTc0MmNiOGYxMmYzYjk4OWIy
|
14
|
+
ODZmMmM4OGNhMTQxZWIzMzdlYzEyODJkMTFmMTU3MGFmYmE3Yzc1N2JlMTFk
|
15
|
+
ZTRjYWUxZjI5MzQ0ZmZmMWIxMjk2NjVkOGNiNTI0MDdmMWNlNDg=
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,9 @@ cvg --present colA input.csv
|
|
6
6
|
|
7
7
|
cvg --missing colA input.csv
|
8
8
|
|
9
|
-
cvg --
|
9
|
+
cvg --match 'colA:/\d+/' input.csv
|
10
|
+
|
11
|
+
cvg --match 'colA:one,two,three,/\d+/' input.csv
|
10
12
|
|
11
13
|
cvg --detect-missing input.csv
|
12
14
|
|
@@ -42,6 +44,8 @@ DONE treat as missing %w{ N/A n/a NULL null - #DIV/0 #REF! #NAME? NIL nil NA na
|
|
42
44
|
|
43
45
|
writes report (why rejected row, checks missing and extra columns across input files)
|
44
46
|
|
45
|
-
dup checks on certain cols
|
47
|
+
DONE dup checks on certain cols
|
46
48
|
|
47
49
|
optionall uses minimal set of headers shared by all
|
50
|
+
|
51
|
+
make it possible to match a field that starts with a /
|
data/bin/cvg
CHANGED
@@ -68,32 +68,33 @@ class Cvg
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
class
|
71
|
+
class Match < Test
|
72
72
|
class << self
|
73
73
|
def accept(k, arg)
|
74
|
-
new(k, arg) if k == '
|
75
|
-
end
|
76
|
-
end
|
77
|
-
def pass?(row)
|
78
|
-
!!(row.fetch(col).to_s =~ regex)
|
79
|
-
end
|
80
|
-
def regex
|
81
|
-
@regex ||= arg.split(':', 2)[1].to_regexp(detect: true) or raise("#{arg.inspect} doesn't have a valid regex")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class Value < Test
|
86
|
-
class << self
|
87
|
-
def accept(k, arg)
|
88
|
-
new(k, arg) if k == 'value'
|
74
|
+
new(k, arg) if k == 'match'
|
89
75
|
end
|
90
76
|
end
|
77
|
+
REGEX_START_1 = '/'
|
78
|
+
REGEX_START_2 = '%r{'
|
91
79
|
def pass?(row)
|
92
80
|
v = row.fetch(col).to_s
|
93
|
-
|
81
|
+
matchers.any? do |matcher|
|
82
|
+
case matcher
|
83
|
+
when ::Regexp
|
84
|
+
matcher =~ v
|
85
|
+
else
|
86
|
+
matcher == v
|
87
|
+
end
|
88
|
+
end
|
94
89
|
end
|
95
|
-
def
|
96
|
-
@
|
90
|
+
def matchers
|
91
|
+
@matchers ||= CSV.parse_line(arg.split(':', 2)[1]).map do |x|
|
92
|
+
if x.start_with?(REGEX_START_1) or x.start_with?(REGEX_START_2)
|
93
|
+
x.to_regexp or die("invalid regex #{x.inspect}")
|
94
|
+
else
|
95
|
+
x
|
96
|
+
end
|
97
|
+
end
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
@@ -165,7 +166,7 @@ class Cvg
|
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
168
|
-
TESTS = [Present, Missing,
|
169
|
+
TESTS = [Present, Missing, Match, GreaterOrLesser, Dedup]
|
169
170
|
FLAGS = {
|
170
171
|
'detect-missing' => DetectMissing,
|
171
172
|
}
|
data/features/basic.feature
CHANGED
@@ -45,7 +45,7 @@ Feature: Basic functionality
|
|
45
45
|
yes,a1
|
46
46
|
yes,1a
|
47
47
|
"""
|
48
|
-
When you pass arguments --
|
48
|
+
When you pass arguments --match 'b:/\d+/'
|
49
49
|
Then you get output
|
50
50
|
"""
|
51
51
|
a,b
|
@@ -65,7 +65,7 @@ Feature: Basic functionality
|
|
65
65
|
no,zz
|
66
66
|
no,ZZ
|
67
67
|
"""
|
68
|
-
When you pass arguments --
|
68
|
+
When you pass arguments --match 'b:z'
|
69
69
|
Then you get output
|
70
70
|
"""
|
71
71
|
a,b
|
@@ -83,7 +83,7 @@ Feature: Basic functionality
|
|
83
83
|
no,ZZ
|
84
84
|
yes,Z
|
85
85
|
"""
|
86
|
-
When you pass arguments --
|
86
|
+
When you pass arguments --match 'b:z,Z'
|
87
87
|
Then you get output
|
88
88
|
"""
|
89
89
|
a,b
|
@@ -91,6 +91,24 @@ Feature: Basic functionality
|
|
91
91
|
yes,Z
|
92
92
|
"""
|
93
93
|
|
94
|
+
Scenario: Mixed regex and literals
|
95
|
+
Given an input csv
|
96
|
+
"""
|
97
|
+
a,b
|
98
|
+
yes,z
|
99
|
+
yes,a
|
100
|
+
yes,Z
|
101
|
+
no,
|
102
|
+
"""
|
103
|
+
When you pass arguments --match 'b:a,/Z/i'
|
104
|
+
Then you get output
|
105
|
+
"""
|
106
|
+
a,b
|
107
|
+
yes,z
|
108
|
+
yes,a
|
109
|
+
yes,Z
|
110
|
+
"""
|
111
|
+
|
94
112
|
Scenario: Less than
|
95
113
|
Given an input csv
|
96
114
|
"""
|
data/lib/cvg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cvg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|