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 +4 -4
- data/csv-utils.gemspec +1 -1
- data/lib/csv_utils/csv_report.rb +4 -3
- data/lib/csv_utils/csv_row.rb +13 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b1634cd26b21129c05cf1c5655e46ff3b81307135ce8dd686022cd8a4ff5adc
|
4
|
+
data.tar.gz: 53312f6841e32ddcae0e97cd9aab4513a47580c35a3ec39964f8933fdbbcff10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5733c0ff8b730e957c46fc73b1080690dd79fb481b30f9591f4256507abc3ea46139d9758605c4c4e143e23781468b9adbd623812ceb105bb610a61943ffbc57
|
7
|
+
data.tar.gz: 4ce9256c44ed50fc289fbe2b0ce970b2798310d50b4f69dffe9fa57098b0acab0539049bd5c945b43768ea7cb3d97b2421e54bf4c069df7751bd3704b68db9ec
|
data/csv-utils.gemspec
CHANGED
data/lib/csv_utils/csv_report.rb
CHANGED
@@ -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
|
data/lib/csv_utils/csv_row.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|