forspell 0.0.7 → 0.0.8
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 +5 -5
- data/README.md +4 -1
- data/lib/forspell/cli.rb +5 -9
- data/lib/forspell/reporter.rb +15 -4
- data/lib/forspell/speller.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9b5038eb72a4bc473d5e567d4a0f77a699f99f0452ccfe59107e999d2bc6baf4
|
4
|
+
data.tar.gz: 5d657cf3c28c6c01c92aa4aa57d85dbf24baf8fef9d946d2c026755b7c114e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d36717ed7a398c0d48d417177be3b16f7100aa94b803e4125fc78c0d757f7e06c0df91cb2207f38d93ad280e11e52928ea7874ffaec7ede6310089ba8b13a69
|
7
|
+
data.tar.gz: 88370117516966529328dcde00931879523a58876204a4450d65e12144080ab328c806cde043c8fae7182156979da9018487f5146f7778f0203426278625c533
|
data/README.md
CHANGED
@@ -44,7 +44,10 @@ Options:
|
|
44
44
|
--help
|
45
45
|
```
|
46
46
|
|
47
|
-
forspell automatically loads command-line arguments from `.forspell` file in current folder, if it is present.
|
47
|
+
`forspell` automatically loads command-line arguments from `.forspell` file in current folder, if it is present.
|
48
|
+
Arguments for `forspell` command are directories or separate files you want to check.
|
49
|
+
If no arguments provided, current directory will be processed.
|
50
|
+
Supported file extensions are `.rb`, `.c`, `.cpp`, `.md`.
|
48
51
|
|
49
52
|
### Dictionaries
|
50
53
|
|
data/lib/forspell/cli.rb
CHANGED
@@ -38,9 +38,9 @@ module Forspell
|
|
38
38
|
|
39
39
|
def call
|
40
40
|
init_options
|
41
|
+
init_reporter
|
41
42
|
create_files_list
|
42
43
|
init_speller
|
43
|
-
init_reporter
|
44
44
|
run
|
45
45
|
end
|
46
46
|
|
@@ -48,6 +48,9 @@ module Forspell
|
|
48
48
|
|
49
49
|
def create_files_list
|
50
50
|
@files = FileList.new(paths: @opts.arguments, exclude_paths: @opts[:exclude_paths])
|
51
|
+
rescue Forspell::FileList::PathLoadError => path
|
52
|
+
@reporter.path_load_error path
|
53
|
+
exit ERROR_CODE
|
51
54
|
end
|
52
55
|
|
53
56
|
def init_options
|
@@ -55,11 +58,7 @@ module Forspell
|
|
55
58
|
|
56
59
|
@opts = Slop.parse(@options, &DEFINITIONS)
|
57
60
|
|
58
|
-
if @opts.arguments.empty?
|
59
|
-
puts 'Usage: forspell paths to check [options]'
|
60
|
-
puts 'Type --help for more info'
|
61
|
-
exit(ERROR_CODE)
|
62
|
-
end
|
61
|
+
@opts.arguments << '.' if @opts.arguments.empty?
|
63
62
|
|
64
63
|
@opts[:format] = 'dictionary' if @opts[:gen_dictionary]
|
65
64
|
@opts[:format] = @opts[:format]&.downcase
|
@@ -88,9 +87,6 @@ module Forspell
|
|
88
87
|
runner = Forspell::Runner.new(files: @files, speller: @speller, reporter: @reporter)
|
89
88
|
runner.call
|
90
89
|
exit @reporter.finalize
|
91
|
-
rescue Forspell::FileList::PathLoadError => path
|
92
|
-
@reporter.path_load_error path
|
93
|
-
exit ERROR_CODE
|
94
90
|
end
|
95
91
|
end
|
96
92
|
end
|
data/lib/forspell/reporter.rb
CHANGED
@@ -13,10 +13,16 @@ module Forspell
|
|
13
13
|
ERROR_CODE = 1
|
14
14
|
DICT_PATH = File.join(Dir.pwd, 'forspell.dict')
|
15
15
|
DICT_OVERWRITE = 'Do you want to overwrite forspell.dict? (yN)'
|
16
|
+
DICT_PROMPT = <<~PROMPT
|
17
|
+
# Format: one word per line. Empty lines and #-comments are supported too.
|
18
|
+
# If you want to add word with its forms, you can write 'word: example' (without quotes) on the line,
|
19
|
+
# where 'example' is existing word with the same possible forms (endings) as your word.
|
20
|
+
# Example: deduplicate: duplicate
|
21
|
+
PROMPT
|
16
22
|
SUGGEST_FORMAT = '(suggestions: %<suggestions>s)'
|
17
23
|
ERROR_FORMAT = '%<file>s:%<line>i: %<text>s %<suggest>s'
|
18
24
|
SUMMARY = "Forspell inspects *.rb, *.c, *.cpp, *.md files\n"\
|
19
|
-
'%<files>i inspected, %<errors>s detected'
|
25
|
+
'%<files>i file%<files_plural>s inspected, %<errors>s error%<errors_plural>s detected'
|
20
26
|
|
21
27
|
attr_accessor :progress_bar
|
22
28
|
|
@@ -51,7 +57,7 @@ module Forspell
|
|
51
57
|
@logger.error "Parsing error in #{@files.last}: #{error}"
|
52
58
|
end
|
53
59
|
|
54
|
-
def path_load_error
|
60
|
+
def path_load_error(path)
|
55
61
|
@logger.error "Path not found: #{path}"
|
56
62
|
end
|
57
63
|
|
@@ -93,7 +99,11 @@ module Forspell
|
|
93
99
|
color = err_count.positive? ? :red : :green
|
94
100
|
total_errors_colorized = @pastel.decorate(err_count.to_s, color)
|
95
101
|
|
96
|
-
print format(SUMMARY,
|
102
|
+
print format(SUMMARY,
|
103
|
+
files: @files.size,
|
104
|
+
errors: total_errors_colorized,
|
105
|
+
files_plural: @files.size == 1 ? '' : 's',
|
106
|
+
errors_plural: err_count == 1 ? '' : 's')
|
97
107
|
end
|
98
108
|
|
99
109
|
def print_dictionary
|
@@ -105,6 +115,7 @@ module Forspell
|
|
105
115
|
else
|
106
116
|
out = File.new(DICT_PATH, 'w')
|
107
117
|
end
|
118
|
+
out.puts DICT_PROMPT unless out.tty?
|
108
119
|
@errors.map(&:first)
|
109
120
|
.group_by(&:text)
|
110
121
|
.transform_values { |v| v.map(&:file).uniq }
|
@@ -117,7 +128,7 @@ module Forspell
|
|
117
128
|
|
118
129
|
private
|
119
130
|
|
120
|
-
def print
|
131
|
+
def print(something)
|
121
132
|
$stdout.tty? ? @progress_bar&.log(something) : puts(something)
|
122
133
|
end
|
123
134
|
end
|
data/lib/forspell/speller.rb
CHANGED
@@ -37,12 +37,12 @@ module Forspell
|
|
37
37
|
|
38
38
|
alterations.any?{ |w| dictionary.check?(w) }
|
39
39
|
else
|
40
|
-
parts.all? { |part| correct?(part) }
|
40
|
+
dictionary.check?(word) || parts.all? { |part| correct?(part) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def suggest(word)
|
45
|
-
@suggestions_size.positive? ? dictionary.suggest(word).first(@suggestions_size) : []
|
45
|
+
@suggestions_size.positive? ? dictionary.suggest(word).first(@suggestions_size) - [word, word.capitalize] : []
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Kuprikov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slop
|
@@ -257,8 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
|
-
|
261
|
-
rubygems_version: 2.6.14
|
260
|
+
rubygems_version: 3.0.1
|
262
261
|
signing_key:
|
263
262
|
specification_version: 4
|
264
263
|
summary: For spelling check
|