csv_lazy 0.0.9 → 0.0.10

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
  SHA1:
3
- metadata.gz: 80463bf9c65eb3d8711f447ee1755b953cb2cf01
4
- data.tar.gz: b2a280caed3b92b8e284bb272fe55cf8648cb251
3
+ metadata.gz: 44d70601a00cdd6e1cd7c102077dadfb7b357f97
4
+ data.tar.gz: e22d5991b47c38d4a3bcb3e07f2283a993bede24
5
5
  SHA512:
6
- metadata.gz: 611b869e291df218be3919c8aa6a46e07d24b9f188f53b1ebdb2f0dfec367e5a7b992fa4454d51b4cdee03b85b6253a967ab848c056b71e59349f69204f6fcf9
7
- data.tar.gz: 5e009d83697815f04a17761da901d5745937c17b6fba584ad48105e05a3009b05145f95b0d481adf00c1a9c59ce8bb974cc6bb9cf200a894de7715de7a276f06
6
+ metadata.gz: 59b05b906c832804795c4c142d8d1b0951b344adf7fb44c3e0660f3c1d0e9766431c86e0c2b1750eb9119b94d0d6c08f4548a2b5e2a470e408a25ae5765f1172
7
+ data.tar.gz: 74f5c69080c4ae0541b6f652a7b5888977ce8196b607ed0798f79c38cda860bda5e57a7a0168aa52af6e76149572bc9a25ad33350975d40995baf82921c06d8d
data/Gemfile CHANGED
@@ -4,13 +4,14 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem "string-strtr", require: false
7
- gem "codeclimate-test-reporter", group: :test, require: nil
8
7
 
9
8
  # Add dependencies to develop your gem here.
10
9
  # Include everything needed to run rake, tests, features, etc.
11
- group :development do
12
- gem "rspec", "~> 3.2.0"
13
- gem "rdoc", "~> 3.12"
10
+ group :development, :test do
14
11
  gem "bundler", ">= 1.0.0"
15
- gem "jeweler", "~> 1.8.8"
12
+ gem "jeweler", "2.3.9"
13
+ end
14
+
15
+ group :development, :test do
16
+ gem "rspec", "3.7.0"
16
17
  end
@@ -1,69 +1,76 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.3.8)
5
- builder (3.2.2)
6
- codeclimate-test-reporter (0.4.7)
7
- simplecov (>= 0.7.1, < 1.0.0)
8
- diff-lcs (1.2.5)
9
- docile (1.1.5)
10
- faraday (0.8.9)
11
- multipart-post (~> 1.2.0)
12
- git (1.2.9.1)
13
- github_api (0.10.1)
14
- addressable
15
- faraday (~> 0.8.1)
16
- hashie (>= 1.2)
17
- multi_json (~> 1.4)
18
- nokogiri (~> 1.5.2)
19
- oauth2
20
- hashie (3.4.1)
21
- highline (1.7.1)
22
- jeweler (1.8.8)
4
+ addressable (2.4.0)
5
+ builder (3.2.3)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.3)
9
+ faraday (0.9.2)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.3.0)
12
+ github_api (0.16.0)
13
+ addressable (~> 2.4.0)
14
+ descendants_tracker (~> 0.0.4)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 3.4)
17
+ mime-types (>= 1.16, < 3.0)
18
+ oauth2 (~> 1.0)
19
+ hashie (3.5.7)
20
+ highline (1.7.10)
21
+ jar-dependencies (0.3.12)
22
+ jeweler (2.3.9)
23
23
  builder
24
- bundler (~> 1.0)
24
+ bundler
25
25
  git (>= 1.2.5)
26
- github_api (= 0.10.1)
26
+ github_api (~> 0.16.0)
27
27
  highline (>= 1.6.15)
28
- nokogiri (= 1.5.10)
28
+ nokogiri (>= 1.5.10)
29
+ psych
29
30
  rake
30
31
  rdoc
31
- json (1.7.7)
32
- json (1.7.7-java)
33
- jwt (1.4.1)
34
- multi_json (1.11.0)
35
- multi_xml (0.5.5)
36
- multipart-post (1.2.0)
37
- nokogiri (1.5.10)
38
- oauth2 (1.0.0)
39
- faraday (>= 0.8, < 0.10)
32
+ semver2
33
+ json (1.8.6)
34
+ json (1.8.6-java)
35
+ jwt (1.5.6)
36
+ mime-types (2.99.3)
37
+ mini_portile2 (2.3.0)
38
+ multi_json (1.13.1)
39
+ multi_xml (0.6.0)
40
+ multipart-post (2.0.0)
41
+ nokogiri (1.8.1)
42
+ mini_portile2 (~> 2.3.0)
43
+ nokogiri (1.8.1-java)
44
+ oauth2 (1.4.0)
45
+ faraday (>= 0.8, < 0.13)
40
46
  jwt (~> 1.0)
41
47
  multi_json (~> 1.3)
42
48
  multi_xml (~> 0.5)
43
- rack (~> 1.2)
44
- rack (1.6.0)
45
- rake (10.4.2)
49
+ rack (>= 1.2, < 3)
50
+ psych (3.0.2)
51
+ psych (3.0.2-java)
52
+ jar-dependencies (>= 0.1.7)
53
+ rack (2.0.3)
54
+ rake (12.3.0)
46
55
  rdoc (3.12.2)
47
56
  json (~> 1.4)
48
- rspec (3.2.0)
49
- rspec-core (~> 3.2.0)
50
- rspec-expectations (~> 3.2.0)
51
- rspec-mocks (~> 3.2.0)
52
- rspec-core (3.2.3)
53
- rspec-support (~> 3.2.0)
54
- rspec-expectations (3.2.1)
57
+ rspec (3.7.0)
58
+ rspec-core (~> 3.7.0)
59
+ rspec-expectations (~> 3.7.0)
60
+ rspec-mocks (~> 3.7.0)
61
+ rspec-core (3.7.1)
62
+ rspec-support (~> 3.7.0)
63
+ rspec-expectations (3.7.0)
55
64
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.2.0)
57
- rspec-mocks (3.2.1)
65
+ rspec-support (~> 3.7.0)
66
+ rspec-mocks (3.7.0)
58
67
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.2.0)
60
- rspec-support (3.2.2)
61
- simplecov (0.9.2)
62
- docile (~> 1.1.0)
63
- multi_json (~> 1.0)
64
- simplecov-html (~> 0.9.0)
65
- simplecov-html (0.9.0)
68
+ rspec-support (~> 3.7.0)
69
+ rspec-support (3.7.0)
70
+ semver2 (3.4.2)
66
71
  string-strtr (0.0.3)
72
+ thread_safe (0.3.6)
73
+ thread_safe (0.3.6-java)
67
74
 
68
75
  PLATFORMS
69
76
  java
@@ -71,8 +78,9 @@ PLATFORMS
71
78
 
72
79
  DEPENDENCIES
73
80
  bundler (>= 1.0.0)
74
- codeclimate-test-reporter
75
- jeweler (~> 1.8.8)
76
- rdoc (~> 3.12)
77
- rspec (~> 3.2.0)
81
+ jeweler (= 2.3.9)
82
+ rspec (= 3.7.0)
78
83
  string-strtr
