pronto-spell 0.6.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 30fc7a9b7901c64d7406fdeedd2b868837f72fdd
4
- data.tar.gz: 61c331d95672195dd274e4e520f2852668d08a13
2
+ SHA256:
3
+ metadata.gz: 07f54bc81dcc96ab8d9fa447d718925489a274569836eac59e70863774bdcf01
4
+ data.tar.gz: bc02b4e4e5466fb1c3a129c31e7dfa0b494d462772246d7f3849266c9c192e8d
5
5
  SHA512:
6
- metadata.gz: 501ebce54992da0b63934f268f0e1d6adacd026301d4f901e3669ca9dd7b64233dd4355eee1bed9cc5aef80131d5e450ff35f6c234b9155d16fac6c92bf99b7d
7
- data.tar.gz: f3b2fe277ab7aae01d4822bea8061701a3c45b9b9edf48463b3e001128a681fc0deb8eb7b4e8f4e613407bf8564baddd1ed025b38d0cc95bbdc3b9ab512d3c5a
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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2016 Mindaugas Mozūras
3
+ Copyright (c) 2017 Mindaugas Mozūras
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Pronto runner that uses Aspell for spell checking
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/mmozuras/pronto-spell.png)](https://codeclimate.com/github/mmozuras/pronto-spell)
4
- [![Build Status](https://travis-ci.org/mmozuras/pronto-spell.png)](https://travis-ci.org/mmozuras/pronto-spell)
3
+ [![Code Climate](https://codeclimate.com/github/prontolabs/pronto-spell.png)](https://codeclimate.com/github/prontolabs/pronto-spell)
4
+ [![Build Status](https://travis-ci.org/prontolabs/pronto-spell.png)](https://travis-ci.org/prontolabs/pronto-spell)
5
5
  [![Gem Version](https://badge.fury.io/rb/pronto-spell.png)](http://badge.fury.io/rb/pronto-spell)
6
- [![Dependency Status](https://gemnasium.com/mmozuras/pronto-spell.png)](https://gemnasium.com/mmozuras/pronto-spell)
6
+ [![Dependency Status](https://gemnasium.com/prontolabs/pronto-spell.png)](https://gemnasium.com/prontolabs/pronto-spell)
7
7
 
8
- Pronto runner that uses [Aspell](https://github.com/YorickPeterse/ffi-aspell) for spell checking. [What is Pronto?](https://github.com/mmozuras/pronto)
8
+ Pronto runner that uses [Aspell](https://github.com/YorickPeterse/ffi-aspell) for spell checking. [What is Pronto?](https://github.com/prontolabs/pronto)
9
9
 
10
10
  ## Prerequisites
11
11
 
@@ -13,3 +13,34 @@ You'll need to install Aspell:
13
13
 
14
14
  * Arch Linux: `sudo pacman -S aspell`
15
15
  * OS X: (`brew install aspell --lang=en`)
16
+
17
+ ## Configuration
18
+
19
+ In order to change configuration, you need to create `.pronto_spell.yaml` file in your project root directory. Awailable options are:
20
+
21
+ ```YAML
22
+ suggestion_mode: 'fast' # default
23
+ language: 'en_US' # default
24
+ min_word_length: 5 # default
25
+ max_word_length: 999 # default is Infinity
26
+ max_suggestions_number: 3 # default
27
+ ignored_words: # words in this list won't be marked as misspelled
28
+ - aspell
29
+ - boolean
30
+ - datetime
31
+ only_lines_matching: # spell checker will run only if the diff contains a word in this list
32
+ - context
33
+ - describe
34
+ ```
35
+
36
+ It's also handy to have `.pronto.yml`. Here is configuration, designed for rails project:
37
+ ```YAML
38
+ spell:
39
+ exclude:
40
+ - 'yarn.lock'
41
+ - 'Gemfile.lock'
42
+ - 'Gemfile'
43
+ - 'package.json'
44
+ - '.*.yml'
45
+ - '*.json'
46
+ ```
@@ -1,22 +1,46 @@
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
8
+ CONFIG_FILE = '.pronto_spell.yml'
9
+
10
+ def ignored_words
11
+ @ignored_words ||= begin
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))
19
+ end
20
+ end
21
+
6
22
  def run
7
- return [] unless @patches
23
+ return [] if !@patches || @patches.count.zero?
8
24
 
9
- @patches.select { |patch| patch.additions > 0 }
25
+ @patches
26
+ .select { |patch| patch.additions.positive? }
10
27
  .map { |patch| inspect(patch) }
11
28
  .flatten.compact
12
29
  end
13
30
 
31
+ private
32
+
14
33
  def inspect(patch)
15
34
  patch.added_lines.map do |line|
16
- words = line.content.scan(/[0-9a-zA-Z]+/)
17
- words.select { |word| word.length > 4 }
18
- .uniq
19
- .select { |word| !speller.correct?(word) }
35
+ if keywords.any? && !keywords_regexp.match(line.content)
36
+ next
37
+ end
38
+
39
+ words = line.content.scan(/([A-Z]{2,})|([A-Z]{0,1}[a-z]+)/)
40
+ .flatten.compact.uniq
41
+
42
+ words
43
+ .select { |word| misspelled?(word) }
20
44
  .map { |word| new_message(word, line) }
21
45
  end
22
46
  end
@@ -26,17 +50,60 @@ module Pronto
26
50
  level = :warning
27
51
 
28
52
  suggestions = speller.suggestions(word)
29
- msg = "#{word} might not be spelled correctly. Spelling suggestions: #{suggestions}"
53
+
54
+ msg = %("#{word}" might not be spelled correctly.)
55
+ if suggestions.any?
56
+ suggestions_text = suggestions[0..max_suggestions_number - 1].join(', ')
57
+ msg += " Spelling suggestions: #{suggestions_text}"
58
+ end
30
59
 
31
60
  Message.new(path, line, level, msg, nil, self.class)
32
61
  end
33
62
 
34
63
  def speller
35
- @speller ||= begin
36
- result = FFI::Aspell::Speller.new('en_US')
37
- result.suggestion_mode = 'fast'
38
- result
64
+ @speller ||= FFI::Aspell::Speller.new(
65
+ language, 'sug-mode': suggestion_mode
66
+ )
67
+ end
68
+
69
+ def spelling_config
70
+ @spelling_config ||= begin
71
+ config_path = File.join(repo_path, CONFIG_FILE)
72
+ File.exist?(config_path) ? YAML.load_file(config_path) : {}
39
73
  end
40
74
  end
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
+
84
+ def suggestion_mode
85
+ spelling_config['suggestion_mode'] || 'fast'
86
+ end
87
+
88
+ def min_word_length
89
+ spelling_config['min_word_length'] || 5
90
+ end
91
+
92
+ def max_word_length
93
+ spelling_config['max_word_length'] || Float::INFINITY
94
+ end
95
+
96
+ def max_suggestions_number
97
+ spelling_config['max_suggestions_number'] || 3
98
+ end
99
+
100
+ def misspelled?(word)
101
+ lintable_word?(word) && !speller.correct?(word)
102
+ end
103
+
104
+ def lintable_word?(word)
105
+ (min_word_length..max_word_length).cover?(word.length) &&
106
+ !ignored_words.include?(word.downcase)
107
+ end
41
108
  end
42
109
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Pronto
2
4
  module SpellVersion
3
- VERSION = '0.6.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'
@@ -10,11 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.author = 'Mindaugas Mozūras'
12
12
  s.email = 'mindaugas.mozuras@gmail.com'
13
- s.homepage = 'http://github.org/mmozuras/pronto-spell'
13
+ s.homepage = 'https://github.com/mmozuras/pronto-spell'
14
14
  s.summary = 'Pronto runner that uses Aspell for spell checking'
15
15
 
16
16
  s.licenses = ['MIT']
17
- s.required_ruby_version = '>= 1.9.3'
17
+ s.required_ruby_version = '>= 2.3.0'
18
18
  s.rubygems_version = '1.8.23'
19
19
 
20
20
  s.files = `git ls-files`.split($RS).reject do |file|
@@ -32,9 +32,9 @@ 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.6.0')
36
35
  s.add_dependency('ffi-aspell', '~> 1.1.0')
37
- s.add_development_dependency('rake', '~> 11.0')
36
+ s.add_dependency('pronto', '~> 0.11.0')
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')
40
40
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-spell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.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: 2016-03-14 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.6.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.6.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
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '11.0'
47
+ version: '12.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '11.0'
54
+ version: '12.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -88,12 +88,14 @@ 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
94
96
  - lib/pronto/spell/version.rb
95
97
  - pronto-spell.gemspec
96
- homepage: http://github.org/mmozuras/pronto-spell
98
+ homepage: https://github.com/mmozuras/pronto-spell
97
99
  licenses:
98
100
  - MIT
99
101
  metadata: {}
@@ -105,15 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
107
  requirements:
106
108
  - - ">="
107
109
  - !ruby/object:Gem::Version
108
- version: 1.9.3
110
+ version: 2.3.0
109
111
  required_rubygems_version: !ruby/object:Gem::Requirement
110
112
  requirements:
111
113
  - - ">="
112
114
  - !ruby/object:Gem::Version
113
115
  version: '0'
114
116
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.4.5
117
+ rubygems_version: 3.0.3
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Pronto runner that uses Aspell for spell checking