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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/bin/comma_splice +13 -0
- data/lib/comma_splice/helpers/comma_calculator.rb +11 -5
- data/lib/comma_splice/helpers/option_scorer.rb +3 -3
- data/lib/comma_splice/version.rb +1 -1
- data/lib/comma_splice.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd12b113b4440991523636f0cb9e7cf193394704cf12234f640632001bee96fa
|
4
|
+
data.tar.gz: 9ad043ca537cef2ab6e3ada54e56e07c04e762c58d3ecca314b894222e86ca42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1efb0c81ae6927969ac5e142d94553f845a454620774c333b23a97d4afffca93a8929156f8b2216d2360446fcf97f986d09ba4e1a4983b25f59822f07cef406
|
7
|
+
data.tar.gz: 5cabfeb12c2329e1d8ed3be5c0518435863a0d63dd7c226c11dd3339cca1c38990b0527b20ceb000e1c3ad4cdaed53235041d5741a63ccae56eb393909e5e2ba
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### 0.2 (January
|
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
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
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
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.
|
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.
|
100
|
-
result.
|
99
|
+
if result.size.positive? && result.first.index(',')
|
100
|
+
result.join(',').size
|
101
101
|
else
|
102
102
|
0
|
103
103
|
end
|
data/lib/comma_splice/version.rb
CHANGED
data/lib/comma_splice.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|