csv-utils 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: f85c431ad42ed20382fbe91c3696153be9437a8ee755ede313be2d6f488b3770
4
- data.tar.gz: b620cfb208a7a28573160103155564875b05990f965f9206ad89bd7cb6b5fcc7
3
+ metadata.gz: 8b1634cd26b21129c05cf1c5655e46ff3b81307135ce8dd686022cd8a4ff5adc
4
+ data.tar.gz: 53312f6841e32ddcae0e97cd9aab4513a47580c35a3ec39964f8933fdbbcff10
5
5
  SHA512:
6
- metadata.gz: 02fe7a0d34f61c54a3788739cc5455dc685cad7b627a9091f2b6e5b3ed0323bf5d162cff53150e89a431c6ab42e76e014b1350c6b47f4aeed66ef727ffe76554
7
- data.tar.gz: 117d50507b9661c1d70b89df658a97649ea2562604c9dd0764f160e9294586293edbf10e9d968da0107a2f072b0e1814d105c364f91ed2c22cca509fb48f2fd6
6
+ metadata.gz: 5733c0ff8b730e957c46fc73b1080690dd79fb481b30f9591f4256507abc3ea46139d9758605c4c4e143e23781468b9adbd623812ceb105bb610a61943ffbc57
7
+ data.tar.gz: 4ce9256c44ed50fc289fbe2b0ce970b2798310d50b4f69dffe9fa57098b0acab0539049bd5c945b43768ea7cb3d97b2421e54bf4c069df7751bd3704b68db9ec
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'csv-utils'
5
- s.version = '0.2.2'
5
+ s.version = '0.2.3'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'CSV Utils'
8
8
  s.description = 'Tools for debugging malformed CSV files'
@@ -4,7 +4,7 @@ module CSVUtils
4
4
  attr_reader :csv,
5
5
  :must_close
6
6
 
7
- def initialize(csv, csv_options = {}, &block)
7
+ def initialize(csv, headers = nil, csv_options = {}, &block)
8
8
  @csv =
9
9
  if csv.is_a?(String)
10
10
  @must_close = true
@@ -15,10 +15,11 @@ module CSVUtils
15
15
  csv
16
16
  end
17
17
 
18
- generate(&block) if block
18
+ generate(headers, &block) if block
19
19
  end
20
20
 
21
- def generate
21
+ def generate(headers = nil)
22
+ add_headers(headers) if headers
22
23
  yield self
23
24
  @csv.close if @must_close
24
25
  end
@@ -23,10 +23,16 @@ module CSVUtils
23
23
 
24
24
  add_value_to_class_method(:csv_columns, header => options)
25
25
  end
26
- end
27
26
 
28
- def csv_headers
29
- self.class.csv_columns.values.map { |column_options| csv_column_header(column_options) }
27
+ def csv_headers
28
+ csv_columns.values.map { |column_options| csv_column_header(column_options) }
29
+ end
30
+
31
+ private
32
+
33
+ def csv_column_header(column_options)
34
+ column_options[:header]
35
+ end
30
36
  end
31
37
 
32
38
  def csv_row
@@ -34,12 +40,12 @@ module CSVUtils
34
40
  end
35
41
  alias_method :to_a, :csv_row
36
42
 
37
- private
38
-
39
- def csv_column_header(column_options)
40
- column_options[:header]
43
+ def csv_headers
44
+ self.class.csv_headers
41
45
  end
42
46
 
47
+ private
48
+
43
49
  def csv_column_value(column_options)
44
50
  if column_options[:proc]
45
51
  instance_eval(&column_options[:proc])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-06 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inheritance-helper