csv_separator_detector 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/csv_separator_detector/version.rb +1 -1
- data/lib/csv_separator_detector.rb +5 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc6d9464377f2e0437a4f4c081ed04d78e7f39438b4c0b6348b3c7dd57a7ac49
|
4
|
+
data.tar.gz: d46011965be500f4907607ec8c3c8a35a1abf50699b8b2517c65cc62becf6043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 437f68a2adf57eb20e52e4e18770639e501c6bd88706cb9d34c3105eb5cac0c50833dbf52745a32d9ef5aaf230e18eea6c7c6a855fb69cce15f56d0548a0542d
|
7
|
+
data.tar.gz: 6d9404d1f40a7084872a54ffe9e831196c0427cabcb03dab8b1c21dba8726b949ae4e2d5adf1e5e2715238ce83a4dbc88cea74466f06e07829a1c74efdba0220
|
@@ -12,6 +12,8 @@ class CsvSeparatorDetector
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
+
fail ArgumentError, 'Input is nil. Expected it to be a string, with comma-separated lines of text' if csv_text.nil?
|
16
|
+
|
15
17
|
separator_with_most_columns or fail CsvSeparatorDetector::Error
|
16
18
|
end
|
17
19
|
|
@@ -39,8 +41,9 @@ class CsvSeparatorDetector
|
|
39
41
|
supported_separators.each_with_object({}) do |sep, memo|
|
40
42
|
begin
|
41
43
|
columns = ::CSV.parse_line(csv_text, col_sep: sep)
|
42
|
-
|
43
|
-
memo[
|
44
|
+
column_count = columns ? columns.length : 0
|
45
|
+
memo[column_count] ||= []
|
46
|
+
memo[column_count] << sep
|
44
47
|
rescue ::CSV::MalformedCSVError
|
45
48
|
# do nothing
|
46
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_separator_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Tulentsev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.6
|
92
|
+
rubygems_version: 2.7.6
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Detect separators in CSV content
|