spellr 0.7.1 → 0.8.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: 0f536be7fdf055e77cf278ccc2b4980da48bcbaae1d821bdf581df338c6ffa4e
4
- data.tar.gz: 8c33f240c847e4b9557f2c02c4804b8e1e375f65135c0f5801165fd9ce3fe53c
3
+ metadata.gz: 4d7433ea064065687e2295575e41d3a991bad67e3ad57602ef37fbbc19dcd91d
4
+ data.tar.gz: a242b9f1c85d00933a367924440d5c22ecc3c53c2f339c18e91393808d25f86d
5
5
  SHA512:
6
- metadata.gz: 9bed7f3fd56ca81cde5796ee61e96caeebe1e4bb0456d50ed9c3e7e34ab794f10130a13b668ee8c9eb175d5f5a8c63defc7c308fed3d6e2f79e431a396419839
7
- data.tar.gz: 7ac9605ef35b4e66c98c919102098e3e59c901a3f019674254c00c2769cb1f852878e00bba9c60ce666ce891aaa848b63d94ec8efd3607498b91801acaa573d6
6
+ metadata.gz: 76ee40dd1f2c4ad6cba3a1db28966bc84e0e6910a994bcf58840135eef8d1043f14bfd0f0151ae9f770633ec8d878d2984dc3e235013766a877ca88f250d5c5d
7
+ data.tar.gz: fc2fb0f38d1513a24cd2e33d5175f35eb7bdbb72f37d2c97c6e2ef6ef0ae3efc6cdbee41938c5c836a9d5af6536c057c0c5ed0b17ab4179c363781255554473d
@@ -1,3 +1,6 @@
1
+ # v0.8.0
2
+ - add the ability to use spellr as a rake task
3
+
1
4
  # v0.7.1
2
5
  - relax fast_ignore requirement
3
6
 
@@ -6,7 +9,6 @@
6
9
  - require fast_ignore 0.6.0
7
10
  - new interactive UI
8
11
  - misc performance improvements
9
- - drop ruby 2.4 support because simplecov does
10
12
 
11
13
  # v0.6.0
12
14
  - add CSS wordlist from MDN
data/README.md CHANGED
@@ -229,11 +229,79 @@ languages:
229
229
  # this file will match even if it doesn't otherwise match the includes pattern.
