cvg 0.2.1 → 0.2.2
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 +11 -0
- data/README.md +2 -0
- data/bin/cvg +18 -4
- data/features/basic.feature +17 -1
- data/lib/cvg/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dab4f622fe1a6af8a0d57aa7a39b99afdd9e930
|
4
|
+
data.tar.gz: ce77fde86b571116c29c236d24bfde7fa4c14173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec53cfd12d29878eb78cb0f570a375a07d0e4acc1881a381451bfb134389a20a4c4797e09f581a82c422250ffa87d67eb22238f0e2bc044c753c4e221a7e8a53
|
7
|
+
data.tar.gz: f28f7c448e7137bb73d19306a6214dcc95b05f71f62f15d93ddc3e0ce984fcb5cce0f5eaada2f9f9a67580b1266131cdd3365cf59329740259651ba6d5c2ac12
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
data/bin/cvg
CHANGED
@@ -10,6 +10,7 @@ end
|
|
10
10
|
require 'set'
|
11
11
|
require 'csv'
|
12
12
|
require 'to_regexp'
|
13
|
+
require 'active_support'
|
13
14
|
require 'active_support/core_ext'
|
14
15
|
require 'hash_digest'
|
15
16
|
|
@@ -198,7 +199,7 @@ class Cvg
|
|
198
199
|
MISSING = %w{ N/A n/a NULL null - #DIV/0 #REF! #NAME? NIL nil NA na #VALUE! #NULL! NaN #N/A #NUM! ? }
|
199
200
|
def apply!(row)
|
200
201
|
row.each do |k, v|
|
201
|
-
if v.is_a?(::String) and MISSING.include?(v)
|
202
|
+
if v.is_a?(::String) and (MISSING.include?(v) or v.strip.empty?)
|
202
203
|
row[k] = nil
|
203
204
|
end
|
204
205
|
end
|
@@ -270,11 +271,15 @@ class Cvg
|
|
270
271
|
private
|
271
272
|
|
272
273
|
def each_input_row
|
274
|
+
count = 0
|
273
275
|
input_paths.each do |path|
|
274
276
|
CSV.foreach(path, headers: :first_row) do |row|
|
275
|
-
|
276
|
-
|
277
|
-
|
277
|
+
if count < limit
|
278
|
+
count += 1
|
279
|
+
row = row.to_hash
|
280
|
+
per_row_pre_test_flags.each { |flag| flag.apply! row }
|
281
|
+
yield row
|
282
|
+
end
|
278
283
|
end
|
279
284
|
end
|
280
285
|
end
|
@@ -298,6 +303,15 @@ class Cvg
|
|
298
303
|
@write_rows_query = !modes.include?(:dont_write_rows)
|
299
304
|
end
|
300
305
|
|
306
|
+
def limit
|
307
|
+
return @limit if defined?(@limit)
|
308
|
+
if limit = options.detect { |k, v| k == 'limit' }
|
309
|
+
@limit = limit[1].to_f.round
|
310
|
+
else
|
311
|
+
@limit = Float::INFINITY
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
301
315
|
def modes
|
302
316
|
@modes ||= flags.map(&:mode).flatten.compact
|
303
317
|
end
|
data/features/basic.feature
CHANGED
@@ -204,6 +204,7 @@ Feature: Basic functionality
|
|
204
204
|
yes,x
|
205
205
|
yes,
|
206
206
|
yes," "
|
207
|
+
yes," "
|
207
208
|
yes,N/A
|
208
209
|
yes,n/a
|
209
210
|
yes,NULL
|
@@ -230,7 +231,8 @@ Feature: Basic functionality
|
|
230
231
|
a,b
|
231
232
|
yes,x
|
232
233
|
yes,
|
233
|
-
yes,
|
234
|
+
yes,
|
235
|
+
yes,
|
234
236
|
yes,
|
235
237
|
yes,
|
236
238
|
yes,
|
@@ -301,6 +303,20 @@ Feature: Basic functionality
|
|
301
303
|
bbb,aaa
|
302
304
|
"""
|
303
305
|
|
306
|
+
Scenario: Output a limited number of rows
|
307
|
+
Given an input csv
|
308
|
+
"""
|
309
|
+
a,b,c
|
310
|
+
aa,bb,cc
|
311
|
+
aaa,bbb,ccc
|
312
|
+
"""
|
313
|
+
When you pass arguments --limit 1
|
314
|
+
Then you get output
|
315
|
+
"""
|
316
|
+
a,b,c
|
317
|
+
aa,bb,cc
|
318
|
+
"""
|
319
|
+
|
304
320
|
Scenario: Any of fields is present
|
305
321
|
Given an input csv
|
306
322
|
"""
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -197,3 +197,4 @@ test_files:
|
|
197
197
|
- features/support/env.rb
|
198
198
|
- spec/cvg_spec.rb
|
199
199
|
- spec/spec_helper.rb
|
200
|
+
has_rdoc:
|