data_list_converter 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/changelog.md +1 -0
- data/lib/data_list_converter/types/csv_file.rb +16 -0
- data/lib/data_list_converter/version.rb +1 -1
- data/test/base_test.rb +1 -1
- data/test/testdata.rb +2 -3
- data/test/types_test.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eae8b0ae00e74f0315d7d62d76ca89955f75f590
|
4
|
+
data.tar.gz: b5b44e967bc8af50a21631edda6a3d7d7f1bfe83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae6682e0c402fac52343277a399588a6553eb36f9044248462b07e901eb584fb0e54699d8fbc3488c57b7aa0e002d3d9ec041617d18e5982212eab5b1b4d666
|
7
|
+
data.tar.gz: 04aec6fb7b56707fcb41912883c8a8a6c524b4eda92f911b798b9ab86be6e36209e03ca78843bed31cecb8b866a90a4cb9d6285f290082d93d09e4771855e9ca
|
data/README.md
CHANGED
data/changelog.md
CHANGED
@@ -19,4 +19,20 @@ class DataListConverter
|
|
19
19
|
end
|
20
20
|
options[:filename]
|
21
21
|
end
|
22
|
+
|
23
|
+
self.register_converter(:table_iterator, :csv_raw) do |proc, options|
|
24
|
+
CSV.generate(force_quotes: true) do |csv|
|
25
|
+
proc.call do |row|
|
26
|
+
csv << row
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
self.register_converter(:csv_raw, :table_iterator) do |input, options|
|
32
|
+
lambda { |&block|
|
33
|
+
CSV.parse(input).each do |row|
|
34
|
+
block.call(row)
|
35
|
+
end
|
36
|
+
}
|
37
|
+
end
|
22
38
|
end
|
data/test/base_test.rb
CHANGED
@@ -11,7 +11,7 @@ describe DataListConverter do
|
|
11
11
|
it 'has parameters' do
|
12
12
|
begin
|
13
13
|
@c.convert(:item_data, :csv_file, ITEM_DATA, csv_file: {filename: "test.csv"})
|
14
|
-
File.read("test.csv").
|
14
|
+
File.read("test.csv").must_equal CSV_DATA
|
15
15
|
@c.convert(:csv_file, :item_data, {filename: "test.csv"}).must_equal(ITEM_DATA)
|
16
16
|
ensure
|
17
17
|
FileUtils.rm_f("test.csv")
|
data/test/testdata.rb
CHANGED
data/test/types_test.rb
CHANGED
@@ -16,7 +16,7 @@ describe DataListConverter do
|
|
16
16
|
:multi_sheet_table_data,
|
17
17
|
:multi_sheet_item_iterator,
|
18
18
|
:multi_sheet_table_iterator,
|
19
|
-
:csv_file, :xls_file, :xlsx_file,
|
19
|
+
:csv_file, :csv_raw, :xls_file, :xlsx_file,
|
20
20
|
:records,
|
21
21
|
].sort
|
22
22
|
)
|
@@ -35,6 +35,8 @@ describe DataListConverter do
|
|
35
35
|
begin
|
36
36
|
@c.convert(:item_data, :csv_file, ITEM_DATA, csv_file: {filename: "test.csv"})
|
37
37
|
@c.convert(:csv_file, :item_data, {filename: "test.csv"}).must_equal ITEM_DATA
|
38
|
+
@c.convert(:item_data, :csv_raw, ITEM_DATA).must_equal CSV_DATA
|
39
|
+
@c.convert(:csv_raw, :item_data, CSV_DATA).must_equal ITEM_DATA
|
38
40
|
ensure
|
39
41
|
FileUtils.rm_f("test.csv")
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_list_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linjunhalida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|