csv_in_zip 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module CsvInZip
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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]
@@ -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
@@ -0,0 +1,3 @@
1
+ some,readme
2
+ looks,like
3
+ csv,data
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.1
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