cvg 0.2.1 → 0.2.2

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
2
  SHA1:
3
- metadata.gz: b0ce58bb750f80bab8a43e12f89ce6f793ddbb1a
4
- data.tar.gz: 24674fffa48caede3c99e5d4adbb99ab4939b906
3
+ metadata.gz: 3dab4f622fe1a6af8a0d57aa7a39b99afdd9e930
4
+ data.tar.gz: ce77fde86b571116c29c236d24bfde7fa4c14173
5
5
  SHA512:
6
- metadata.gz: 91b318d4c10b2bbed129084091661435e054a136ede8d19020a7a31cc81cfdd4285647df6531e16956bb8f58301a974d5df1f46600f1724de41c9ac9f916376f
7
- data.tar.gz: 8ff44eb888b5df7471b85214dfa7edaae653e9a92d2ae18287dc60e2e426003c120fde1438b80c2d20eb5e5a2a0f2a5f2605f1a3e8cfec635300a380dcf443c3
6
+ metadata.gz: ec53cfd12d29878eb78cb0f570a375a07d0e4acc1881a381451bfb134389a20a4c4797e09f581a82c422250ffa87d67eb22238f0e2bc044c753c4e221a7e8a53
7
+ data.tar.gz: f28f7c448e7137bb73d19306a6214dcc95b05f71f62f15d93ddc3e0ce984fcb5cce0f5eaada2f9f9a67580b1266131cdd3365cf59329740259651ba6d5c2ac12
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ 0.2.2 / 2014-07-15
2
+
3
+ * Bug fixes
4
+
5
+ * Fix nullification of whitespace-only strings
6
+ * Fix how we require activesupport
7
+
8
+ * Enhancements
9
+
10
+ * --limit outputs only the specified number of rows (per file)
11
+
1
12
  0.2.1 / 2014-03-07
2
13
 
3
14
  * Bug fixes
data/README.md CHANGED
@@ -14,6 +14,8 @@ cvg --detect-missing input.csv
14
14
 
15
15
  cvg --lt 'colA:5' input.colA
16
16
 
17
+ cvg --limit 5 input.csv
18
+
17
19
  Multiple tests:
18
20
 
19
21
  cvg --present colA --missing colB input.csv
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
- row = row.to_hash
276
- per_row_pre_test_flags.each { |flag| flag.apply! row }
277
- yield row
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
@@ -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
  """
@@ -1,3 +1,3 @@
1
1
  class Cvg
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-03-07 00:00:00.000000000 Z
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: