nebulous 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bd0a6f4d3f113c1f2d6538c030f2c88b750530a
4
- data.tar.gz: a740e101add3bc77b8b0640b6bbffb034ca9df4f
3
+ metadata.gz: 29c4fbaeb91217e7196b9966ed06a349400a3d57
4
+ data.tar.gz: d1105b5b854fc279c757426c894bae1fc914b329
5
5
  SHA512:
6
- metadata.gz: 07905a4a8ab161501018832be757ee6ec8d8b5d737ac4be332ed99bce006aecd8817a6683fc6caa44bf43240295c4d64d4786e596bb388db535e339b741a0753
7
- data.tar.gz: b051ab11fb60c9b0130263134c07babb2127cc241a928dfe90c4b9c17fb999d9e33b2afe86e44094d0ec5c5ffa1e6af18e3289aaace4e19fd4063631f2a4ed9f
6
+ metadata.gz: 84645b05c28bbab1f3e5626377b0502f1aaa495d944197a44e8e767ed0c600726354ea0931f39ab48a016bf3577d497d89305c8aa06e813b530614186958c6f3
7
+ data.tar.gz: 455a43562135c5608bf8d7ef2de39a57df35cc39de43d017fc8efc7415cc0b0d2542a85dff4d3603e0ddc27409de661b733abea31521a30c008cafed73344131
@@ -62,7 +62,15 @@ module Nebulous
62
62
  end
63
63
 
64
64
  def readline
65
- File.open(path, &:readline).encode(encoding, invalid: :replace)
65
+ ln = ''
66
+
67
+ File.open(path, 'r') do |io|
68
+ while ln.chomp.empty?
69
+ ln += io.readline
70
+ end
71
+ end
72
+
73
+ ln.encode(encoding, invalid: :replace)
66
74
  end
67
75
  end
68
76
  end
@@ -7,11 +7,12 @@ module Nebulous
7
7
  end
8
8
 
9
9
  def raw_headers
10
- Row.parse(readline, options)
10
+ ln = read_complete_line
11
+ Row.parse(ln, options)
11
12
  end
12
13
 
13
14
  def read_headers
14
- @headers ||= Row.headers(readline, options) if options[:headers]
15
+ @headers ||= Row.headers(read_complete_line, options)
15
16
  end
16
17
 
17
18
  def chunk
@@ -7,7 +7,7 @@ module Nebulous
7
7
 
8
8
  def read_complete_line
9
9
  ln = readline
10
- while ln.count(options.quote_char) % 2 == 1
10
+ while ln.empty? || ln.count(options.quote_char) % 2 == 1
11
11
  ln += readline
12
12
  end
13
13
  ln
@@ -35,7 +35,7 @@ module Nebulous
35
35
 
36
36
  def process(&block)
37
37
  @index = 0
38
- read_headers
38
+ read_headers if options[:headers]
39
39
  iterate(&block)
40
40
  ensure
41
41
  reset
@@ -1,3 +1,3 @@
1
1
  module Nebulous
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -32,6 +32,18 @@ describe Nebulous::Parser do
32
32
  ["First name", "Last name", "From", "Access", "Qty"]
33
33
  )
34
34
  end
35
+
36
+ context 'around empty lines' do
37
+ let(:path) do
38
+ './spec/support/assets/crlf-comma-delimited-emptyline.csv'
39
+ end
40
+
41
+ it 'returns expected headers' do
42
+ expect(parser.headers).to eq(
43
+ ["First name", "Last name", "From", "Access", "Qty"]
44
+ )
45
+ end
46
+ end
35
47
  end
36
48
  end
37
49
 
@@ -0,0 +1,22 @@
1
+
2
+ First name,Last name,From,Access,Qty
3
+ どーもありがとう,ミスター·ロボット,VIP,VIP,2
4
+ Meghan,Koch,VIP,VIP,5
5
+ Genoveva,Dare,Zach Graves,vip,5
6
+ Eulalia,Stiedemann,VIP,GA,2
7
+ Kaylie,Lakin,Vans,VIP,1
8
+ Grace,Nienow,Vans,VIP,5
9
+ Alberto,Upton,Vans,VIP,5
10
+ Saige,Larson,Fan Club,VIP,4
11
+ Virginie,Lindgren,Zach Graves,VIP,5 passes
12
+ Ahmad,Bins,Vans,VIP,4
13
+ Sydni,Turcotte,Vans,VIP,5
14
+ Aylin,McLaughlin,Fan Club,GA,1
15
+ Jimmy,Hoppe,Zach Graves,GA,5
16
+ Isabell,Hills,Vans,VIP,4
17
+ Chad,Anderson,Zach Graves,GA,4
18
+ Arnold,Yundt,VIP,VIP,5
19
+ Cary,Halvorson,Vans,GA,1
20
+ Jedidiah,Feest,Zach Graves,GA,0
21
+ Carol,Reilly,Zach Graves,VIP,2
22
+ Heidi,Wunsch,Zach Graves,VIP,2 passes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nebulous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Graves
@@ -128,6 +128,7 @@ files:
128
128
  - spec/support/assets/clrf-batches.csv
129
129
  - spec/support/assets/cr-comma-delimited.csv
130
130
  - spec/support/assets/cr-lf-comma-delimited.csv
131
+ - spec/support/assets/crlf-comma-delimited-emptyline.csv
131
132
  - spec/support/assets/crlf-comma-delimited.csv
132
133
  - spec/support/assets/crlf-dolla-delimited.csv
133
134
  - spec/support/assets/crlf-pipe-delimited.csv
@@ -167,6 +168,7 @@ test_files:
167
168
  - spec/support/assets/clrf-batches.csv
168
169
  - spec/support/assets/cr-comma-delimited.csv
169
170
  - spec/support/assets/cr-lf-comma-delimited.csv
171
+ - spec/support/assets/crlf-comma-delimited-emptyline.csv
170
172
  - spec/support/assets/crlf-comma-delimited.csv
171
173
  - spec/support/assets/crlf-dolla-delimited.csv
172
174
  - spec/support/assets/crlf-pipe-delimited.csv