forspell 0.0.7 → 0.0.9

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
- SHA1:
3
- metadata.gz: 67422b4f2942f8a061b0551a4fa837c0c0c93140
4
- data.tar.gz: b56c34d10ecd2bee9dbfa14757ec7853d8a6fe17
2
+ SHA256:
3
+ metadata.gz: 16e96dc4e732badadf52412ae2cc8d2f6fd1b900e760151b8c8a8b0172eef612
4
+ data.tar.gz: ffbf262ff89973346045aa6e586ae0a7e31f1fbbfc284d7bd7c3448b8218ab2b
5
5
  SHA512:
6
- metadata.gz: 1e2512ac8231b29ac095fdf2d71b426a82ba9365c6ae4d9cbf52f349f76b12bf7cdfe170b2001b4f0fe7b3fc4239175f59d8cec7f9742880c30d7a0bc8c88cff
7
- data.tar.gz: 432eb94fcf818aba269b8292988956ba905964426e239ae35a9c3972813d6d1b7c19d9a1da2e4146d3f649bfbe13902359ba49fe532458e330e04c6cc4ad89b7
6
+ metadata.gz: 50ac0b2e6b5b3e243d4ee11abeb84b22374e45623d142521111ebe3bb2e81f0118b944be72099212775f9f64a9b13c0260f04b2255b5d3a541a7b03214a9db3a
7
+ data.tar.gz: 675033785e77aa12a510589519ee2177f126fb9cf54dab53071d6006a5114fa7fc05d12e465a08ebe8acc01135c2bdd7aad71aee9626bba96fa3ddc7a240e1bd
data/README.md CHANGED
@@ -3,21 +3,21 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/forspell.svg)](http://badge.fury.io/rb/forspell)
4
4
  [![Build Status](https://travis-ci.org/kkuprikov/forspell.svg?branch=master)](https://travis-ci.org/kkuprikov/forspell)
5
5
 
6
- **Forspell** is spellchecker for code and documentation. It uses well-known [hunspell](https://en.wikipedia.org/wiki/Hunspell) tool and dictionary, provides customizable output, and could be easily integrated into CI pipeline.
6
+ **Forspell** is a spellchecker for code and documentation. It uses the well-known [hunspell](https://en.wikipedia.org/wiki/Hunspell) tool and dictionary, provides customizable output, and could be easily integrated into CI pipeline.
7
7
 
8
- Example of output:
8
+ Here's an output example:
9
9
 
10
10
  ![](https://user-images.githubusercontent.com/713419/55152630-d775a600-5161-11e9-9c56-d9fb45d8a3a4.png)
11
11
 
12
12
  ## Features
13
13
 
14
- * Able to check Markdown files and comments inside Ruby, C and C++ source code;
15
- * Correctly skips over code examples and identifiers inside comments and Markdown most of the time;
14
+ * Ability to check Markdown files and comments in Ruby, C and C++ code;
15
+ * Skipping over code examples and identifiers inside comments and Markdown most of the time;
16
16
  * Distributed with latest en-US hunspell dictionaries, but can be set to use any other dictionary;
17
- * Includes by default custom Ruby ecosystem-related dictionary (so it will not report as misspelled words like "Gemfile", "args", "middleware" and alike);
18
- * It is easy to create custom dictionary for your project, so your internal terms would not be reported as misspellings;
17
+ * Includes a custom Ruby ecosystem-related dictionary (so it will not report words like "Gemfile", "args", "middleware" and alike as misspelled);
18
+ * Easiness to create a custom dictionary for your project, so your internal terms would not be reported as misspellings;
19
19
  * Option to auto-generate initial custom dictionary;
20
- * Several output formats, including pretty colorized human-readable, YAML and JSON.
20
+ * Several output formats, including pretty print, YAML and JSON.
21
21
 
22
22
  ## Installation
23
23
 
@@ -25,7 +25,7 @@ Example of output:
25
25
  gem install forspell
26
26
  ```
27
27
 
28
- `forspell` requires `libhunspell` >= 1.2.0 to be installed, see [hunspell site](https://github.com/hunspell/hunspell) for installation instructions (it is probably as easy as `<yourpackagemanager> install hunspell` on most of Linuxes and MacOS).
28
+ `forspell` requires `libhunspell` >= 1.2.0 to be installed, see [hunspell site](https://github.com/hunspell/hunspell) for installation instructions (it is probably as easy as `<yourpackagemanager> install hunspell` on most of *nix and MacOS).
29
29
 
30
30
  ## Usage
31
31
 
@@ -44,26 +44,29 @@ 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
+ With no arguments provided, a current directory will be processed.
50
+ Supported file extensions are `.rb`, `.c`, `.cpp`, `.md`.
48
51
 
49
52
  ### Dictionaries
50
53
 
51
- As already said, forspell uses hunspell dictionaries to check spelling. By default, it is `en_US` modern dictionary, distributed with forspell itself, but you can specify any other with `-d` option. If you have `/some/custom/path/fr_FR.aff` and `/some/custom/path/fr_FR.dic`, than you can use it instead of `en_US` with `-d /some/custom/path/fr_FR`.
54
+ Forspell uses hunspell dictionaries to check spelling. By default, it is the `en_US` modern dictionary, distributed with forspell itself, but you can specify any other with `-d` option. If you have `/some/custom/path/fr_FR.aff` and `/some/custom/path/fr_FR.dic`, than you can use it instead of `en_US` with `-d /some/custom/path/fr_FR`.
52
55
 
53
56
  In addition to the main dictionary, forspell also includes (and always uses) small auxiliary dictionary with words specific for Ruby ecosystem, you can review it in [forspell repo](https://github.com/kkuprikov/forspell/blob/master/lib/forspell/ruby.dict).
54
57
 
55
- You can also add your project's **custom dictionary** with internal terms, for them not to obstruct spellchecker's output. Custom dictionary (or several) can be passed with `-c` option. Also, `forspell.dict` would be automatically read, if present in current directory. Format of custom dictionary:
58
+ You can also add your project's **custom dictionary** with internal terms, for them not to obstruct spellchecker's output. Custom dictionary (or several) may be passed with `-c` option. Also, `forspell.dict` will be automatically processed, if presented in current directory. Format of custom dictionary:
56
59
 
57
60
  * Each word on its own line.
58
61
  * Line contains either just `word` (means only this word in this form).
59
62
  * ...or `word: example` -- in this case, "example" should be existing word from the main dictionary, and it means your custom term can have the same forms as example word. For example, "subclass: class" will mean that "subclass", "subclasses" and "subclass'" should be considered correct.
60
63
  * `#` marks comments.
61
64
 
62
- For larger projects, it is handy to generate custom dictionary with `forspell your,project,pathes --gen-dictionary`. This will create `forspell.dict` with all misspelling found in your project, you can proceed by deleting genuine errors and leave what should be considered correct internal terms.
65
+ For larger projects, it is handy to generate a custom dictionary with `forspell your,project,paths --gen-dictionary`. This will create `forspell.dict` with all misspellings found in your project, and you can proceed by deleting genuine errors and leave internal terms, which should be considered correct.
63
66
 
64
67
  ## Integration with CI
65
68
 
66
- Forspell return codes:
69
+ Forspell's return codes:
67
70
 
68
71
  * 0 - when no errors found
69
72
  * 1 - when there are any errors
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
@@ -36,7 +36,7 @@ module Forspell
36
36
  def expand_paths(path)
37
37
  if File.directory?(path)
38
38
  Dir.glob(File.join(path, '**', "*.{#{EXTENSION_GLOBS.join(',')}}"))
39
- elsif File.exists? path
39
+ elsif File.exist? path
40
40
  path
41
41
  else
42
42
  raise PathLoadError, path
@@ -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 path
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, files: @files.size, errors: total_errors_colorized)
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 something
131
+ def print(something)
121
132
  $stdout.tty? ? @progress_bar&.log(something) : puts(something)
122
133
  end
123
134
  end
@@ -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.7
4
+ version: 0.0.9
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-05-27 00:00:00.000000000 Z
12
+ date: 2024-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '5.0'
76
+ version: '6.0'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '5.0'
83
+ version: '6.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: yard
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -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
- rubyforge_project:
261
- rubygems_version: 2.6.14
260
+ rubygems_version: 3.0.3.1
262
261
  signing_key:
263
262
  specification_version: 4
264
263
  summary: For spelling check