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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3fb3aafd4be7410864b3da814faf00fcdbfab984
4
- data.tar.gz: c25146c943306ee463a6068e111637579fdf44b3
2
+ SHA256:
3
+ metadata.gz: fc6d9464377f2e0437a4f4c081ed04d78e7f39438b4c0b6348b3c7dd57a7ac49
4
+ data.tar.gz: d46011965be500f4907607ec8c3c8a35a1abf50699b8b2517c65cc62becf6043
5
5
  SHA512:
6
- metadata.gz: 32111c5a1b813bf7a25c9a61dce58b82cb8f830dd0dfabbe64dc5268b40e8c387f7c5ea831e03081553b95784680308cf7d5cfdd68bcfeb7c54cfd2f503f1ec4
7
- data.tar.gz: a36d8bef9a4ebe54d2ccce9432a191c7f427482a78457ba785e790531545d95c03ce3791b4fc3c1a206cd0ad7534d5e3866ea193d621ae9223700d2b05c3cce9
6
+ metadata.gz: 437f68a2adf57eb20e52e4e18770639e501c6bd88706cb9d34c3105eb5cac0c50833dbf52745a32d9ef5aaf230e18eea6c7c6a855fb69cce15f56d0548a0542d
7
+ data.tar.gz: 6d9404d1f40a7084872a54ffe9e831196c0427cabcb03dab8b1c21dba8726b949ae4e2d5adf1e5e2715238ce83a4dbc88cea74466f06e07829a1c74efdba0220
@@ -1,3 +1,3 @@
1
1
  class CsvSeparatorDetector
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- memo[columns.length] ||= []
43
- memo[columns.length] << sep
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.0
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: 2017-04-30 00:00:00.000000000 Z
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.11
92
+ rubygems_version: 2.7.6
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Detect separators in CSV content