pry-byetypo 1.0.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d29897c99a83e87e7e440a1c4d70152362c59b56909271441ad8ee64cdfc0dda
4
- data.tar.gz: e56b51093055e7374b10b83c4ab5694f51a46e6fa7d7bc49db4f883ee1e5238a
3
+ metadata.gz: ffd46e3838ed0c8d43e5aa5c3fc5a38c518d90a4dbefcbba09f1629fffe72260
4
+ data.tar.gz: cef94f7e070bc541cedc9f2a547a9dc2901b8bf2ca96b4cfda09f5ffef890381
5
5
  SHA512:
6
- metadata.gz: e0196f077acc833eb924f2d112bb88e052a2b8386ac1166d3f155b40db286a2afd99edfd2d81c5dce720d0dbb494902fb7ab0da185463b7926cd3aba0e446a0d
7
- data.tar.gz: e3c93cf18c7e5af20557d60d4760d2c7305b3b986c073ec1fc643c5be991e7d54ec8cc36ee9ee9f3a393865f15207bce3292e726a4496f1972cfe71357efe077
6
+ metadata.gz: 61e7d2eb327d7a3905eb882288260484d42497bfe895a98a72bbccf562d9905ede28becb9b9c2da9e71c537967f8621299d364b97f442869d98f551a4b5073a4
7
+ data.tar.gz: 86252b1586e787a3f3e3ac6a66c13034640eba983a2d0d8a8be95f239906fef4611f9c00fcf17c675030b03ab512605dc1e87436ef9eaea7d261675a2cc03845
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pry-byetypo (1.0.0)
4
+ pry-byetypo (1.1.0)
5
5
  colorize (~> 1.1.0)
6
6
  pry (>= 0.13, < 0.15)
7
7
  rails (~> 7.0)
data/README.md CHANGED
@@ -2,30 +2,32 @@
2
2
 
3
3
  Autocorrects typos in your Pry console.
4
4
 
5
- This small Pry plugin captures exceptions that could be due to typos and deduces the correct command based on your database information.
6
-
7
- > [!NOTE]
8
- > So far, this plugin is not framework agnostic, and it requires Rails 7 or later.
9
-
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.
10
6
 
11
7
  #### Before
12
8
 
13
9
  ```ruby
14
- [1] pry(main)> Usert.last
15
- NameError: uninitialized constant Usert
16
- from (pry):3:in `__pry__'
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__'
17
15
  ```
18
16
 
19
17
  #### After
20
18
 
21
19
  ```ruby
22
- [1] pry(main)> Usert.last
23
- I, [2024-01-13T20:00:16.280710 #694] INFO -- : `Usert` not working, running:
24
- I, [2024-01-13T20:00:16.281237 #694] INFO -- : User.last
25
- 2024-01-13 20:00:16.345175 D [694:9200 log_subscriber.rb:130] ActiveRecord::Base -- User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]]
26
- => #<User id: 1, email: "yo@email.com">
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
27
26
  ```
28
27
 
28
+ > [!NOTE]
29
+ > So far, this plugin is not framework agnostic, and it requires Rails 7 or later.
30
+
29
31
  ## Installation
30
32
 
31
33
 
@@ -47,57 +49,94 @@ gem install pry-byetypo
47
49
  2. Start your daily work.
48
50
  3. Let `pry-byetypo` remove frictions. 🚀
49
51
 
50
- ## Under the hood
52
+ ## Byetypo dictionary
51
53
 
52
- ### 1. Byetypo dictionary
53
-
54
- When you open a new Pry console, the gem will generate a `byetypo_dictionary.pstore` file containing three pieces of information:
54
+ When you open a new Pry console, the gem will generate a `byetypo_dictionary.pstore` file containing four pieces of information:
55
55
 
56
56
  - A list of the ActiveRecord models in your application (e.g. `User`, `Account`).
57
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`)
58
59
  - A timestamp representing the last time the `byetypo_dictionary` was updated. (by default updated every week).
59
60
 
60
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.
61
62
 
62
- ### 2. Captured exceptions
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
+ ```
63
89
 
64
- #### NameError
90
+ ### NameError - uninitialized constant
65
91
 
66
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.
67
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
+
68
105
  ```ruby
69
106
  [1] pry(main)> Usert.last