84
+
85
+ BUNDLED WITH
86
+ 1.16.1
data/README.md CHANGED
@@ -1,7 +1,3 @@
1
- [![Build Status](https://api.shippable.com/projects/540e7b9a3479c5ea8f9ec209/badge?branchName=master)](https://app.shippable.com/projects/540e7b9a3479c5ea8f9ec209/builds/latest)
2
- [![Code Climate](https://codeclimate.com/github/kaspernj/csv_lazy/badges/gpa.svg)](https://codeclimate.com/github/kaspernj/csv_lazy)
3
- [![Test Coverage](https://codeclimate.com/github/kaspernj/csv_lazy/badges/coverage.svg)](https://codeclimate.com/github/kaspernj/csv_lazy)
4
-
5
1
  # csv_lazy
6
2
 
7
3
  ## Install
data/Rakefile CHANGED
@@ -37,13 +37,3 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
37
37
  end
38
38
 
39
39
  task :default => :spec
40
-
41
- require 'rdoc/task'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "csv_lazy #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: csv_lazy 0.0.9 ruby lib
5
+ # stub: csv_lazy 0.0.10 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "csv_lazy"
9
- s.version = "0.0.9"
8
+ s.name = "csv_lazy".freeze
9
+ s.version = "0.0.10"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Kasper Johansen"]
14
- s.date = "2015-04-22"
15
- s.description = "A small CSV lib that skips whitespace-format-bugs and more."
16
- s.email = "k@spernj.org"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Kasper Johansen".freeze]
14
+ s.date = "2018-01-24"
15
+ s.description = "A small CSV lib that skips whitespace-format-bugs and more.".freeze
16
+ s.email = "k@spernj.org".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.md"
@@ -29,39 +29,36 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "csv_lazy.gemspec",
31
31
  "lib/csv_lazy.rb",
32
- "shippable.yml",
32
+ "peak_flow.yml",
33
33
  "spec/csv_lazy_spec.rb",
34
34
  "spec/spec_helper.rb",
35
35
  "spec/test1.csv.gz",
36
36
  "spec/test2.csv"
37
37
  ]
38
- s.homepage = "http://github.com/kaspernj/csv_lazy"
39
- s.licenses = ["MIT"]
40
- s.rubygems_version = "2.4.0"
41
- s.summary = "A small CSV lib that skips whitespace-format-bugs and more."
38
+ s.homepage = "http://github.com/kaspernj/csv_lazy".freeze
39
+ s.licenses = ["MIT".freeze]
40
+ s.rubygems_version = "2.6.11".freeze
41
+ s.summary = "A small CSV lib that skips whitespace-format-bugs and more.".freeze
42
42
 
43
43
  if s.respond_to? :specification_version then
44
44
  s.specification_version = 4
45
45
 
46
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- s.add_runtime_dependency(%q<string-strtr>, [">= 0"])
48
- s.add_development_dependency(%q<rspec>, ["~> 3.2.0"])
49
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
51
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.8"])
47
+ s.add_runtime_dependency(%q<string-strtr>.freeze, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>.freeze, [">= 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
50
+ s.add_development_dependency(%q<rspec>.freeze, ["= 3.7.0"])
52
51
  else
53
- s.add_dependency(%q<string-strtr>, [">= 0"])
54
- s.add_dependency(%q<rspec>, ["~> 3.2.0"])
55
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
57
- s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
52
+ s.add_dependency(%q<string-strtr>.freeze, [">= 0"])
53
+ s.add_dependency(%q<bundler>.freeze, [">= 1.0.0"])
54
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
55
+ s.add_dependency(%q<rspec>.freeze, ["= 3.7.0"])
58
56
  end
59
57
  else
60
- s.add_dependency(%q<string-strtr>, [">= 0"])
61
- s.add_dependency(%q<rspec>, ["~> 3.2.0"])
62
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
64
- s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
58
+ s.add_dependency(%q<string-strtr>.freeze, [">= 0"])
59
+ s.add_dependency(%q<bundler>.freeze, [">= 1.0.0"])
60
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
61
+ s.add_dependency(%q<rspec>.freeze, ["= 3.7.0"])
65
62
  end
66
63
  end
67
64
 
@@ -173,16 +173,9 @@ private
173
173
  col_content = ""
174
174
 
175
175
  loop do
176
- match_read = read_remove_regex(@regex_read_until_quote_char)
177
- if !match_read
178
- if @eof
179
- add_col(@buffer) unless @buffer.empty?
180
- @buffer = ""
181
- break
182
- else
183
- read_buffer
184
- end
185
- else
176
+ if read_until_quote_and_end
177
+ break
178
+ elsif match_read = read_remove_regex(@regex_read_until_quote_char)
186
179
  all = match_read[0]
187
180
  escaped_quote_char = all[-@escaped_quote.length, @escaped_quote.length]
188
181
  double_escaped_quote_char = all[-@escaped_quote_double.length, @escaped_quote_double.length]
@@ -196,6 +189,14 @@ private
196
189
  add_col(unescape(col_content))
197
190
  break
198
191
  end
192
+ else
193
+ if @eof
194
+ add_col(@buffer) unless @buffer.empty?
195
+ @buffer = ""
196
+ break
197
+ else
198
+ read_buffer
199
+ end
199
200
  end
200
201
  end
201
202
 
@@ -214,7 +215,6 @@ private
214
215
  end
215
216
  elsif match = read_remove_regex(@regex_read_until_col_sep)
216
217
  add_col(match[1])
217
- return true
218
218
  elsif match = read_remove_regex(@regex_read_until_row_sep)
219
219
  puts "csv_lazy: Row seperator reached." if @debug
220
220
  add_col(match[1])
@@ -238,6 +238,18 @@ private
238
238
  retry
239
239
  end
240
240
 
241
+ def read_until_quote_and_end
242
+ if match = @buffer.match(/\A(.*?)#{Regexp.escape(@args[:quote_char])}(#{Regexp.escape(@args[:col_sep])}|#{Regexp.escape(@args[:row_sep])})/)
243
+ content = match[1]
244
+ @buffer = @buffer.gsub(/\A#{Regexp.escape(content)}#{Regexp.escape(@args[:quote_char])}/, "")
245
+ content = content.gsub(/\\#{Regexp.escape(@args[:quote_char])}/, @args[:quote_char]) # Remove escapes from escaped quotes
246
+ add_col(content)
247
+ true
248
+ else
249
+ false
250
+ end
251
+ end
252
+
241
253
  #Adds a new column to the current row.
242
254
  def add_col(str)
243
255
  @row << str
@@ -0,0 +1,2 @@
1
+ script:
2
+ - bundle exec rspec
@@ -133,7 +133,7 @@ describe "CsvLazy" do
133
133
 
134
134
  row = csv.read_row
135
135
  expect(row[0]).to eq "Test1"
136
- expect(row[1]).to eq "Test2 \"Wee\""
136
+ expect(row[1]).to eq 'Test2 "Wee"'
137
137
  expect(row.length).to eq 2
138
138
 
139
139
  row = csv.read_row
@@ -145,4 +145,12 @@ describe "CsvLazy" do
145
145
  row = csv.read_row
146
146
  expect(row).to eq false
147
147
  end
148
+
149
+ it "can handle unescaped quotes in quote columns" do
150
+ col = '"EB59009";"Kokuryu"Icchorai"Ginjoshu 1.8L";"0";"412,5";"EB";"E";"Sake - Mirin - Shochu - Umeshu - Beer";"166,58";"Fejl";""'
151
+
152
+ csv = CsvLazy.new(io: StringIO.new(col))
153
+
154
+ expect(csv.to_a).to eq [["EB59009", "Kokuryu\"Icchorai\"Ginjoshu 1.8L", "0", "412,5", "EB", "E", "Sake - Mirin - Shochu - Umeshu - Beer", "166,58", "Fejl", ""]]
155
+ end
148
156
  end
@@ -1,6 +1,3 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
3
-
4
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
3
  require 'rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_lazy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-strtr
@@ -25,61 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 3.2.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 3.2.0
41
- - !ruby/object:Gem::Dependency
42
- name: rdoc
28
+ name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '3.12'
33
+ version: 1.0.0
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '3.12'
40
+ version: 1.0.0
55
41
  - !ruby/object:Gem::Dependency
56
- name: bundler
42
+ name: jeweler
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - '='
60
46
  - !ruby/object:Gem::Version
61
- version: 1.0.0
47
+ version: 2.3.9
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - '='
67
53
  - !ruby/object:Gem::Version
68
- version: 1.0.0
54
+ version: 2.3.9
69
55
  - !ruby/object:Gem::Dependency
70
- name: jeweler
56
+ name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - '='
74
60
  - !ruby/object:Gem::Version
75
- version: 1.8.8
61
+ version: 3.7.0
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - '='
81
67
  - !ruby/object:Gem::Version
82
- version: 1.8.8
68
+ version: 3.7.0
83
69
  description: A small CSV lib that skips whitespace-format-bugs and more.
84
70
  email: k@spernj.org
85
71
  executables: []
@@ -98,7 +84,7 @@ files:
98
84
  - VERSION
99
85
  - csv_lazy.gemspec
100
86
  - lib/csv_lazy.rb
101
- - shippable.yml
87
+ - peak_flow.yml
102
88
  - spec/csv_lazy_spec.rb
103
89
  - spec/spec_helper.rb
104
90
  - spec/test1.csv.gz
@@ -123,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
109
  version: '0'
124
110
  requirements: []
125
111
  rubyforge_project:
126
- rubygems_version: 2.4.0
112
+ rubygems_version: 2.6.11
127
113
  signing_key:
128
114
  specification_version: 4
129
115
  summary: A small CSV lib that skips whitespace-format-bugs and more.
@@ -1,11 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- archive: true
4
- rvm:
5
- - ruby 1.9.3-head
6
- - ruby-2.1.2
7
- - jruby-head
8
- script:
9
- - CODECLIMATE_REPO_TOKEN=eace98ffec782ba73b18d99d6f00710e860cdb620483532d8c386a0fcf3046f8 bundle exec rspec
10
- notifications:
11
- email: false