230
230
  ```
231
231
 
232
+ If you want a file to have a file-specific wordlist:
233
+ e.g. for terms specific to logstash:
234
+ ```yml
235
+ languages:
236
+ logstash: # this can be anything
237
+ includes:
238
+ - path/to/logstash/file
239
+ ```
240
+
241
+ ## Rake and Travis
242
+
243
+ Create or open a file in the root of your project named `Rakefile`.
244
+ adding the following lines
245
+ ```ruby
246
+ # Rakefile
247
+ require 'spellr/rake_task'
248
+ Spellr::RakeTask.generate_task
249
+ ```
250
+
251
+ This will add the `rake spellr` task. To provide arguments like the cli, use square brackets. (ensure you escape the `[]` if you're using zsh)
252
+ `rake 'spellr[--interactive]'`
253
+
254
+ To have this automatically run on travis, add `:spellr` to the default task.
255
+ ```ruby
256
+ # Rakefile
257
+ require 'spellr/rake_task'
258
+ Spellr::RakeTask.generate_task
259
+
260
+ task :default, :spellr
261
+ ```
262
+ or if you already have :default task, add :spellr to the array.
263
+ ```ruby
264
+ require 'spellr/rake_task'
265
+ Spellr::RakeTask.generate_task
266
+
267
+ task :default, [:spec, :spellr]
268
+ ```
269
+ or etc.
270
+
271
+ Also follow the travis documentation to have travis run rake:
272
+ ```yml
273
+ # .travis.yml
274
+ sudo: false
275
+ language: ruby
276
+ cache: bundler
277
+ rvm:
278
+ - 2.5
279
+ before_install: gem install bundler
280
+ ```
281
+
282
+ To provide default cli arguments, the first argument is the name, and subsequent arguments are the cli arguments.
283
+ ```ruby
284
+ # Rakefile
285
+ require 'spellr/rake_task'
286
+ Spellr::RakeTask.generate_task(:spellr_quiet, '--quiet')
287
+
288
+ task :default, :spellr_quiet
289
+ ```
290
+ or `rake spellr` will be in interactive mode unless the CI env variable is set.
291
+ ```ruby
292
+ # Rakefile
293
+ require 'spellr/rake_task'
294
+ spellr_arguments = ENV['CI'] ? [] : ['--interactive']
295
+ Spellr::RakeTask.generate_task(:spellr, **spellr_arguments)
296
+
297
+ task :default, :spellr
298
+ ```
299
+
232
300
  ## Development
233
301
 
234
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
302
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
235
303
 
236
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
304
+ To install this gem onto your local machine, run `bundle exec rake install`.
237
305
 
238
306
  ## Contributing
239
307
 
data/exe/spellr CHANGED
@@ -3,10 +3,4 @@
3
3
 
4
4
  require_relative '../lib/spellr/cli'
5
5
 
6
- begin
7
- Spellr::CLI.new(ARGV).check
8
- rescue Spellr::Error => e
9
- require_relative '../lib/spellr/string_format'
10
- warn Spellr::StringFormat.red(e.message)
11
- exit 1
12
- end
6
+ Spellr::CLI.new(ARGV)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative '../spellr'
4
4
  require_relative 'cli_options'
5
+ require_relative 'string_format'
5
6
 
6
7
  module Spellr
7
8
  class CLI
@@ -10,10 +11,18 @@ module Spellr
10
11
  def initialize(argv)
11
12
  @argv = argv
12
13
  CLI::Options.parse(@argv)
13
- Spellr.config.valid?
14
+ check
15
+ rescue Spellr::Error => e
16
+ exit_with_error(e.message)
17
+ end
18
+
19
+ def exit_with_error(message)
20
+ warn Spellr::StringFormat.red(message)
21
+ exit 1
14
22
  end
15
23
 
16
24
  def check
25
+ Spellr.config.valid?
17
26
  checker = Spellr.config.checker.new(files: files)
18
27
  checker.check
19
28
 
@@ -15,7 +15,7 @@ module Spellr
15
15
  validate :keys_are_single_characters
16
16
 
17
17
  def valid?
18
- raise Spellr::Config::Invalid, errors.join("\n") unless super
18
+ raise ::Spellr::Config::Invalid, errors.join("\n") unless super
19
19
  end
20
20
 
21
21
  def interactive_is_interactive # rubocop:disable Metrics/MethodLength
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+ require 'spellr/cli'
5
+ require 'shellwords'
6
+
7
+ module Spellr
8
+ class RakeTask
9
+ include ::Rake::DSL
10
+
11
+ def self.generate_task(name = :spellr, *default_argv) # rubocop:disable
12
+ new(name, default_argv)
13
+
14
+ name
15
+ end
16
+
17
+ def initialize(name, default_argv)
18
+ @name = name
19
+ @default_argv = default_argv
20
+
21
+ describe_task
22
+ define_task
23
+ end
24
+
25
+ private
26
+
27
+ def escaped_argv(argv = @default_argv)
28
+ return if argv.empty?
29
+
30
+ Shellwords.shelljoin(argv)
31
+ end
32
+
33
+ def describe_task
34
+ return desc('Run spellr') if @default_argv.empty?
35
+
36
+ desc("Run spellr (default args: #{escaped_argv})")
37
+ end
38
+
39
+ def define_task
40
+ task(@name, :'*args') do |_, task_argv|
41
+ argv = argv_or_default(task_argv)
42
+ write_cli_cmd(argv)
43
+ run(argv)
44
+ end
45
+ end
46
+
47
+ def write_cli_cmd(argv)
48
+ $stdout.puts("\e[2mspellr #{escaped_argv(argv)}\e[0m")
49
+ end
50
+
51
+ def run(argv)
52
+ Spellr::CLI.new(argv)
53
+ rescue SystemExit => e
54
+ raise unless e.status == 0
55
+ end
56
+
57
+ def argv_or_default(task_argv)
58
+ task_argv = task_argv.to_a.compact
59
+ task_argv.empty? ? @default_argv : task_argv
60
+ end
61
+ end
62
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spellr
4
- VERSION = '0.7.1'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spellr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2020-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -248,6 +248,7 @@ files:
248
248
  - lib/spellr/output.rb
249
249
  - lib/spellr/output_stubbed.rb
250
250
  - lib/spellr/quiet_reporter.rb
251
+ - lib/spellr/rake_task.rb
251
252
  - lib/spellr/reporter.rb
252
253
  - lib/spellr/string_format.rb
253
254
  - lib/spellr/token.rb