70
- I, [2024-01-13T20:00:16.280710 #694] INFO -- : `Usert` not working, running:
71
- I, [2024-01-13T20:00:16.281237 #694] INFO -- : User.last
72
- 2024-01-13 20:00:16.345175 D [694:9200 log_subscriber.rb:130] ActiveRecord::Base -- User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]]
107
+ I, [2024-01-13T20:00:16.280710 #694] ERROR -- : uninitialized constant Usert
108
+ I, [2024-01-13T20:00:16.281237 #694] INFO -- : Running: User.last
73
109
  => #<User id: 1, email: "yo@email.com">
74
110
  ```
75
111
 
76
- #### ActiveRecord::ConfigurationError
112
+ ### ActiveRecord::ConfigurationError
77
113
 
78
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.
79
116
 
80
- eg:
117
+ ##### Before
81
118
 
82
119
  ```ruby
83
120
  [6] pry(main)> User.joins(:group).where(groups: { name: "Landlord" }).last
84
121
  ActiveRecord::ConfigurationError: Can't join 'User' to association named 'group'; perhaps you misspelled it?
85
122
  ```
86
123
 
87
- This plugin will look into the `byetypo_dictionary` file to find the closest match and run the correct query.
88
-
124
+ ##### After
89
125
 
90
126
  ```ruby
91
127
  [1] pry(main)> User.joins(:group).where(groups: { name: "Landlord" })
92
- I, [2024-01-13T22:45:16.297811 #1079] INFO -- : `group` not working, running.
93
- I, [2024-01-13T22:45:16.297972 #1079] INFO -- : User.joins(:groups).where(groups: { name: "Landlord" })
128
+ I, [2024-01-13T22:45:16.297811 #1079] ERROR -- : ActiveRecord::ConfigurationError: Can't join 'User' to association named 'group'; perhaps you misspelled it?
129
+ I, [2024-01-13T22:45:16.297972 #1079] INFO -- : Running: User.joins(:groups).where(groups: { name: "Landlord" })
94
130
  2024-01-13 22:45:16.319544 D [1079:9200 log_subscriber.rb:130] ActiveRecord::Base -- User Load (1.6ms) SELECT "users".* FROM "users" INNER JOIN "user_groups" ON "user_groups"."user_id" = "users"."id" INNER JOIN "groups" ON "groups"."id" = "user_groups"."group_id" WHERE "users"."deleted_at" IS NULL AND "groups"."name" = $1 [["name", "Landlord"]]
95
131
  => []
96
132
  ```
97
133
 
98
- #### ActiveRecord::StatementInvalid
134
+ ### ActiveRecord::StatementInvalid
99
135
 
100
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
101
140
 
102
141
  ```ruby
103
142
  [1] pry(main)> User.joins(:groups).where(grous: { name: "Landlord" }).last
@@ -105,12 +144,12 @@ ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause
105
144
  LINE 1: ..."group_id" WHERE "users"."deleted_at" IS NULL AND "grous"."n...
106
145
  ```
107
146
 
108
- This plugin will look into the `byetypo_dictionary` file to find the closest match and run the correct query.
147
+ ##### After
109
148
 
110
149
  ```ruby
111
150
  1] pry(main)> User.joins(:groups).where(grous: { name: "Landlord" }).last
112
- I, [2024-01-14T23:50:49.273043 #1248] INFO -- : `grous` not working, running:
113
- I, [2024-01-14T23:50:49.273177 #1248] INFO -- : User.joins(:groups).where(groups: { name: "Landlord" }).last
151
+ I, [2024-01-14T23:50:49.273043 #1248] ERROR -- : ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "grous"
152
+ I, [2024-01-14T23:50:49.273177 #1248] INFO -- : Running: User.joins(:groups).where(groups: { name: "Landlord" }).last
114
153
  2024-01-14 23:50:49.281956 D [1248:9200 log_subscriber.rb:130] ActiveRecord::Base -- User Load (2.1ms) SELECT "users".* FROM "users" INNER JOIN "user_groups" ON "user_groups"."user_id" = "users"."id" INNER JOIN "groups" ON "groups"."id" = "user_groups"."group_id" WHERE "users"."deleted_at" IS NULL AND "groups"."name" = $1 ORDER BY "users"."id" DESC LIMIT $2 [["name", "Landlord"], ["LIMIT", 1]]
115
154
  ```
116
155
 
@@ -118,11 +157,11 @@ I, [2024-01-14T23:50:49.273177 #1248] INFO -- : User.joins(:groups).where(group
118
157
 
119
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.
120
159
 
121
- ### Unreadable database URL (URI::InvalidURIError)
160
+ #### Unreadable database URL (URI::InvalidURIError)
122
161
 
123
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.
124
163
 
125
- ### Unreadable connection pool (ActiveRecord::ConnectionTimeoutError)
164
+ #### Unreadable connection pool (ActiveRecord::ConnectionTimeoutError)
126
165
 
127
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.
128
167
 
@@ -0,0 +1,7 @@
1
+ module Constants
2
+ module Errors
3
+ UNINITIALIZED_CONSTANT = "uninitialized constant".freeze
4
+ UNDEFINED_VARIABLE = "undefined local variable".freeze
5
+ UNDEFINED_TABLE = "UndefinedTable".freeze
6
+ end
7
+ end
@@ -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
- logger.error(exception.to_s.colorize(color: :light_red, mode: :bold))
12
- logger.info("Running: #{corrected_cmd}".colorize(color: :green, mode: :bold))
13
-
14
- pry.eval(corrected_cmd)
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 => error
23
- # eg: Usert.last
20
+ in NameError
24
21
  # NameError is a Superclass for all undefined statement.
25
- # In this context We only need to one including an `uninitialized constant` error.
26
- return pry_exception_handler unless error.message.include?(UNINITIALIZED_CONSTANT)
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 error.message.include?(UNDEFINED_TABLE)
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.abort unless staled_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
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Pry
4
4
  module Byetypo
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
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, :eager_loading) do |output, exception, pry|
12
- Setup::ApplicationDictionary.new
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.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-29 00:00:00.000000000 Z
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