pronto-spell 0.10.0 → 0.11.0

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: d1f4b64675918e0fa51a628c161e4bbbaf774fca7a1f6508e22d4b9f8f7e8402
4
- data.tar.gz: 6b6a768dd4ac49a4762334b68d3d8507af3f23567eac72372fcdb6c2c86a9ad8
3
+ metadata.gz: 07f54bc81dcc96ab8d9fa447d718925489a274569836eac59e70863774bdcf01
4
+ data.tar.gz: bc02b4e4e5466fb1c3a129c31e7dfa0b494d462772246d7f3849266c9c192e8d
5
5
  SHA512:
6
- metadata.gz: 3a0a4d6c9e9eacc0e35fcd3263ae89c00d189b1fc0366666195cdbfe1a01ceb07efe7235eca8516d53cc7a489cb242c414bc3a18df671107907c86b580fe39e7
7
- data.tar.gz: 557c522a42ae028a0c9db1d5a25267ed07c6b70f17264f815fec6020ee2433257834eda90a5f6db5495a6f92e0faa0bf7b42b9ccd67ad32621363c5754ae558c
6
+ metadata.gz: 46455fa1baafe659fe69c14a9db5a7803af4315e76ab9e340a67fce8f699a8bea215a0ebfae9750a401ce2a716d0a50dfaecdb06353bd35c39b07f126c3345ef
7
+ data.tar.gz: bfa0787135e7fcb72c54d021bb1d4d2c725f8c5602c9d0f4da8245d64208d22e2b5696dde5291366079163c3734022313a520e48188b38cc4cff5cb02b6f903d
@@ -0,0 +1,3 @@
1
+ # Order is important. The last matching pattern takes the most precedence.
2
+ # Default owners for everything in the repo.
3
+ * @prontolabs/core
@@ -0,0 +1,22 @@
1
+ name: Checks
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ ruby:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0']
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
21
+ - name: rake spec
22
+ run: bundle exec rake spec
data/README.md CHANGED
@@ -20,6 +20,7 @@ In order to change configuration, you need to create `.pronto_spell.yaml` file i
20
20
 
21
21
  ```YAML
22
22
  suggestion_mode: 'fast' # default
23
+ language: 'en_US' # default
23
24
  min_word_length: 5 # default
24
25
  max_word_length: 999 # default is Infinity
25
26
  max_suggestions_number: 3 # default
@@ -27,6 +28,9 @@ ignored_words: # words in this list won't be marked as misspelled
27
28
  - aspell
28
29
  - boolean
29
30
  - datetime
31
+ only_lines_matching: # spell checker will run only if the diff contains a word in this list
32
+ - context
33
+ - describe
30
34
  ```
31
35
 
32
36
  It's also handy to have `.pronto.yml`. Here is configuration, designed for rails project:
@@ -1,14 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pronto'
2
4
  require 'ffi/aspell'
3
5
 
4
6
  module Pronto
5
7
  class Spell < Runner
6
- CONFIG_FILE = '.pronto_spell.yml'.freeze
8
+ CONFIG_FILE = '.pronto_spell.yml'
7
9
 
8
10
  def ignored_words
9
11
  @ignored_words ||= begin
10
- words = (spelling_config['ignored_words'] || []).map(&:downcase)
11
- Set.new(words)
12
+ Set.new(spelling_config['ignored_words'].to_a.map(&:downcase))
13
+ end
14
+ end
15
+
16
+ def keywords
17
+ @keywords ||= begin
18
+ Set.new(spelling_config['only_lines_matching'].to_a.map(&:downcase))
12
19
  end
13
20
  end
14
21
 
@@ -16,7 +23,7 @@ module Pronto
16
23
  return [] if !@patches || @patches.count.zero?
17
24
 
18
25
  @patches
19
- .select { |patch| patch.additions > 0 }
26
+ .select { |patch| patch.additions.positive? }
20
27
  .map { |patch| inspect(patch) }
21
28
  .flatten.compact
22
29
  end
@@ -25,6 +32,10 @@ module Pronto
25
32
 
26
33
  def inspect(patch)
27
34
  patch.added_lines.map do |line|
35
+ if keywords.any? && !keywords_regexp.match(line.content)
36
+ next
37
+ end
38
+
28
39
  words = line.content.scan(/([A-Z]{2,})|([A-Z]{0,1}[a-z]+)/)
29
40
  .flatten.compact.uniq
30
41
 
@@ -41,8 +52,9 @@ module Pronto
41
52
  suggestions = speller.suggestions(word)
42
53
 
43
54
  msg = %("#{word}" might not be spelled correctly.)
44
- unless suggestions.empty?
45
- msg += " Spelling suggestions: #{suggestions[0..2].join(', ')}"
55
+ if suggestions.any?
56
+ suggestions_text = suggestions[0..max_suggestions_number - 1].join(', ')
57
+ msg += " Spelling suggestions: #{suggestions_text}"
46
58
  end
47
59
 
48
60
  Message.new(path, line, level, msg, nil, self.class)
@@ -50,7 +62,7 @@ module Pronto
50
62
 
51
63
  def speller
52
64
  @speller ||= FFI::Aspell::Speller.new(
53
- 'en_US', :'sug-mode' => suggestion_mode
65
+ language, 'sug-mode': suggestion_mode
54
66
  )
55
67
  end
56
68
 
@@ -61,6 +73,14 @@ module Pronto
61
73
  end
62
74
  end
63
75
 
76
+ def keywords_regexp
77
+ @keywords_regexp ||= %r{#{keywords.to_a.join('|')}}
78
+ end
79
+
80
+ def language
81
+ spelling_config['language'] || 'en_US'
82
+ end
83
+
64
84
  def suggestion_mode
65
85
  spelling_config['suggestion_mode'] || 'fast'
66
86
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Pronto
2
4
  module SpellVersion
3
- VERSION = '0.10.0'.freeze
5
+ VERSION = '0.11.0'
4
6
  end
5
7
  end
@@ -1,8 +1,8 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
4
- require 'English'
3
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
5
4
  require 'pronto/spell/version'
5
+ require 'English'
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = 'pronto-spell'
@@ -32,8 +32,8 @@ Gem::Specification.new do |s|
32
32
  s.extra_rdoc_files = ['LICENSE', 'README.md']
33
33
  s.require_paths = ['lib']
34
34
 
35
- s.add_dependency('pronto', '~> 0.10.0')
36
35
  s.add_dependency('ffi-aspell', '~> 1.1.0')
36
+ s.add_dependency('pronto', '~> 0.11.0')
37
37
  s.add_development_dependency('rake', '~> 12.0')
38
38
  s.add_development_dependency('rspec', '~> 3.4')
39
39
  s.add_development_dependency('rspec-its', '~> 1.2')
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-spell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: pronto
14
+ name: ffi-aspell
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.0
19
+ version: 1.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.0
26
+ version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: ffi-aspell
28
+ name: pronto
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.0
33
+ version: 0.11.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.0
40
+ version: 0.11.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,8 @@ extra_rdoc_files:
88
88
  - LICENSE
89
89
  - README.md
90
90
  files:
91
+ - ".github/CODEOWNERS"
92
+ - ".github/workflows/checks.yml"
91
93
  - LICENSE
92
94
  - README.md
93
95
  - lib/pronto/spell.rb
@@ -112,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
114
  - !ruby/object:Gem::Version
113
115
  version: '0'
114
116
  requirements: []
115
- rubygems_version: 3.0.1
117
+ rubygems_version: 3.0.3
116
118
  signing_key:
117
119
  specification_version: 4
118
120
  summary: Pronto runner that uses Aspell for spell checking