hippie_csv 0.0.8 → 0.0.9
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 +4 -4
- data/lib/hippie_csv/constants.rb +0 -1
- data/lib/hippie_csv/support.rb +10 -2
- data/lib/hippie_csv/version.rb +1 -1
- data/spec/fixtures/blank_lines_crlf.csv +9 -0
- data/spec/hippie_csv/version_spec.rb +1 -1
- data/spec/hippie_csv_spec.rb +5 -3
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 178191d199c6e5318a8377be2852354d1371537e
|
|
4
|
+
data.tar.gz: cd17b3aa8028743e6b531c67ba36822d2a31a4a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86f07865e61f68ad07c4811d1fdfc7db210f476f9042d7cdac2cea2aa0da6de44c4fdb589d8fa0e35245ed90aec4c7f5df2c5dfeb98dcf7e8d458c47b9398b42
|
|
7
|
+
data.tar.gz: ec95093f3a6e3c060b8706b76538d050040f91a4307888e3ff2a05544fa29f0897375c6c0cdde88f8b4c91dfdf68ba83378a2aeccf7b8cbf79101c11ebc4f363
|
data/lib/hippie_csv/constants.rb
CHANGED
data/lib/hippie_csv/support.rb
CHANGED
|
@@ -21,7 +21,11 @@ module HippieCSV
|
|
|
21
21
|
magical_encode(string)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
DELIMETERS.each do |delimiter|
|
|
26
|
+
string.gsub!(blank_line_regex(delimiter), "")
|
|
27
|
+
end
|
|
28
|
+
|
|
25
29
|
string.encode(string.encoding, universal_newline: true)
|
|
26
30
|
end
|
|
27
31
|
|
|
@@ -29,7 +33,7 @@ module HippieCSV
|
|
|
29
33
|
QUOTE_CHARACTERS.find do |quote_character|
|
|
30
34
|
[string, tolerate_escaping(string, quote_character)].find do |string_to_parse|
|
|
31
35
|
rescuing_malformed do
|
|
32
|
-
return parse_csv(string_to_parse.strip, quote_character)
|
|
36
|
+
return parse_csv(string_to_parse.squeeze("\n").strip, quote_character)
|
|
33
37
|
end
|
|
34
38
|
end
|
|
35
39
|
end
|
|
@@ -63,6 +67,10 @@ module HippieCSV
|
|
|
63
67
|
|
|
64
68
|
private
|
|
65
69
|
|
|
70
|
+
def blank_line_regex(delimiter)
|
|
71
|
+
/^#{delimiter}+(\r\n|\r)$/
|
|
72
|
+
end
|
|
73
|
+
|
|
66
74
|
def detect_encoding(string)
|
|
67
75
|
CharDet.detect(string[0..ENCODING_SAMPLE_CHARACTER_COUNT])["encoding"]
|
|
68
76
|
end
|
data/lib/hippie_csv/version.rb
CHANGED
data/spec/hippie_csv_spec.rb
CHANGED
|
@@ -141,10 +141,12 @@ describe HippieCSV do
|
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "maintains coherent column count when stripping blank lines" do
|
|
144
|
-
|
|
144
|
+
[:blank_lines_crlf, :trailing_leading_blank_lines].each do |fixture_name|
|
|
145
|
+
path = fixture_path(fixture_name)
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
import = subject.read(path)
|
|
148
|
+
expect(import.map(&:length).uniq.size).to eq(1)
|
|
149
|
+
end
|
|
148
150
|
end
|
|
149
151
|
end
|
|
150
152
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hippie_csv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen O'Brien
|
|
@@ -101,6 +101,7 @@ files:
|
|
|
101
101
|
- lib/hippie_csv/version.rb
|
|
102
102
|
- spec/fixtures/accents_semicolon_windows_1252.csv
|
|
103
103
|
- spec/fixtures/bad_quoting.csv
|
|
104
|
+
- spec/fixtures/blank_lines_crlf.csv
|
|
104
105
|
- spec/fixtures/dos_line_ending.csv
|
|
105
106
|
- spec/fixtures/encoding.csv
|
|
106
107
|
- spec/fixtures/escaped_quotes.csv
|
|
@@ -143,6 +144,7 @@ summary: Tolerant, liberal CSV parsing
|
|
|
143
144
|
test_files:
|
|
144
145
|
- spec/fixtures/accents_semicolon_windows_1252.csv
|
|
145
146
|
- spec/fixtures/bad_quoting.csv
|
|
147
|
+
- spec/fixtures/blank_lines_crlf.csv
|
|
146
148
|
- spec/fixtures/dos_line_ending.csv
|
|
147
149
|
- spec/fixtures/encoding.csv
|
|
148
150
|
- spec/fixtures/escaped_quotes.csv
|