csv_in_zip 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/csv_in_zip/version.rb +1 -1
- data/lib/csv_in_zip.rb +1 -0
- data/spec/lib/csv_in_zip_spec.rb +12 -0
- data/spec/support/data/README +3 -0
- data/spec/support/data/multi_files.zip +0 -0
- metadata +5 -1
data/lib/csv_in_zip/version.rb
CHANGED
data/lib/csv_in_zip.rb
CHANGED
@@ -23,6 +23,7 @@ module CsvInZip
|
|
23
23
|
zip_file = Zip::ZipFile.open(target_zip)
|
24
24
|
Zip::ZipFile.foreach(target_zip) do |entry|
|
25
25
|
next if entry.to_s =~ /^__MACOSX/
|
26
|
+
next unless File.extname(entry.to_s) == ".csv"
|
26
27
|
|
27
28
|
csv_lines = zip_file.read(entry).gsub("\r\n", "\n").split("\n")
|
28
29
|
csv_lines = csv_lines[1..-1] if options[:remove_header_line]
|
data/spec/lib/csv_in_zip_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe CsvInZip do
|
|
9
9
|
@multi_data_zip = File.join(base, "multi_data.csv.zip")
|
10
10
|
@utf8_zip = File.join(base, "utf8.csv.zip")
|
11
11
|
@sjis_zip = File.join(base, "sjis.csv.zip")
|
12
|
+
@multi_files_zip = File.join(base, "multi_files.zip")
|
12
13
|
end
|
13
14
|
|
14
15
|
it "should add headers" do
|
@@ -44,4 +45,15 @@ describe CsvInZip do
|
|
44
45
|
row["日本語ヘッダー"].should == "データ2"
|
45
46
|
end
|
46
47
|
end
|
48
|
+
|
49
|
+
describe "multi files" do
|
50
|
+
it "should open only csv files" do
|
51
|
+
count = 0
|
52
|
+
CsvInZip.extract(@multi_files_zip) do |row|
|
53
|
+
count += 1
|
54
|
+
end
|
55
|
+
count.should == utf8_csv_has_only_one_row = 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_in_zip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -125,8 +125,10 @@ files:
|
|
125
125
|
- lib/csv_in_zip/version.rb
|
126
126
|
- spec/lib/csv_in_zip_spec.rb
|
127
127
|
- spec/spec_helper.rb
|
128
|
+
- spec/support/data/README
|
128
129
|
- spec/support/data/multi_data.csv
|
129
130
|
- spec/support/data/multi_data.csv.zip
|
131
|
+
- spec/support/data/multi_files.zip
|
130
132
|
- spec/support/data/no_headers.csv
|
131
133
|
- spec/support/data/no_headers.csv.zip
|
132
134
|
- spec/support/data/sjis.csv
|
@@ -160,8 +162,10 @@ summary: extract csv in zip
|
|
160
162
|
test_files:
|
161
163
|
- spec/lib/csv_in_zip_spec.rb
|
162
164
|
- spec/spec_helper.rb
|
165
|
+
- spec/support/data/README
|
163
166
|
- spec/support/data/multi_data.csv
|
164
167
|
- spec/support/data/multi_data.csv.zip
|
168
|
+
- spec/support/data/multi_files.zip
|
165
169
|
- spec/support/data/no_headers.csv
|
166
170
|
- spec/support/data/no_headers.csv.zip
|
167
171
|
- spec/support/data/sjis.csv
|