spellr 0.8.0 → 0.8.1

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
2
  SHA256:
3
- metadata.gz: 4d7433ea064065687e2295575e41d3a991bad67e3ad57602ef37fbbc19dcd91d
4
- data.tar.gz: a242b9f1c85d00933a367924440d5c22ecc3c53c2f339c18e91393808d25f86d
3
+ metadata.gz: 0e045b4e7f76fa43573c0e28564a4f532dbcc9b35f05ca682e7302274ce0bdbc
4
+ data.tar.gz: 2918d1f1c2a41c681dc7370180ead18a63a86f991032140f0dea1ac92faad3b0
5
5
  SHA512:
6
- metadata.gz: 76ee40dd1f2c4ad6cba3a1db28966bc84e0e6910a994bcf58840135eef8d1043f14bfd0f0151ae9f770633ec8d878d2984dc3e235013766a877ca88f250d5c5d
7
- data.tar.gz: fc2fb0f38d1513a24cd2e33d5175f35eb7bdbb72f37d2c97c6e2ef6ef0ae3efc6cdbee41938c5c836a9d5af6536c057c0c5ed0b17ab4179c363781255554473d
6
+ metadata.gz: d44c69a61badacc0a792f2ec60794847ea722101fc46e5fdce717562e2f3923ce6d95624af75d6c31e4cdcf2e6b017aaa7aa87c28a3f3b3761591658fcea6770
7
+ data.tar.gz: a607bcdf971179b58c7a1fc4fbf433ef4312724910c74f3731dd5df1127ccc2c9059d836564f00456656d19dfad39b62707663baffd1349bb93352a20f83f9b8
@@ -1,3 +1,6 @@
1
+ # v0.8.1
2
+ - use refinements for backports so that RakeTask doesn't conflict with Rubocop::RakeTask
3
+
1
4
  # v0.8.0
2
5
  - add the ability to use spellr as a rake task
3
6
 
data/README.md CHANGED
@@ -257,14 +257,14 @@ To have this automatically run on travis, add `:spellr` to the default task.
257
257
  require 'spellr/rake_task'
258
258
  Spellr::RakeTask.generate_task
259
259
 
260
- task :default, :spellr
260
+ task default: :spellr
261
261
  ```
262
262
  or if you already have :default task, add :spellr to the array.
263
263
  ```ruby
264
264
  require 'spellr/rake_task'
265
265
  Spellr::RakeTask.generate_task
266
266
 
267
- task :default, [:spec, :spellr]
267
+ task default: [:spec, :spellr]
268
268
  ```
269
269
  or etc.
270
270
 
@@ -285,7 +285,7 @@ To provide default cli arguments, the first argument is the name, and subsequent
285
285
  require 'spellr/rake_task'
286
286
  Spellr::RakeTask.generate_task(:spellr_quiet, '--quiet')
287
287
 
288
- task :default, :spellr_quiet
288
+ task default: :spellr_quiet
289
289
  ```
290
290
  or `rake spellr` will be in interactive mode unless the CI env variable is set.
291
291
  ```ruby
@@ -294,7 +294,7 @@ require 'spellr/rake_task'
294
294
  spellr_arguments = ENV['CI'] ? [] : ['--interactive']
295
295
  Spellr::RakeTask.generate_task(:spellr, **spellr_arguments)
296
296
 
297
- task :default, :spellr
297
+ task default: :spellr
298
298
  ```
299
299
 
300
300
  ## Development
@@ -1,58 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby_version = Gem::Version.new(RUBY_VERSION)
4
-
5
- unless ruby_version >= Gem::Version.new('2.5')
6
- class Hash
7
- def slice!(*keys)
8
- delete_if { |k| !keys.include?(k) }
9
- end
3
+ module Spellr
4
+ ruby_version = Gem::Version.new(RUBY_VERSION)
5
+ unless ruby_version >= Gem::Version.new('2.5')
6
+ module HashSlice
7
+ refine Hash do
8
+ def slice!(*keys)
9
+ delete_if { |k| !keys.include?(k) }
10
+ end
10
11
 
11
- def slice(*keys)
12
- dup.slice!(*keys)
12
+ def slice(*keys)
13
+ dup.slice!(*keys)
14
+ end
15
+ end
13
16
  end
14
- end
15
17
 
