comma_splice 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: e0a958c45c6fe94fbc6a4af1cb5fc2a0c20cf7a68728520d227b62a79e2078a5
4
- data.tar.gz: 7e4e09b4a3308a2ccb2c5a58d1b56ced9f6f5927bf41d89680c4401b5aad2b5d
3
+ metadata.gz: 74958cacc824b9e475df20acee4cc75ac354738ab4ed475a7ddc5f3ce5c7c553
4
+ data.tar.gz: 3b7129b58e24be7e9549e2971b994fd159e0d21675118e3c413a38dc1823db9c
5
5
  SHA512:
6
- metadata.gz: 1daff9cfdd5f54c37bd47edc83b02308a0f3fe7b0d8af86dd0a910e264929a5b5b1191386b3b06df42f157770c4bc733c656e3beb4d9bafe10d7bc65a5483185
7
- data.tar.gz: f6e4c32e2e03d3bf915a9b8360146eaa34ed9b34a954cb4b9a74b08c68ef4f8ae15cba83c854f96b88b098b791f802200992e46194a373e27cdd388c40311136
6
+ metadata.gz: 112fea4670275a7222bbf60d13c8f61cea9386a60eaaf2cf16fd514f5c0ffd69a4e2e0453658408977607608340ca1e94e7f53581565d10014501c18d61a6570
7
+ data.tar.gz: b62a9835b22555efd4aad03c467c1d24f298d50c34b399171f8fc5bcb0d8c1ddfff1be14268599fe5ce67b88c6b9201c6c3e250e72de34361ba252594a6146e1
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ### 0.1.1 (January 24, 2020)
4
+ - [BUGFIX] handle case where all columns are equal widths
5
+ - [BUGFIX] Improve error message
6
+ - [IMPROVEMENT] simplify slicing [\#1](https://github.com/jkeen/comma_splice/pull/1) ([AlexMooney](https://github.com/AlexMooney))
7
+
8
+ ### 0.1.0 (August 5th, 2019)
9
+ - Initial Release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comma_splice (0.1.0)
4
+ comma_splice (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  thor
50
50
 
51
51
  BUNDLED WITH
52
- 2.0.1
52
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Comma Splice
2
2
 
3
- This gem tackles one very specific problem: when CSVs have commas in the values and the values haven't been quoted. This determines which commas separate fields and which commas are part of a value, and corrects the file.
3
+ This gem tackles [one very specific problem](https://medium.com/@jeffkeen/how-to-correct-32-000-incorrect-csv-files-in-fewer-than-32-000-steps-a5f1ba25d951): when CSVs have commas in the values and the values haven't been quoted. This determines which commas separate fields and which commas are part of a value, and corrects the file.
4
4
 
5
5
  For example, given the following CSV
6
6
 
@@ -19,7 +19,7 @@ which parses incorrectly as:
19
19
  | 01-27-2019 @ 12:31:00 | Lester Sterling | Lester Sterling Special | Merritone Rock Steady 2: This Music Got Soul 1966-1967 | Dub Store |
20
20
 
21
21
 
22
- Running this through `comma_splice fix /path/to/file` will return this corrected content:
22
+ Running this through `comma_splice correct /path/to/file` will return this corrected content:
23
23
 
24
24
  ```
25
25
  timestamp,artist,title,albumtitle,label
@@ -34,10 +34,10 @@ module CommaSplice
34
34
  end
35
35
 
36
36
  start_column = variables.find_index(true)
37
- end_column = variables.reverse.find_index(true) * -1
37
+ end_column = variables.reverse.find_index(true)
38
38
 
39
- @start_column = start_column
40
- @end_column = end_column
39
+ @start_column = start_column || 0
40
+ @end_column = (end_column || 1) * -1
41
41
  end
42
42
 
43
43
  private
@@ -13,8 +13,8 @@ module CommaSplice
13
13
  @left_bounds = left_bounds
14
14
  @right_bounds = right_bounds
15
15
 
16
- raise 'right bounds must be less than -1' unless right_bounds < 0
17
- raise 'left bounds must be greater than zero' unless left_bounds >= 0
16
+ raise 'right bounds must be negative' unless right_bounds.negative?
17
+ raise 'left bounds must be not be negative' if left_bounds.negative?
18
18
  end
19
19
 
20
20
  def needs_correcting?
@@ -35,17 +35,8 @@ module CommaSplice
35
35
  # the only values that could contain an extra comma are "artist,title,albumtitle,label"
36
36
  # therefore our left_bounds = 4, right_bounds = -5
37
37
 
38
- values_before = if left_bounds > 0
39
- values[0..(left_bounds - 1)]
40
- else
41
- []
42
- end
43
-
44
- values_after = if right_bounds < -1
45
- values[(right_bounds + 1)..-1]
46
- else
47
- []
48
- end
38
+ values_before = values[0...left_bounds]
39
+ values_after = values.slice(right_bounds + 1, -(right_bounds + 1))
49
40
  [values_before, corrector.correction, values_after].flatten.join(',')
50
41
  end
51
42
 
@@ -1,3 +1,3 @@
1
1
  module CommaSplice
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comma_splice
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
  - Jeff Keen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,6 +104,7 @@ extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
106
  - ".rspec"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - Gemfile.lock
109
110
  - LICENSE.txt
@@ -142,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.7.8
146
+ rubygems_version: 3.0.6
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Fixes CSVs with unescaped commas