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: 19364c10e5d63e6ebc62aa9546e77897e7c82d833da814696f2f02acaf08c0e9
4
- data.tar.gz: 9e2d299d10364d6bc76db71d8596b2b942ded8baa6954f90f515d3a7c73319dd
3
+ metadata.gz: b0a93b11d72346335618ba4ba38487e30b7b83c3a8460b11ad08987b903a5349
4
+ data.tar.gz: 3014b3bfda0207d5fecb14b0ba1dd421404e383b8ddcc3077bd5912f59063f60
5
5
  SHA512:
6
- metadata.gz: f41711a85eb37c414185c405a4dffd3325b6e172113362362e1176cfe151bfd941ebc535aa0202ce296e77f1f4871a1e161cdaa79022b1cde8797dd7db9d1c3d
7
- data.tar.gz: 21373c1b2a16ac6df0f8c5545ed93f1925295056e07618093bfbefc9ac0085398894d427b302a4bb2b3b01853b6aa4b877347c47fadb51863ff5e0f7be77594d
6
+ metadata.gz: 7b5c2b5b46aad5f54b6b7a84738eeba57f51e4e799150e9c197cb4ebb6e413ca5498635555b777b58dccad44f88195d968f0cc3d87400b2581c687cd1ccc4fc6
7
+ data.tar.gz: e7cbd3b2c198c11e4cdc91eb5ce057aea760e83292e116ba0bb6a50c737b84a9f811503ce4f84ee210f698008d661d7f372fb5b9302e79c02513a0e1264d8ecf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pry-byetypo (1.3.1)
4
+ pry-byetypo (1.3.2)
5
5
  pry (>= 0.13, < 0.15)
6
6
 
7
7
  GEM
@@ -8,7 +8,7 @@ class ExceptionsBase < Base
8
8
  include Setup::Store
9
9
 
10
10
  def call
11
- if corrected_word
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(klass).methods.map(&:to_s) # rubocop:disable Security/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.match(/for\s+(.*?):\w*$/)[1]
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Pry
4
4
  module Byetypo
5
- VERSION = "1.3.1"
5
+ VERSION = "1.3.2"
6
6
  end
7
7
  end
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.1
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-02 00:00:00.000000000 Z
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.22
109
+ rubygems_version: 3.4.19
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Autocorrects typos in your Pry console