comma_splice 0.2.0 → 0.2.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: bd44bca5b615b5f267ae81b16aaa6b379b53963e637af1cc000d6229996963d4
4
- data.tar.gz: bd70a25937f8baf3cec97eeb5276ce050f3898a76f5be9cf8e0c8e726bc5a8fa
3
+ metadata.gz: dd12b113b4440991523636f0cb9e7cf193394704cf12234f640632001bee96fa
4
+ data.tar.gz: 9ad043ca537cef2ab6e3ada54e56e07c04e762c58d3ecca314b894222e86ca42
5
5
  SHA512:
6
- metadata.gz: 991f2138d4d08941b1a83d231338a5197bce6bcea0e136c3cbb67ca67cf04b31ad425ce148d48f2bf5ca8280bfee2b736d7ace002cd043dac071bdee8ca2ad2f
7
- data.tar.gz: 4d9e601ab359fe6511d9c54b3469104e64f057953924a7867c6b7e58df224c9b5d9b279060ff7e67e3d965da7460334ed23f97c1fd2792c32441e2cc9f8161da
6
+ metadata.gz: d1efb0c81ae6927969ac5e142d94553f845a454620774c333b23a97d4afffca93a8929156f8b2216d2360446fcf97f986d09ba4e1a4983b25f59822f07cef406
7
+ data.tar.gz: 5cabfeb12c2329e1d8ed3be5c0518435863a0d63dd7c226c11dd3339cca1c38990b0527b20ceb000e1c3ad4cdaed53235041d5741a63ccae56eb393909e5e2ba
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
  .DS_Store
10
10
  .byebug_history
11
+ test-file.txt
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ### 0.2 (January 27, 2020)
3
+ ### 0.2.1 (January 26, 2020)
4
+ - [BUGFIX] Remove debug information from option output
5
+ - [IMPROVEMENT] Add debug option to display scoring info
6
+ - [BUGFIX] Fixed scoring for comma separated numbers
7
+
8
+ ### 0.2 (January 26, 2020)
4
9
  - [IMPROVEMENT] Add scoring model to better handle cases that needed prompting before, like comma-separated numbers
5
10
  - [IMPROVEMENT] Correct line escaping even on lines that don't have incorrect commas to ensure correct parsing of generated CSV down the line
6
11
  - [IMPROVEMENT] Use ruby csv library to generate lines instead of handling escaping cases manually
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comma_splice (0.2.0)
4
+ comma_splice (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bin/comma_splice CHANGED
@@ -7,6 +7,7 @@ require 'thor'
7
7
  class CommaSpliceCLI < Thor
8
8
  class_option :start_line, type: :numeric, default: nil
9
9
  class_option :end_line, type: :numeric, default: nil
10
+ class_option :debug, type: :boolean, default: false
10
11
 
11
12
  desc 'version', 'print the current comma_splice version'
12
13
  def version
@@ -15,6 +16,8 @@ class CommaSpliceCLI < Thor
15
16
 
16
17
  desc 'correct FILE_PATH', 'return corrected file contents'
17
18
  def correct(file_path)
19
+ setup
20
+
18
21
  file_corrector = CommaSplice::FileCorrector.new(
19
22
  file_path,
20
23
  start_line: options[:start_line],
@@ -26,6 +29,8 @@ class CommaSpliceCLI < Thor
26
29
 
27
30
  desc 'fix FILE_PATH [SAVE_PATH]', 'return corrected file contents'
28
31
  def fix(file_path, fix_path)
32
+ setup
33
+
29
34
  file_corrector = CommaSplice::FileCorrector.new(
30
35
  file_path,
31
36
  start_line: options[:start_line],
@@ -37,6 +42,8 @@ class CommaSpliceCLI < Thor
37
42
 
38
43
  desc 'bad_lines FILE_PATH', 'show bad lines'
39
44
  def bad_lines(file_path)
45
+ setup
46
+
40
47
  file_corrector = CommaSplice::FileCorrector.new(
41
48
  file_path,
42
49
  start_line: options[:start_line],
@@ -48,6 +55,8 @@ class CommaSpliceCLI < Thor
48
55
 
49
56
  desc 'bad_line_count FILE_PATH', 'check file contents for needed corrections'
50
57
  def bad_line_count(file_path)
58
+ setup
59
+
51
60
  file_corrector = CommaSplice::FileCorrector.new(
52
61
  file_path,
53
62
  start_line: options[:start_line],
@@ -56,6 +65,10 @@ class CommaSpliceCLI < Thor
56
65
 
57
66
  puts file_corrector.bad_lines.size
58
67
  end
68
+
69
+ def setup
70
+ CommaSplice.debug = options[:debug]
71
+ end
59
72
  end
60
73
 
61
74
  CommaSpliceCLI.start(ARGV)
@@ -73,6 +73,8 @@ module CommaSplice
73
73
  longest_header = @headers.max_by(&:length)
74
74
 
75
75
  options.each_with_index do |option, index|
76
+ score_breakdown = option.breakdown
77
+
76
78
  @headers.each_with_index do |header, i|
77
79
  marker = if i.zero?
78
80
  "(#{index + 1})"
@@ -80,12 +82,16 @@ module CommaSplice
80
82
  ''
81
83
  end
82
84
 
83
- puts marker.ljust(7) +
84
- header.ljust(longest_header.size) + ': ' +
85
- option.option[i].to_s
85
+ line = marker.ljust(7) +
86
+ header.ljust(longest_header.size) + ': ' +
87
+ option.option[i].to_s.ljust(75)
88
+
89
+ if CommaSplice.debug
90
+ line = line + "| " + (score_breakdown.shift || "")
91
+ end
92
+ puts line
86
93
  end
87
- puts ''.ljust(7) + "(score = #{option.score})"
88
- puts ''.ljust(7) + option.breakdown
94
+
89
95
  puts "\n"
90
96
  end
91
97
 
@@ -21,7 +21,7 @@ module CommaSplice
21
21
  end
22
22
  end
23
23
 
24
- breakdown.join("\n")
24
+ breakdown.unshift("score: #{score}")
25
25
  end
26
26
 
27
27
  def score
@@ -96,8 +96,8 @@ module CommaSplice
96
96
 
97
97
  option.collect do |o|
98
98
  result = o.to_s.scan(/\d{1,3}(?:,\d{1,3})*(?:\.\d+)?/)
99
- if result.first && result.first.index(',')
100
- result.first.size
99
+ if result.size.positive? && result.first.index(',')
100
+ result.join(',').size
101
101
  else
102
102
  0
103
103
  end
@@ -1,3 +1,3 @@
1
1
  module CommaSplice
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/comma_splice.rb CHANGED
@@ -16,4 +16,5 @@ require 'byebug'
16
16
 
17
17
  module CommaSplice
18
18
  class Error < StandardError; end
19
+ mattr_accessor :debug
19
20
  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.2.0
4
+ version: 0.2.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: 2020-01-26 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler