guard-codespell 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +16 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/guard-codespell.gemspec +29 -0
- data/lib/guard/codespell/version.rb +7 -0
- data/lib/guard/codespell.rb +108 -0
- data/spec/guard/codespell_spec.rb +96 -0
- data/spec/spec_helper.rb +16 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e7a0af7ae61248ca56109551b7278c033228e23862d3889d1963e5cee801a592
|
4
|
+
data.tar.gz: dc5bacdaddc4a71ce51c18611c8da4b77318fbaee078e1bbca5bb08f43573cde
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ec1dfccf2ee53e1f232b60a8f164d2c0e1b27a8f895a0f8dcd993facb7d18709a2dbcb3e92899dfc009515d3114699702b4bfdac0c56e56094f56a76d316b9e
|
7
|
+
data.tar.gz: '052190ab445dc4b81fe9bf04b4e31aefc671100efd49a65b03d43bb0109e64295bcd570df3fe42a4281eff1c505823b5b6828c3e7d5371d4179ff43b3e994693'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.6.6
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
SuggestExtensions: false
|
4
|
+
TargetRubyVersion: 2.6
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Exclude:
|
8
|
+
- 'spec/**/*.rb'
|
9
|
+
Style/StringLiterals:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
Style/StringLiteralsInInterpolation:
|
14
|
+
Enabled: true
|
15
|
+
EnforcedStyle: double_quotes
|
16
|
+
|
17
|
+
Layout/LineLength:
|
18
|
+
Max: 120
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [0.1.0] - Initial release - 2021-12-04
|
4
|
+
|
5
|
+
In this first release, we have a basic implementation of codespell in a guard environment.
|
6
|
+
|
7
|
+
The only available option for this version is to set the path to a [codespell config file](https://github.com/codespell-project/codespell#using-a-config-file) for the plugin to set the correct usage of codespell.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at guillaume.loubier@hooktstudios.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in guard-codespell.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rspec", "~> 3.0"
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem "guard-compat", require: false
|
13
|
+
gem "rubocop"
|
14
|
+
gem "rubocop-rspec"
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Guillaume Loubier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# guard::codespell
|
2
|
+
|
3
|
+
**guard-codespell** helps in keeping your code typo free by running [codespell](https://github.com/codespell-project/codespell) when files are modified
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Please make sure to have [Guard](https://github.com/guard/guard) and [codespell](https://github.com/codespell-project/codespell) installed before you start.
|
8
|
+
|
9
|
+
Add `guard-codespell` to your `Gemfile`.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
group :development do
|
13
|
+
gem 'guard-codespell'
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
and then execute:
|
18
|
+
|
19
|
+
```sh
|
20
|
+
$ bundle install
|
21
|
+
```
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
See guard documentation for how to [add a guard plugin](https://github.com/guard/guard#add-guard-plugins) and [how to use guard](https://github.com/guard/guard#usage).
|
25
|
+
|
26
|
+
## Configuration
|
27
|
+
|
28
|
+
Some configuration options are available to use with guard-codespell.
|
29
|
+
|
30
|
+
| Option | Type | Description |
|
31
|
+
| ----- | ----- | ----- |
|
32
|
+
| `all_on_start` | Boolean | Run codespell when starting guard |
|
33
|
+
| `config` | String | Path to a [codespell config file](https://github.com/codespell-project/codespell#using-a-config-file) |
|
34
|
+
| `debug` | Boolean | Show the codespell command that is used when guard-codespell runs |
|
35
|
+
| `only_git_changes` | Boolean | Only run codespell on files tracked by git (the result of `git status --porcelain` is used to create the list of files to check for errors. |
|
36
|
+
|
37
|
+
Here's an example on how to use those options in your Guardfile
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
guard :codespell, config: ".codespellrc", debug: true, only_git_changes: true do
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hooktstudios/guard-codespell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hooktstudios/guard-codespell/blob/master/CODE_OF_CONDUCT.md).
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
51
|
+
|
52
|
+
## Code of Conduct
|
53
|
+
|
54
|
+
Everyone interacting in the Guard::Codespell project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hooktstudios/guard-codespell/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "guard/codespell"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/guard/codespell/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "guard-codespell"
|
7
|
+
spec.version = Guard::CodespellVersion::VERSION
|
8
|
+
spec.authors = ["Guillaume Loubier"]
|
9
|
+
spec.email = ["guillaume.loubier@hooktstudios.com"]
|
10
|
+
|
11
|
+
spec.summary = "Guard plugin for codespell"
|
12
|
+
spec.description = "Guard::Codespell uses codespell to automatically look for typos in your codebase."
|
13
|
+
spec.homepage = "https://github.com/hooktstudios/guard-codespell"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/hooktstudios/guard-codespell"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/hooktstudios/guard-codespell/CHANGELOG.md"
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
21
|
+
|
22
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "guard", "~> 2.0"
|
28
|
+
spec.add_runtime_dependency "guard-compat", "~> 1.1"
|
29
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "guard/compat/plugin"
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
# Service that runs the codespell tool inside guard.
|
7
|
+
# Based on an example from the guard documentation https://github.com/guard/guard/wiki/Create-a-guard
|
8
|
+
class Codespell < Plugin
|
9
|
+
attr_reader :options, :codespell
|
10
|
+
|
11
|
+
# Initializes a Guard plugin.
|
12
|
+
# Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!
|
13
|
+
#
|
14
|
+
# @param [Hash] options the custom Guard plugin options
|
15
|
+
# @option options [Array<Guard::Watcher>] watchers the Guard plugin file watchers
|
16
|
+
# @option options [Symbol] group the group this Guard plugin belongs to
|
17
|
+
# @option options [Boolean] any_return allow any object to be returned from a watcher
|
18
|
+
def initialize(options = {})
|
19
|
+
super
|
20
|
+
@codespell = codespell_installed?
|
21
|
+
end
|
22
|
+
|
23
|
+
# Called once when Guard starts. Please override initialize method to init stuff.
|
24
|
+
#
|
25
|
+
# @raise [:task_has_failed] when start has failed
|
26
|
+
# @return [Object] the task result
|
27
|
+
def start
|
28
|
+
run_all if options[:all_on_start]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Called when just `enter` is pressed
|
32
|
+
# This method should be principally used for long action like running all specs/tests/...
|
33
|
+
#
|
34
|
+
# @raise [:task_has_failed] when run_all has failed
|
35
|
+
# @return [Object] the task result
|
36
|
+
def run_all
|
37
|
+
return warn_codespell_missing unless codespell
|
38
|
+
return run_codespell(changed_files) if options[:only_git_changes]
|
39
|
+
|
40
|
+
run_codespell
|
41
|
+
end
|
42
|
+
|
43
|
+
# Called on file(s) additions that the Guard plugin watches.
|
44
|
+
#
|
45
|
+
# @param [Array<String>] paths the changes files or paths
|
46
|
+
# @raise [:task_has_failed] when run_on_additions has failed
|
47
|
+
# @return [Object] the task result
|
48
|
+
def run_on_additions(paths)
|
49
|
+
return warn_codespell_missing unless codespell
|
50
|
+
|
51
|
+
run_codespell(paths)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Called on file(s) modifications that the Guard plugin watches.
|
55
|
+
#
|
56
|
+
# @param [Array<String>] paths the changes files or paths
|
57
|
+
# @raise [:task_has_failed] when run_on_modifications has failed
|
58
|
+
# @return [Object] the task result
|
59
|
+
def run_on_modifications(paths)
|
60
|
+
return warn_codespell_missing unless codespell
|
61
|
+
|
62
|
+
run_codespell(paths)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def run_codespell(paths = [])
|
68
|
+
Guard::Compat::UI.info "Looking for typos with codespell"
|
69
|
+
cmd = build_command(paths)
|
70
|
+
Guard::Compat::UI.info "... running #{cmd}" if options[:debug]
|
71
|
+
system(cmd)
|
72
|
+
Guard::Compat::UI.info "Codespell check finished"
|
73
|
+
end
|
74
|
+
|
75
|
+
def build_command(paths)
|
76
|
+
cmd = []
|
77
|
+
cmd << "codespell"
|
78
|
+
cmd << "--config=#{options[:config]}" if options[:config]
|
79
|
+
cmd << paths.join(" ") if paths.any?
|
80
|
+
|
81
|
+
cmd.join(" ")
|
82
|
+
end
|
83
|
+
|
84
|
+
def codespell_installed?
|
85
|
+
# Based on this script to check if an executable is present in PATH: https://stackoverflow.com/a/5471032
|
86
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
87
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
88
|
+
exts.each do |ext|
|
89
|
+
exe = File.join(path, "codespell#{ext}")
|
90
|
+
return true if File.executable?(exe) && !File.directory?(exe)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
def warn_codespell_missing
|
97
|
+
Guard::Compat::UI.warning "Spellcheck failed - guard-codespell cannot find the codespell library."
|
98
|
+
Guard::Compat::UI.warning "Please run `pip install codespell` to resolve this issue."
|
99
|
+
end
|
100
|
+
|
101
|
+
# Fetch a list of changed files from the result of git status
|
102
|
+
def changed_files
|
103
|
+
`git status --porcelain`.lines.map do |line|
|
104
|
+
line.chomp.split(" ").last
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "guard/compat/test/helper"
|
4
|
+
require "guard/codespell"
|
5
|
+
|
6
|
+
RSpec.describe Guard::Codespell do
|
7
|
+
subject(:guard) { described_class.new(options) }
|
8
|
+
|
9
|
+
let(:paths) { %w[path/to/foo.rb path/to/bar/baz.js] }
|
10
|
+
let(:options) { {} }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(guard).to receive(:run_codespell)
|
14
|
+
allow(Guard::Compat::UI).to receive(:info)
|
15
|
+
allow(Guard::Compat::UI).to receive(:warning)
|
16
|
+
end
|
17
|
+
|
18
|
+
shared_examples "a method calling run_codespell with specific paths" do
|
19
|
+
it "calls run_codespell with paths" do
|
20
|
+
guard.public_send(method, paths)
|
21
|
+
expect(guard).to have_received(:run_codespell).with(paths)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
shared_examples "a method call when codespell is not installed" do
|
26
|
+
it "returns a warning" do
|
27
|
+
guard.public_send(method, paths)
|
28
|
+
expect(guard).not_to have_received(:run_codespell)
|
29
|
+
expect(Guard::Compat::UI).to have_received(:warning).twice
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with codespell installed" do
|
34
|
+
before do
|
35
|
+
allow(guard).to receive(:codespell).and_return(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#run_all" do
|
39
|
+
it "calls run_codespell without any args" do
|
40
|
+
guard.run_all
|
41
|
+
expect(guard).to have_received(:run_codespell).with(no_args)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when only_git_changes option is set to true" do
|
45
|
+
let(:options) { { only_git_changes: true } }
|
46
|
+
|
47
|
+
it "calls run_codespell without any args" do
|
48
|
+
allow(guard).to receive(:changed_files).and_return(paths)
|
49
|
+
|
50
|
+
guard.run_all
|
51
|
+
expect(guard).to have_received(:run_codespell).with(paths)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#run_on_additions" do
|
57
|
+
let(:method) { :run_on_additions }
|
58
|
+
|
59
|
+
it_behaves_like "a method calling run_codespell with specific paths"
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#run_on_modifications" do
|
63
|
+
let(:method) { :run_on_modifications }
|
64
|
+
|
65
|
+
it_behaves_like "a method calling run_codespell with specific paths"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with codespell not installed" do
|
70
|
+
before do
|
71
|
+
allow(guard).to receive(:codespell).and_return(false)
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#run_all" do
|
75
|
+
let(:method) { :run_all }
|
76
|
+
|
77
|
+
it "returns a warning" do
|
78
|
+
guard.run_all
|
79
|
+
expect(guard).not_to have_received(:run_codespell)
|
80
|
+
expect(Guard::Compat::UI).to have_received(:warning).twice
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#run_on_additions" do
|
85
|
+
let(:method) { :run_on_additions }
|
86
|
+
|
87
|
+
it_behaves_like "a method call when codespell is not installed"
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#run_on_modifications" do
|
91
|
+
let(:method) { :run_on_modifications }
|
92
|
+
|
93
|
+
it_behaves_like "a method call when codespell is not installed"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "guard/compat/test/helper"
|
4
|
+
require "guard/codespell"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Enable flags like --only-failures and --next-failure
|
8
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
9
|
+
|
10
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-codespell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillaume Loubier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: guard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard-compat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
description: Guard::Codespell uses codespell to automatically look for typos in your
|
42
|
+
codebase.
|
43
|
+
email:
|
44
|
+
- guillaume.loubier@hooktstudios.com
|
45
|
+
executables:
|
46
|
+
- console
|
47
|
+
- setup
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".github/workflows/main.yml"
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rspec"
|
54
|
+
- ".rubocop.yml"
|
55
|
+
- CHANGELOG.md
|
56
|
+
- CODE_OF_CONDUCT.md
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/console
|
62
|
+
- bin/setup
|
63
|
+
- guard-codespell.gemspec
|
64
|
+
- lib/guard/codespell.rb
|
65
|
+
- lib/guard/codespell/version.rb
|
66
|
+
- spec/guard/codespell_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
homepage: https://github.com/hooktstudios/guard-codespell
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata:
|
72
|
+
homepage_uri: https://github.com/hooktstudios/guard-codespell
|
73
|
+
source_code_uri: https://github.com/hooktstudios/guard-codespell
|
74
|
+
changelog_uri: https://github.com/hooktstudios/guard-codespell/CHANGELOG.md
|
75
|
+
rubygems_mfa_required: 'true'
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '2.6'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.0.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Guard plugin for codespell
|
95
|
+
test_files:
|
96
|
+
- spec/guard/codespell_spec.rb
|
97
|
+
- spec/spec_helper.rb
|