16
- require 'yaml'
17
- module YAML
18
- class << self
19
- alias_method :safe_load_without_symbolize_names, :safe_load
20
- def safe_load(path, *args, symbolize_names: false, **kwargs)
21
- if symbolize_names
22
- symbolize_names!(safe_load_without_symbolize_names(path, *args, **kwargs))
23
- else
24
- safe_load_without_symbolize_names(path, *args, **kwargs)
18
+ require 'yaml'
19
+ module YAMLSymbolizeNames
20
+ refine YAML.singleton_class do
21
+ alias_method :safe_load_without_symbolize_names, :safe_load
22
+ def safe_load(path, *args, symbolize_names: false, **kwargs)
23
+ if symbolize_names
24
+ symbolize_names!(safe_load_without_symbolize_names(path, *args, **kwargs))
25
+ else
26
+ safe_load_without_symbolize_names(path, *args, **kwargs)
27
+ end
25
28
  end
26
- end
27
29
 
28
- private
30
+ private
29
31
 
30
- def symbolize_names!(obj) # rubocop:disable Metrics/MethodLength
31
- case obj
32
- when Hash
33
- obj.keys.each do |key| # rubocop:disable Style/HashEachMethods # each_key never finishes.
34
- obj[key.to_sym] = symbolize_names!(obj.delete(key))
32
+ def symbolize_names!(obj) # rubocop:disable Metrics/MethodLength
33
+ case obj
34
+ when Hash
35
+ obj.keys.each do |key| # rubocop:disable Style/HashEachMethods # each_key never finishes.
36
+ obj[key.to_sym] = symbolize_names!(obj.delete(key))
37
+ end
38
+ when Array
39
+ obj.map! { |ea| symbolize_names!(ea) }
35
40
  end
36
- when Array
37
- obj.map! { |ea| symbolize_names!(ea) }
41
+ obj
38
42
  end
39
- obj
40
43
  end
41
44
  end
42
45
  end
43
- end
44
46
 
45
- # all this to avoid a deprecation warning
46
- unless ruby_version >= Gem::Version.new('2.6')
47
- require 'yaml'
48
- module YAML
49
- class << self
50
- alias_method :safe_load_without_permitted_classes, :safe_load
51
- def safe_load(path, *args, permitted_classes: nil, **kwargs)
52
- if permitted_classes
53
- safe_load_without_permitted_classes(path, permitted_classes, *args, **kwargs)
54
- else
55
- safe_load_without_permitted_classes(path, *args, **kwargs)
47
+ unless ruby_version >= Gem::Version.new('2.6')
48
+ require 'yaml'
49
+ module YAMLPermittedClasses
50
+ refine YAML.singleton_class do
51
+ alias_method :safe_load_without_permitted_classes, :safe_load
52
+ def safe_load(path, *args, permitted_classes: nil, **kwargs)
53
+ if permitted_classes
54
+ safe_load_without_permitted_classes(path, permitted_classes, *args, **kwargs)
55
+ else
56
+ safe_load_without_permitted_classes(path, *args, **kwargs)
57
+ end
56
58
  end
57
59
  end
58
60
  end
@@ -5,6 +5,10 @@ require_relative 'backports'
5
5
 
6
6
  module Spellr
7
7
  class ConfigLoader
8
+ # :nocov:
9
+ using ::Spellr::YAMLSymbolizeNames if defined?(::Spellr::YAMLSymbolizeNames)
10
+ # :nocov:
11
+
8
12
  attr_reader :config_file
9
13
 
10
14
  def initialize(config_file = ::File.join(Dir.pwd, '.spellr.yml'))
@@ -7,6 +7,10 @@ require 'yaml'
7
7
  # https://www.sitepoint.com/machine-learning-ruby-naive-bayes-theorem/
8
8
 
9
9
  class NaiveBayes
10
+ # :nocov:
11
+ using ::Spellr::YAMLPermittedClasses if defined?(::Spellr::YAMLPermittedClasses)
12
+ # :nocov:
13
+
10
14
  YAML_PATH = File.join(__dir__, 'data.yml')
11
15
 
12
16
  attr_reader :feature_set
@@ -4,6 +4,9 @@ require_relative 'stats'
4
4
  require_relative '../backports'
5
5
 
6
6
  class PossibleKey # rubocop:disable Metrics/ClassLength
7
+ # :nocov:
8
+ using ::Spellr::HashSlice if defined?(::Spellr::HashSlice)
9
+ # :nocov:
7
10
  include Stats
8
11
 
9
12
  VOWELS = %i{
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spellr
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spellr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson