console_buddy 0.1.9 → 0.1.11

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: e3405d3e352a7082a232730e28352f8724badbbf069380fa80450c955997454f
4
- data.tar.gz: 0cbc27a23dda483e14ce75818560b42dde9dc7ed034e870074d8d36b278eee1c
3
+ metadata.gz: f06e8299de73ca38c3034fe6b769da6e0abe43d5cd139495afcba9009408b1dc
4
+ data.tar.gz: 9ae2d7489bf7eecd165cfa24ed388dfaf32ef9fc0a85a4402c5c6f951c0f2ae7
5
5
  SHA512:
6
- metadata.gz: eafabb5a03cfe5a5229d3f5e1042f52592ecb6d324d940208918a5037695c9d5fdf381816648bf0ecb5df572bf45b32c21753f0953a67b7a198740164fe0e397
7
- data.tar.gz: 48ba1b2de4bc2627a32a656f7edfb9191f1de62d5c165f61ebe34d2f8138aa5934dd93c59dd0c1ddcf86da6bfed5af847785bd81be7189ee25940380f169cd9c
6
+ metadata.gz: 5bf025aac5e410b334475f5dcaab699cb5ca0692e690c686038f971595844250d772245d0f87662ed0e20b423b2c9a7fba82f12868cb267c243dcc64c32023cd
7
+ data.tar.gz: ae5ff5b1c1d1fd00bfea0ae195f5d061a0c698f050c8d7530544f086114b23cac318e5250c3a243a5a95f796375bb75abcc61045e6cd9631493de064e5271b3d
@@ -20,6 +20,7 @@ module ConsoleBuddy
20
20
  if block_given?
21
21
  instance = ::ConsoleBuddy::Augment::DSL.new
22
22
  instance.instance_eval(&block)
23
+ ConsoleBuddy.augment_classes if ConsoleBuddy.respond_to?(:augment_classes)
23
24
  end
24
25
  end
25
26
  end
@@ -21,6 +21,7 @@ module ConsoleBuddy
21
21
  if block_given?
22
22
  instance = ::ConsoleBuddy::Helpers::DSL.new
23
23
  instance.instance_eval(&block)
24
+ ConsoleBuddy.augment_console if ConsoleBuddy.respond_to?(:augment_console)
24
25
  end
25
26
  end
26
27
  end
@@ -8,7 +8,7 @@ require_relative "../one_off_job"
8
8
  module ConsoleBuddy
9
9
  module Jobs
10
10
  class Sidekiq
11
- include(defined?(::Sidekiq::Job) ? ::Sidekiq::Job : ::Sidekiq::Worker)
11
+ include(defined?(::Sidekiq::Worker) ? ::Sidekiq::Worker : ::Sidekiq::Job)
12
12
 
13
13
  def perform(*args)
14
14
  ::ConsoleBuddy::OneOffJob.perform(*args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConsoleBuddy
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
data/lib/console_buddy.rb CHANGED
@@ -2,16 +2,8 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- # Check if .console_buddy directory exists
6
- def console_buddy_directory_exists?
7
- console_buddy_path = Pathname.new(File.join(Dir.pwd, '.console_buddy'))
8
- console_buddy_path.exist? && console_buddy_path.directory?
9
- end
10
-
11
- if !console_buddy_directory_exists?
12
- return
13
- end
14
-
5
+ # Always load the module; .console_buddy existence is checked in start! when Rails.root is set
6
+ # (Rails 7.2 / Spring can require gems before Rails.root is available)
15
7
  require 'active_support'
16
8
  require 'active_support/all'
17
9
 
@@ -68,6 +60,8 @@ module ConsoleBuddy
68
60
  def start!
69
61
  # Initialize the default values
70
62
  set_config_defaults
63
+ # Require .console_buddy to exist (check here when Rails.root is set; avoids Rails 7.2 / Spring load-order issues)
64
+ return unless console_buddy_directory_exists?
71
65
  # Check if there is a .console_buddy/config file
72
66
  load_console_buddy_config
73
67
 
@@ -129,9 +123,22 @@ module ConsoleBuddy
129
123
  ENV['RAILS_ENV'] || ENV['RACK_ENV']
130
124
  end
131
125
 
126
+ # App root so .console_buddy is found under Rails (e.g. with Spring) or Dir.pwd
127
+ def console_buddy_root
128
+ if defined?(Rails) && Rails.respond_to?(:root) && Rails.root.present?
129
+ Pathname.new(Rails.root.to_s)
130
+ else
131
+ Pathname.new(Dir.pwd)
132
+ end
133
+ end
134
+
135
+ def console_buddy_directory_exists?
136
+ console_buddy_root.join('.console_buddy').exist? && console_buddy_root.join('.console_buddy').directory?
137
+ end
138
+
132
139
  # Loads the .console_buddy/config file if present
133
140
  def load_console_buddy_config
134
- config_path = Pathname.new(File.join(Dir.pwd, '.console_buddy', 'config.rb'))
141
+ config_path = console_buddy_root.join('.console_buddy', 'config.rb')
135
142
  if config_path.exist? && config_path.file?
136
143
  require config_path.to_s
137
144
  else
@@ -142,7 +149,7 @@ module ConsoleBuddy
142
149
  # Loads all the files in the .console_buddy folder
143
150
  # .console_buddy folder should be in the root of the project
144
151
  def load_console_buddy_files
145
- console_buddy_path = Pathname.new(File.join(Dir.pwd, '.console_buddy'))
152
+ console_buddy_path = console_buddy_root.join('.console_buddy')
146
153
  if console_buddy_path.exist? && console_buddy_path.directory?
147
154
  console_buddy_path.find do |path|
148
155
  next unless path.file?
@@ -188,6 +195,8 @@ module ConsoleBuddy
188
195
  end
189
196
  end
190
197
 
198
+ public :augment_classes, :augment_console
199
+
191
200
  # This will add the buddy methods to the IRB session
192
201
  # So that they can be called without instantiating the `ConsoleBuddy::Base` class
193
202
  def start_buddy_in_irb
@@ -204,6 +213,12 @@ module ConsoleBuddy
204
213
  Rails::ConsoleMethods.include(ConsoleBuddy::IRB)
205
214
  load_progress_bar
206
215
  end
216
+ # Pry: ensure console methods are on the session's main object (before_session gets output, binding, pry)
217
+ if defined?(Pry)
218
+ Pry.config.hooks.add_hook(:before_session, :console_buddy) do |_output, binding, _pry|
219
+ binding.receiver.extend(ConsoleBuddy::IRB)
220
+ end
221
+ end
207
222
  end
208
223
 
209
224
  def load_progress_bar
@@ -247,4 +262,4 @@ require_relative "console_buddy/initializers/rails"
247
262
 
248
263
  if rspec_present
249
264
  require_relative "console_buddy/initializers/rspec"
250
- end
265
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_buddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Bowie
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-02-18 00:00:00.000000000 Z
12
+ date: 2026-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -208,8 +208,8 @@ homepage:
208
208
  licenses: []
209
209
  metadata:
210
210
  bug_tracker_uri: https://github.com/GoodForNothingTech/console_buddy/issues
211
- changelog_uri: https://github.com/GoodForNothingTech/console_buddy/CHANGELOG.md
212
- documentation_uri: https://github.com/GoodForNothingTech/console_buddy
211
+ changelog_uri: https://github.com/GoodForNothingTech/console_buddy/blob/main/CHANGELOG.md
212
+ documentation_uri: https://github.com/GoodForNothingTech/console_buddy/blob/main/README.md
213
213
  source_code_uri: https://github.com/GoodForNothingTech/console_buddy
214
214
  post_install_message:
215
215
  rdoc_options: []
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  - !ruby/object:Gem::Version
227
227
  version: '0'
228
228
  requirements: []
229
- rubygems_version: 3.4.1
229
+ rubygems_version: 3.4.19
230
230
  signing_key:
231
231
  specification_version: 4
232
232
  summary: Have you ever had debugging tricks, aliases, or shortcuts that don't make