cvg 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzgyMDY5ZWZiODdhZmI3NTE5MGUwZDdjOTQzYjBmYzg0MWZhNzA1OA==
4
+ N2U0OTc4YjRkMDc1NzBlZGM1OGM3MTU1OTVkYmMyMGEwN2I1ZWM4OQ==
5
5
  data.tar.gz: !binary |-
6
- NWNlYWNiYzRjYWZjZjQwODc2Y2FjN2ZhZWQzMGQ0OTQ3NGZhYTdiMw==
6
+ OGM3NmFmZmM0YmExY2MyZjI3MmNmMTBkNjljYzU3MWI5ZTc5NDdkOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjE2ZDRjYWU3MGY4MDVjYzBjMTQ4Y2RhZmEyOWVmNjkwNTZhYzgzZjhkYzQx
10
- ZTJmYmE4MzE4MzEyNmRhZDIyZTcxNDQzODU0NzIxNGM2ZTBhOWEyM2EyNjAw
11
- Yjc3OTVhN2U4NzllYWQ5MTk5NmRkZmFiZmQwMDcxZjM3MGMwYTM=
9
+ YzZjYzUyMmM3ZWEyNDRiYThkOTk3M2YyOTFiNGI5OTJlOGQ0YWRhNjdhYzBk
10
+ NWIxNThhZmJiN2YzYTE0OTgzNjhiODc3MTk0NmJkZDhmOWU4ZTBmM2MzYzU2
11
+ ZDJhZmEzYmVmZDZhZDY4MTAyNGE3MjFhZWUxNGIzYjQxOWNiMGI=
12
12
  data.tar.gz: !binary |-
13
- OTUxZTA1ODMwM2E0NjFlMjVkYjVlNjljNmUyYzk5ZjUwOWZkODZlYzA2NWVi
14
- MTE2NDkzNjExNjFiODdlZGMzYmJlYjRlODA3MmMxMmI3ZmIzMDlkYjJiYzAx
15
- MWU0NjI5ZDg1OWIxM2EwNjg5ZTMyNGQ3NGY3YWE5M2IyMzU5MDc=
13
+ Zjk0NTRmNTI5YTA1MTFlMGZkZTY3OTVlY2FjYjU3OWQzZTQzNGM3Mjg3YWMy
14
+ NmVkNGQzMjM2OTA2ZDc3MWVmODBkYTBiZGQyZTU5MTZiMjg0MTIzNjhmNWE2
15
+ ZDJjYjM0ZmU3YWVkZGUyOTAzMWQ2N2JlNjNlMTYxNWNiY2JlOTg=
@@ -0,0 +1,9 @@
1
+ 0.0.2 / 2013-11-05
2
+
3
+ * Enhancements
4
+
5
+ * --output-fields b,a,c
6
+
7
+ 0.0.1 / 2013-11-05
8
+
9
+ initial
data/bin/cvg CHANGED
@@ -178,11 +178,11 @@ class Cvg
178
178
  end
179
179
 
180
180
  def perform
181
- output_headers
181
+ write_headers
182
182
 
183
183
  each_input_row do |row|
184
184
  if tests.all? { |t| t.pass?(row) }
185
- output_row row
185
+ write_row row
186
186
  end
187
187
  end
188
188
 
@@ -223,12 +223,12 @@ class Cvg
223
223
  end
224
224
  end
225
225
 
226
- def output_row(row)
227
- output_f.puts row.values_at(*headers).to_csv
226
+ def write_row(row)
227
+ output_f.puts row.values_at(*fields).to_csv
228
228
  end
229
229
 
230
- def output_headers
231
- output_f.puts headers.to_csv
230
+ def write_headers
231
+ output_f.puts fields.to_csv
232
232
  end
233
233
 
234
234
  def output_f
@@ -239,10 +239,16 @@ class Cvg
239
239
  output_f.close
240
240
  end
241
241
 
242
- def headers
243
- @headers ||= input_paths.map do |path|
244
- CSV.parse_line(File.open(path) { |f| f.gets })
245
- end.flatten.uniq
242
+ def fields
243
+ @fields ||= begin
244
+ if user = options.detect { |k, v| k == 'output-fields' }
245
+ CSV.parse_line user[1]
246
+ else
247
+ input_paths.map do |path|
248
+ CSV.parse_line(File.open(path) { |f| f.gets })
249
+ end.flatten.uniq
250
+ end
251
+ end
246
252
  end
247
253
 
248
254
 
@@ -267,3 +267,18 @@ Feature: Basic functionality
267
267
  yes,y,
268
268
  yes,x,2
269
269
  """
270
+
271
+ Scenario: Output certain fields
272
+ Given an input csv
273
+ """
274
+ a,b,c
275
+ aa,bb,cc
276
+ aaa,bbb,ccc
277
+ """
278
+ When you pass arguments --output-fields b,a
279
+ Then you get output
280
+ """
281
+ b,a
282
+ bb,aa
283
+ bbb,aaa
284
+ """
@@ -1,3 +1,3 @@
1
1
  module Cvg
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cvg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
@@ -120,6 +120,7 @@ files:
120
120
  - .gitignore
121
121
  - .rspec
122
122
  - .travis.yml
123
+ - CHANGELOG
123
124
  - Gemfile
124
125
  - LICENSE.txt
125
126
  - README.md