pry-byetypo 1.3.1 → 1.3.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a93b11d72346335618ba4ba38487e30b7b83c3a8460b11ad08987b903a5349
|
4
|
+
data.tar.gz: 3014b3bfda0207d5fecb14b0ba1dd421404e383b8ddcc3077bd5912f59063f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5c2b5b46aad5f54b6b7a84738eeba57f51e4e799150e9c197cb4ebb6e413ca5498635555b777b58dccad44f88195d968f0cc3d87400b2581c687cd1ccc4fc6
|
7
|
+
data.tar.gz: e7cbd3b2c198c11e4cdc91eb5ce057aea760e83292e116ba0bb6a50c737b84a9f811503ce4f84ee210f698008d661d7f372fb5b9302e79c02513a0e1264d8ecf
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ class ExceptionsBase < Base
|
|
8
8
|
include Setup::Store
|
9
9
|
|
10
10
|
def call
|
11
|
-
if
|
11
|
+
if can_correct?
|
12
12
|
logger.error("\e[1;31m#{exception}\e[0m")
|
13
13
|
logger.info("\e[1;32mRunning: #{corrected_cmd}\e[0m")
|
14
14
|
|
@@ -28,6 +28,14 @@ class ExceptionsBase < Base
|
|
28
28
|
@pry = pry
|
29
29
|
end
|
30
30
|
|
31
|
+
def can_correct?
|
32
|
+
error_from_typo? && dictionary && corrected_word
|
33
|
+
end
|
34
|
+
|
35
|
+
def error_from_typo?
|
36
|
+
last_cmd.include?(unknown_from_exception)
|
37
|
+
end
|
38
|
+
|
31
39
|
def corrected_word
|
32
40
|
@corrected_word ||= spell_checker.correct(unknown_from_exception).first
|
33
41
|
end
|
@@ -15,7 +15,7 @@ module Exceptions
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def dictionary
|
18
|
-
eval(
|
18
|
+
eval(infer_klass).methods.map(&:to_s) # rubocop:disable Security/Eval
|
19
19
|
end
|
20
20
|
|
21
21
|
def exception_regexp
|
@@ -23,7 +23,17 @@ module Exceptions
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def klass
|
26
|
-
exception.to_s.
|
26
|
+
exception_without_class_module = exception.to_s.gsub(":Class", "")
|
27
|
+
exception_without_class_module.split.last
|
28
|
+
end
|
29
|
+
|
30
|
+
# [].methods and Array.methods have a different output.
|
31
|
+
# Array class is a part of the Ruby core library while `[]` is an instance of the Array class.
|
32
|
+
# When calling [].methods, we inspect the methods available to instances of the Array class, including those inherited from its class and ancestors.
|
33
|
+
def infer_klass
|
34
|
+
return klass if klass != "Array"
|
35
|
+
|
36
|
+
"[]"
|
27
37
|
end
|
28
38
|
end
|
29
39
|
end
|
data/lib/pry-byetypo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-byetypo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clément Morisset
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.4.
|
109
|
+
rubygems_version: 3.4.19
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Autocorrects typos in your Pry console
|