pry-byetypo 1.0.2 → 1.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +64 -23
- data/lib/pry-byetypo/constants/errors.rb +7 -0
- data/lib/pry-byetypo/exceptions/exceptions_base.rb +10 -5
- data/lib/pry-byetypo/exceptions/name_error/handler.rb +34 -0
- data/lib/pry-byetypo/exceptions/name_error/undefined_variable.rb +36 -0
- data/lib/pry-byetypo/exceptions/name_error/uninitialized_constant.rb +27 -0
- data/lib/pry-byetypo/exceptions_handler.rb +6 -13
- data/lib/pry-byetypo/session/clear_history.rb +21 -0
- data/lib/pry-byetypo/session/populate_history.rb +43 -0
- data/lib/pry-byetypo/setup/application_dictionary.rb +17 -3
- data/lib/pry-byetypo/version.rb +1 -1
- data/lib/pry-byetypo.rb +13 -4
- metadata +8 -3
- data/lib/pry-byetypo/exceptions/name_error.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffd46e3838ed0c8d43e5aa5c3fc5a38c518d90a4dbefcbba09f1629fffe72260
|
4
|
+
data.tar.gz: cef94f7e070bc541cedc9f2a547a9dc2901b8bf2ca96b4cfda09f5ffef890381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61e7d2eb327d7a3905eb882288260484d42497bfe895a98a72bbccf562d9905ede28becb9b9c2da9e71c537967f8621299d364b97f442869d98f551a4b5073a4
|
7
|
+
data.tar.gz: 86252b1586e787a3f3e3ac6a66c13034640eba983a2d0d8a8be95f239906fef4611f9c00fcf17c675030b03ab512605dc1e87436ef9eaea7d261675a2cc03845
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,24 +2,27 @@
|
|
2
2
|
|
3
3
|
Autocorrects typos in your Pry console.
|
4
4
|
|
5
|
-
This small Pry plugin captures exceptions that
|
5
|
+
This small Pry plugin captures exceptions that may arise from typos and deduces the correct command based on your database information and session history.
|
6
6
|
|
7
7
|
#### Before
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
[1] pry(main)>
|
11
|
-
|
12
|
-
|
10
|
+
[1] pry(main)> result = 1
|
11
|
+
=> 1
|
12
|
+
[2] pry(main)> resilt
|
13
|
+
NameError: undefined local variable or method `resilt' for main:Object
|
14
|
+
from (pry):2:in `__pry__'
|
13
15
|
```
|
14
16
|
|
15
17
|
#### After
|
16
18
|
|
17
19
|
```ruby
|
18
|
-
[1] pry(main)>
|
19
|
-
|
20
|
-
|
21
|
-
2024-01-
|
22
|
-
|
20
|
+
[1] pry(main)> result = 1
|
21
|
+
=> 1
|
22
|
+
[2] pry(main)> resilt
|
23
|
+
E, [2024-01-31T17:11:16.344161 #3739] ERROR -- : undefined local variable or method `resilt' for main:Object
|
24
|
+
I, [2024-01-31T17:11:16.344503 #3739] INFO -- : Running: result
|
25
|
+
=> 1
|
23
26
|
```
|
24
27
|
|
25
28
|
> [!NOTE]
|
@@ -46,24 +49,59 @@ gem install pry-byetypo
|
|
46
49
|
2. Start your daily work.
|
47
50
|
3. Let `pry-byetypo` remove frictions. 🚀
|
48
51
|
|
49
|
-
##
|
50
|
-
|
51
|
-
### 1. Byetypo dictionary
|
52
|
+
## Byetypo dictionary
|
52
53
|
|
53
|
-
When you open a new Pry console, the gem will generate a `byetypo_dictionary.pstore` file containing
|
54
|
+
When you open a new Pry console, the gem will generate a `byetypo_dictionary.pstore` file containing four pieces of information:
|
54
55
|
|
55
56
|
- A list of the ActiveRecord models in your application (e.g. `User`, `Account`).
|
56
57
|
- A list of the ActiveRecord associations in your application (e.g. `user`, `users`, `account`, `accounts`).
|
58
|
+
- Unique identifiers for each active Pry instance, populated with the variable history of the current session. (e.g. `result = 1` will store `result`)
|
57
59
|
- A timestamp representing the last time the `byetypo_dictionary` was updated. (by default updated every week).
|
58
60
|
|
59
61
|
This file is generated at the root of your application by default. If you want to update its location, you can configure the path by adding a `BYETYPO_STORE_PATH` entry in your `.env` file.
|
60
62
|
|
61
|
-
|
63
|
+
## Captured exceptions
|
64
|
+
|
65
|
+
### NameError - undefined local variable or method
|
66
|
+
|
67
|
+
This error occurs when you mispelled a variable in your REPL. The gem will catch that exception and will try find the closest matches. If so, it will run the command with the (potential) corrected variable.
|
68
|
+
|
69
|
+
##### Before
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
[1] pry(main)> result = 1
|
73
|
+
=> 1
|
74
|
+
[2] pry(main)> resilt
|
75
|
+
NameError: undefined local variable or method `resilt' for main:Object
|
76
|
+
from (pry):2:in `__pry__'
|
77
|
+
```
|
78
|
+
|
79
|
+
##### After
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
[1] pry(main)> result = 1
|
83
|
+
=> 1
|
84
|
+
[2] pry(main)> resilt
|
85
|
+
E, [2024-01-31T17:11:16.344161 #3739] ERROR -- : undefined local variable or method `resilt' for main:Object
|
86
|
+
I, [2024-01-31T17:11:16.344503 #3739] INFO -- : Running: result
|
87
|
+
=> 1
|
88
|
+
```
|
62
89
|
|
63
|
-
|
90
|
+
### NameError - uninitialized constant
|
64
91
|
|
65
92
|
This error occurs when you mispelled a model in your REPL. The gem will catch that exception and will try find the closest matches. If so, it will run the command with the (potential) corrected model.
|
66
93
|
|
94
|
+
##### Before
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
[2] pry(main)> Usert.last
|
98
|
+
NameError: uninitialized constant Usert
|
99
|
+
from (pry):2:in `__pry__'
|
100
|
+
[3] pry(main)>
|
101
|
+
```
|
102
|
+
|
103
|
+
##### After
|
104
|
+
|
67
105
|
```ruby
|
68
106
|
[1] pry(main)> Usert.last
|
69
107
|
I, [2024-01-13T20:00:16.280710 #694] ERROR -- : uninitialized constant Usert
|
@@ -71,19 +109,19 @@ I, [2024-01-13T20:00:16.281237 #694] INFO -- : Running: User.last
|
|
71
109
|
=> #<User id: 1, email: "yo@email.com">
|
72
110
|
```
|
73
111
|
|
74
|
-
|
112
|
+
### ActiveRecord::ConfigurationError
|
75
113
|
|
76
114
|
Raised when association is being configured improperly or user tries to use offset and limit together with `ActiveRecord::Base.has_many` or `ActiveRecord::Base.has_and_belongs_to_many` associations.
|
115
|
+
This plugin will look into the `byetypo_dictionary` file to find the closest match and run the correct query.
|
77
116
|
|
78
|
-
|
117
|
+
##### Before
|
79
118
|
|
80
119
|
```ruby
|
81
120
|
[6] pry(main)> User.joins(:group).where(groups: { name: "Landlord" }).last
|
82
121
|
ActiveRecord::ConfigurationError: Can't join 'User' to association named 'group'; perhaps you misspelled it?
|
83
122
|
```
|
84
123
|
|
85
|
-
|
86
|
-
|
124
|
+
##### After
|
87
125
|
|
88
126
|
```ruby
|
89
127
|
[1] pry(main)> User.joins(:group).where(groups: { name: "Landlord" })
|
@@ -93,9 +131,12 @@ I, [2024-01-13T22:45:16.297972 #1079] INFO -- : Running: User.joins(:groups).wh
|
|
93
131
|
=> []
|
94
132
|
```
|
95
133
|
|
96
|
-
|
134
|
+
### ActiveRecord::StatementInvalid
|
97
135
|
|
98
136
|
The query attempts to reference columns or conditions related to a table, but the table is not properly included in the FROM clause.
|
137
|
+
This plugin will look into the `byetypo_dictionary` file to find the closest match and run the correct query.
|
138
|
+
|
139
|
+
##### Before
|
99
140
|
|
100
141
|
```ruby
|
101
142
|
[1] pry(main)> User.joins(:groups).where(grous: { name: "Landlord" }).last
|
@@ -103,7 +144,7 @@ ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause
|
|
103
144
|
LINE 1: ..."group_id" WHERE "users"."deleted_at" IS NULL AND "grous"."n...
|
104
145
|
```
|
105
146
|
|
106
|
-
|
147
|
+
##### After
|
107
148
|
|
108
149
|
```ruby
|
109
150
|
1] pry(main)> User.joins(:groups).where(grous: { name: "Landlord" }).last
|
@@ -116,11 +157,11 @@ I, [2024-01-14T23:50:49.273177 #1248] INFO -- : Running: User.joins(:groups).wh
|
|
116
157
|
|
117
158
|
Pry-byetypo is linked to your development database. During initialization, it will attempt to establish a connection to retrieve the tables available in your project. It will fetch the information for the development environment from the `database.yml` file.
|
118
159
|
|
119
|
-
|
160
|
+
#### Unreadable database URL (URI::InvalidURIError)
|
120
161
|
|
121
162
|
If the database connection string is not readable, the gem will be unable to establish a connection. If you encounter such an issue, make sure to add a `DATABASE_URL` variable to your `.env` file with the easily readable URL of your database.
|
122
163
|
|
123
|
-
|
164
|
+
#### Unreadable connection pool (ActiveRecord::ConnectionTimeoutError)
|
124
165
|
|
125
166
|
If the number of connections in your pool is not readable, you may encounter an `ActiveRecord::ConnectionTimeoutError`. If you experience this issue, make sure to add a `DATABASE_POOL` variable to your `.env` file.
|
126
167
|
|
@@ -1,17 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "logger"
|
4
|
+
require "colorize"
|
3
5
|
require_relative "../base"
|
4
6
|
require_relative "../setup/store"
|
5
|
-
require "colorize"
|
6
7
|
|
7
8
|
class ExceptionsBase < Base
|
8
9
|
include Setup::Store
|
9
10
|
|
10
11
|
def call
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
if corrected_word
|
13
|
+
logger.error(exception.to_s.colorize(color: :light_red, mode: :bold))
|
14
|
+
logger.info("Running: #{corrected_cmd}".colorize(color: :green, mode: :bold))
|
15
|
+
|
16
|
+
pry.eval(corrected_cmd)
|
17
|
+
else
|
18
|
+
Pry::ExceptionHandler.handle_exception(output, exception, pry)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
private
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../exceptions_base"
|
4
|
+
require_relative "../../constants/errors"
|
5
|
+
require_relative "uninitialized_constant"
|
6
|
+
require_relative "undefined_variable"
|
7
|
+
|
8
|
+
module Exceptions
|
9
|
+
module NameError
|
10
|
+
class Handler < ExceptionsBase
|
11
|
+
attr_reader :exception, :output, :pry
|
12
|
+
|
13
|
+
def initialize(output, exception, pry)
|
14
|
+
@output = output
|
15
|
+
@exception = exception
|
16
|
+
@pry = pry
|
17
|
+
end
|
18
|
+
|
19
|
+
# FIXME: https://github.com/rubocop/rubocop-performance/issues/438
|
20
|
+
# rubocop:disable Performance/ConstantRegexp
|
21
|
+
def call
|
22
|
+
case exception.message
|
23
|
+
in /#{Constants::Errors::UNINITIALIZED_CONSTANT}/
|
24
|
+
UninitializedConstant.call(output, exception, pry)
|
25
|
+
in /#{Constants::Errors::UNDEFINED_VARIABLE}/
|
26
|
+
UndefinedVariable.call(output, exception, pry)
|
27
|
+
else
|
28
|
+
Pry::ExceptionHandler.handle_exception(output, exception, pry)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
# rubocop:enable Performance/ConstantRegexp
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../exceptions_base"
|
4
|
+
|
5
|
+
module Exceptions
|
6
|
+
module NameError
|
7
|
+
class UndefinedVariable < ExceptionsBase
|
8
|
+
private
|
9
|
+
|
10
|
+
def corrected_word
|
11
|
+
@corrected_word ||= spell_checker(session_dictionary).correct(unknown_from_exception).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def corrected_cmd
|
15
|
+
@corrected_cmd ||= last_cmd.gsub(/\b#{unknown_from_exception}\b/, corrected_word)
|
16
|
+
end
|
17
|
+
|
18
|
+
def unknown_from_exception
|
19
|
+
exception.to_s.match(exception_regexp)[1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def session_dictionary
|
23
|
+
@session_dictionary ||= store.transaction { |s| s[pry_instance_uid] }
|
24
|
+
end
|
25
|
+
|
26
|
+
def exception_regexp
|
27
|
+
/`(\w+)'/
|
28
|
+
end
|
29
|
+
|
30
|
+
# Use the current binding identifier as pry instance uid.
|
31
|
+
def pry_instance_uid
|
32
|
+
pry.current_binding.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../exceptions_base"
|
4
|
+
|
5
|
+
module Exceptions
|
6
|
+
module NameError
|
7
|
+
class UninitializedConstant < ExceptionsBase
|
8
|
+
private
|
9
|
+
|
10
|
+
def unknown_from_exception
|
11
|
+
exception.to_s.split.last
|
12
|
+
end
|
13
|
+
|
14
|
+
def corrected_word
|
15
|
+
@corrected_word ||= spell_checker(ar_models_dictionary).correct(unknown_from_exception).first
|
16
|
+
end
|
17
|
+
|
18
|
+
def corrected_cmd
|
19
|
+
@corrected_cmd ||= last_cmd.gsub(unknown_from_exception, corrected_word)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ar_models_dictionary
|
23
|
+
@ar_models_dictionary ||= store.transaction { |s| s["active_record_models"] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,14 +3,12 @@
|
|
3
3
|
require_relative "base"
|
4
4
|
require_relative "exceptions/active_record/statement_invalid"
|
5
5
|
require_relative "exceptions/active_record/configuration_error"
|
6
|
-
require_relative "exceptions/name_error"
|
6
|
+
require_relative "exceptions/name_error/handler"
|
7
|
+
require_relative "constants/errors"
|
7
8
|
|
8
9
|
class ExceptionsHandler < Base
|
9
10
|
attr_reader :exception, :output, :pry
|
10
11
|
|
11
|
-
UNINITIALIZED_CONSTANT = "uninitialized constant"
|
12
|
-
UNDEFINED_TABLE = "UndefinedTable"
|
13
|
-
|
14
12
|
def initialize(output, exception, pry)
|
15
13
|
@output = output
|
16
14
|
@exception = exception
|
@@ -19,20 +17,15 @@ class ExceptionsHandler < Base
|
|
19
17
|
|
20
18
|
def call
|
21
19
|
case exception
|
22
|
-
in NameError
|
23
|
-
# eg: Usert.last
|
20
|
+
in NameError
|
24
21
|
# NameError is a Superclass for all undefined statement.
|
25
|
-
|
26
|
-
|
27
|
-
Exceptions::NameError.call(output, exception, pry)
|
28
|
-
in ActiveRecord::StatementInvalid => error
|
29
|
-
# eg: User.joins(:groups).where(grous: { name: "Landlord" }).last
|
22
|
+
Exceptions::NameError::Handler.call(output, exception, pry)
|
23
|
+
in ActiveRecord::StatementInvalid
|
30
24
|
# ActiveRecord::StatementInvalid is a Superclass for all database execution errors.
|
31
25
|
# We only need to one including an `UndefinedTable` error.
|
32
|
-
return pry_exception_handler unless
|
26
|
+
return pry_exception_handler unless exception.message.include?(Constants::Errors::UNDEFINED_TABLE)
|
33
27
|
Exceptions::ActiveRecord::StatementInvalid.call(output, exception, pry)
|
34
28
|
in ActiveRecord::ConfigurationError
|
35
|
-
# eg: User.joins(:group).where(groups: { name: "Landlord" }).last
|
36
29
|
Exceptions::ActiveRecord::ConfigurationError.call(output, exception, pry)
|
37
30
|
else
|
38
31
|
pry_exception_handler
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../base"
|
4
|
+
require_relative "../setup/store"
|
5
|
+
|
6
|
+
module Session
|
7
|
+
class ClearHistory < Base
|
8
|
+
include Setup::Store
|
9
|
+
|
10
|
+
attr_reader :pry
|
11
|
+
|
12
|
+
def initialize(pry)
|
13
|
+
@pry = pry
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
pry_instance_to_remove = pry.push_initial_binding.join
|
18
|
+
store.transaction { store.delete(pry_instance_to_remove) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../base"
|
4
|
+
require_relative "../setup/store"
|
5
|
+
|
6
|
+
module Session
|
7
|
+
class PopulateHistory < Base
|
8
|
+
include Setup::Store
|
9
|
+
|
10
|
+
attr_reader :binding
|
11
|
+
|
12
|
+
def initialize(binding)
|
13
|
+
@binding = binding
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
store.transaction do
|
18
|
+
store.abort unless extract_variable_to_store
|
19
|
+
|
20
|
+
store[pry_instance_uid].push(variable_to_store)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Unique instance identifier (e.g., a Pry opened tab)
|
27
|
+
def pry_instance_uid
|
28
|
+
binding.binding_stack.join
|
29
|
+
end
|
30
|
+
|
31
|
+
def extract_variable_to_store
|
32
|
+
@extract_variable_to_store ||= last_cmd.match(/^(\w+)\s*=/)
|
33
|
+
end
|
34
|
+
|
35
|
+
def last_cmd
|
36
|
+
binding.eval_string.strip
|
37
|
+
end
|
38
|
+
|
39
|
+
def variable_to_store
|
40
|
+
extract_variable_to_store[1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -3,25 +3,34 @@
|
|
3
3
|
require_relative "checks/database_url"
|
4
4
|
require_relative "checks/database_pool"
|
5
5
|
require_relative "store"
|
6
|
+
require_relative "../base"
|
6
7
|
|
7
8
|
require "pstore"
|
8
9
|
|
9
10
|
module Setup
|
10
|
-
class ApplicationDictionary
|
11
|
+
class ApplicationDictionary < Base
|
11
12
|
include Store
|
12
13
|
|
13
|
-
def initialize
|
14
|
+
def initialize(binding)
|
15
|
+
@binding = binding
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
14
19
|
establish_db_connection
|
15
20
|
populate_store
|
16
21
|
end
|
17
22
|
|
18
23
|
private
|
19
24
|
|
25
|
+
attr_reader :binding
|
26
|
+
|
20
27
|
SEVEN_DAYS = 604800
|
21
28
|
|
22
29
|
def populate_store
|
23
30
|
store.transaction do
|
24
|
-
store
|
31
|
+
# Create a table with unique instance identifier information to store variables history.
|
32
|
+
store[pry_instance_uid] = []
|
33
|
+
store.commit unless staled_store?
|
25
34
|
|
26
35
|
store["active_record_models"] = populate_active_record_models_dictionary
|
27
36
|
store["associations"] = populate_associations
|
@@ -66,6 +75,11 @@ module Setup
|
|
66
75
|
(store["synced_at"] + SEVEN_DAYS) <= Time.now
|
67
76
|
end
|
68
77
|
|
78
|
+
# Use the binding identifier as pry instance uid.
|
79
|
+
def pry_instance_uid
|
80
|
+
binding.to_s
|
81
|
+
end
|
82
|
+
|
69
83
|
def logger
|
70
84
|
@logger = Logger.new($stdout)
|
71
85
|
end
|
data/lib/pry-byetypo/version.rb
CHANGED
data/lib/pry-byetypo.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "pry"
|
4
|
-
require "zeitwerk"
|
5
4
|
|
6
|
-
require_relative "pry-byetypo/version"
|
7
5
|
require_relative "pry-byetypo/setup/application_dictionary"
|
6
|
+
require_relative "pry-byetypo/session/clear_history"
|
8
7
|
require_relative "pry-byetypo/exceptions_handler"
|
8
|
+
require_relative "pry-byetypo/session/populate_history"
|
9
|
+
require_relative "pry-byetypo/version"
|
9
10
|
|
10
11
|
module Pry::Byetypo
|
11
|
-
Pry.config.hooks.add_hook(:before_session, :
|
12
|
-
Setup::ApplicationDictionary.
|
12
|
+
Pry.config.hooks.add_hook(:before_session, :create_dictionary) do |_output, binding, _pry|
|
13
|
+
Setup::ApplicationDictionary.call(binding)
|
14
|
+
end
|
15
|
+
|
16
|
+
Pry.config.hooks.add_hook(:after_read, :populate_session_history) do |_output, binding, _pry|
|
17
|
+
Session::PopulateHistory.call(binding)
|
18
|
+
end
|
19
|
+
|
20
|
+
Pry.config.hooks.add_hook(:after_session, :clear_session_history) do |_output, _binding, pry|
|
21
|
+
Session::ClearHistory.call(pry)
|
13
22
|
end
|
14
23
|
|
15
24
|
# TODO: Adds max_attempts
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- morissetcl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -77,12 +77,17 @@ files:
|
|
77
77
|
- Rakefile
|
78
78
|
- lib/pry-byetypo.rb
|
79
79
|
- lib/pry-byetypo/base.rb
|
80
|
+
- lib/pry-byetypo/constants/errors.rb
|
80
81
|
- lib/pry-byetypo/exceptions/active_record/base.rb
|
81
82
|
- lib/pry-byetypo/exceptions/active_record/configuration_error.rb
|
82
83
|
- lib/pry-byetypo/exceptions/active_record/statement_invalid.rb
|
83
84
|
- lib/pry-byetypo/exceptions/exceptions_base.rb
|
84
|
-
- lib/pry-byetypo/exceptions/name_error.rb
|
85
|
+
- lib/pry-byetypo/exceptions/name_error/handler.rb
|
86
|
+
- lib/pry-byetypo/exceptions/name_error/undefined_variable.rb
|
87
|
+
- lib/pry-byetypo/exceptions/name_error/uninitialized_constant.rb
|
85
88
|
- lib/pry-byetypo/exceptions_handler.rb
|
89
|
+
- lib/pry-byetypo/session/clear_history.rb
|
90
|
+
- lib/pry-byetypo/session/populate_history.rb
|
86
91
|
- lib/pry-byetypo/setup/application_dictionary.rb
|
87
92
|
- lib/pry-byetypo/setup/checks/base.rb
|
88
93
|
- lib/pry-byetypo/setup/checks/database_pool.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "exceptions_base"
|
4
|
-
|
5
|
-
module Exceptions
|
6
|
-
class NameError < ExceptionsBase
|
7
|
-
private
|
8
|
-
|
9
|
-
def unknown_from_exception
|
10
|
-
exception.to_s.split.last
|
11
|
-
end
|
12
|
-
|
13
|
-
def corrected_word
|
14
|
-
@corrected_word ||= spell_checker(ar_models_dictionary).correct(unknown_from_exception).first
|
15
|
-
end
|
16
|
-
|
17
|
-
def corrected_cmd
|
18
|
-
@corrected_cmd ||= last_cmd.gsub(unknown_from_exception, corrected_word)
|
19
|
-
end
|
20
|
-
|
21
|
-
def ar_models_dictionary
|
22
|
-
@ar_models_dictionary ||= store.transaction { |s| s["active_record_models"] }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|