pry-rails 0.3.8 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +2 -1
- data/Readme.md +16 -7
- data/lib/pry-rails/commands/find_route.rb +2 -2
- data/lib/pry-rails/commands/show_middleware.rb +7 -3
- data/lib/pry-rails/commands/show_models.rb +4 -0
- data/lib/pry-rails/commands/show_routes.rb +20 -4
- data/lib/pry-rails/prompt.rb +5 -1
- data/lib/pry-rails/railtie.rb +24 -5
- data/lib/pry-rails/version.rb +1 -1
- data/pry-rails.gemspec +1 -1
- data/scenarios/rails30.dockerfile +1 -1
- data/scenarios/rails31.dockerfile +1 -1
- data/scenarios/rails32.dockerfile +1 -1
- data/scenarios/rails40.dockerfile +1 -1
- data/scenarios/rails41.dockerfile +1 -1
- data/scenarios/rails42.dockerfile +1 -1
- data/scenarios/rails50.dockerfile +1 -1
- data/scenarios/rails51.dockerfile +1 -1
- data/scenarios/rails52.docker-compose.yml +15 -0
- data/scenarios/rails52.dockerfile +5 -0
- data/scenarios/rails52.gemfile +7 -0
- data/scenarios/rails60.docker-compose.yml +15 -0
- data/scenarios/rails60.dockerfile +5 -0
- data/scenarios/rails60.gemfile +7 -0
- data/scenarios.yml +4 -1
- data/spec/railtie_spec.rb +2 -1
- data/spec/show_models_spec.rb +1 -1
- data/spec/show_routes_spec.rb +4 -4
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 41cf7797bc227eb06eb453085ab2b045943d5994a2f619a91c9a5820ca42f561
|
4
|
+
data.tar.gz: 9efdf50c92a2f68ba75c63e48856b21e9372905d64001fa0c07a9c25ccc88924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4c411a091a7c3841ba74293ce7400fba5aa663388b41c0368e7c78b3cd7f527c1c97107930cfd1918e1b5614cc34d2b83c5af397b055daafd2afab7933c5e7c
|
7
|
+
data.tar.gz: 34e938fb579b8968bf7e9a3fb6265976a3f68a28eae47c8c67d16ebe7904499b8b734bd32c2dd531fe0dac0bff6673fa69136fb4d2dd72ec5135132ac134be21
|
data/Rakefile
CHANGED
@@ -23,7 +23,8 @@ end
|
|
23
23
|
|
24
24
|
desc 'Start the Rails console'
|
25
25
|
task :console => :development_env do
|
26
|
-
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1)
|
26
|
+
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1) ||
|
27
|
+
Rails::VERSION::MAJOR >= 6
|
27
28
|
require 'rails/command'
|
28
29
|
require 'rails/commands/console/console_command'
|
29
30
|
else
|
data/Readme.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
This project is not actively maintained and looking for a maintainer!
|
2
|
+
|
3
|
+
|
1
4
|
# Description
|
2
5
|
|
3
6
|
Avoid repeating yourself, use pry-rails instead of copying the initializer to every rails project.
|
4
|
-
This is a small gem which causes `rails console` to open [pry](
|
7
|
+
This is a small gem which causes `rails console` to open [pry](https://pry.github.io/). It therefore depends on *pry*.
|
5
8
|
|
6
9
|
# Prerequisites
|
7
10
|
|
@@ -71,9 +74,6 @@ Pokemon
|
|
71
74
|
updated_at: datetime
|
72
75
|
belongs_to hacker
|
73
76
|
has_many beers through hacker
|
74
|
-
|
75
|
-
$ DISABLE_PRY_RAILS=1 rails console
|
76
|
-
irb(main):001:0>
|
77
77
|
```
|
78
78
|
|
79
79
|
## Custom Rails prompt
|
@@ -82,7 +82,7 @@ If you want to permanently include the current Rails environment and project nam
|
|
82
82
|
in the Pry prompt, put the following lines in your project's `.pryrc`:
|
83
83
|
|
84
84
|
```ruby
|
85
|
-
Pry.config.prompt = Pry::Prompt[:rails]
|
85
|
+
Pry.config.prompt = Pry::Prompt[:rails]
|
86
86
|
```
|
87
87
|
|
88
88
|
If `.pryrc` could be loaded without pry-rails being available or installed,
|
@@ -90,13 +90,22 @@ guard against setting `Pry.config.prompt` to `nil`:
|
|
90
90
|
|
91
91
|
```ruby
|
92
92
|
if Pry::Prompt[:rails]
|
93
|
-
Pry.config.prompt = Pry::Prompt[:rails]
|
93
|
+
Pry.config.prompt = Pry::Prompt[:rails]
|
94
94
|
end
|
95
95
|
```
|
96
96
|
|
97
97
|
Check out `change-prompt --help` for information about temporarily
|
98
98
|
changing the prompt for the current Pry session.
|
99
99
|
|
100
|
+
## Disabling pry-rails
|
101
|
+
|
102
|
+
If pry-rails is included in your application but you would prefer not to use it, you may run the following command to set the appropriate environment variable to disable initialization and fall back to the default IRB console:
|
103
|
+
```shell
|
104
|
+
DISABLE_PRY_RAILS=1 rails console
|
105
|
+
```
|
106
|
+
|
107
|
+
Note that you may need to run `spring stop` first.
|
108
|
+
|
100
109
|
# Developing and Testing
|
101
110
|
|
102
111
|
This repo uses [Roadshow] to generate a [Docker Compose] file for each
|
@@ -106,7 +115,7 @@ To run specs across all versions, you can either [get the Roadshow tool] and
|
|
106
115
|
run `roadshow run`, or use Docker Compose directly:
|
107
116
|
|
108
117
|
```
|
109
|
-
$ for fn in scenarios/*.docker-compose
|
118
|
+
$ for fn in scenarios/*.docker-compose.yml; do docker-compose -f $fn run --rm scenario; done
|
110
119
|
```
|
111
120
|
|
112
121
|
You can also manually run the Rails console and server on each version with
|
@@ -52,11 +52,11 @@ class PryRails::FindRoute < Pry::ClassCommand
|
|
52
52
|
if all_routes.any?
|
53
53
|
grouped_routes = all_routes.group_by { |route| route.defaults[:controller] }
|
54
54
|
result = grouped_routes.each_with_object("") do |(controller, routes), res|
|
55
|
-
res << "Routes for " +
|
55
|
+
res << "Routes for " + bold(controller.to_s.camelize + "Controller") + "\n"
|
56
56
|
res << "--\n"
|
57
57
|
routes.each do |route|
|
58
58
|
spec = route.path.is_a?(String) ? route.path : route.path.spec
|
59
|
-
res << "#{route.defaults[:action]} #{
|
59
|
+
res << "#{route.defaults[:action]} #{bold(verb_for(route))} #{spec} #{route_helper(route.name)}" + "\n"
|
60
60
|
end
|
61
61
|
res << "\n"
|
62
62
|
end
|
@@ -17,10 +17,14 @@ class PryRails::ShowMiddleware < Pry::ClassCommand
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def process
|
20
|
-
#
|
20
|
+
# Assumes there is only one Rack::Server instance.
|
21
|
+
# TODO: Figure out what replaced Rack::Server so that we can show the
|
22
|
+
# entire middleware stack on recent Rails versions.
|
21
23
|
server = nil
|
22
|
-
|
23
|
-
|
24
|
+
if defined?(Rack::Server)
|
25
|
+
ObjectSpace.each_object(Rack::Server) do |object|
|
26
|
+
server = object
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
middlewares = []
|
@@ -40,6 +40,10 @@ class PryRails::ShowModels < Pry::ClassCommand
|
|
40
40
|
models = []
|
41
41
|
|
42
42
|
ObjectSpace.each_object do |o|
|
43
|
+
# If this is deprecated, calling any methods on it will emit a warning,
|
44
|
+
# so just back away slowly.
|
45
|
+
next if ActiveSupport::Deprecation::DeprecationProxy === o
|
46
|
+
|
43
47
|
is_model = false
|
44
48
|
|
45
49
|
begin
|
@@ -17,10 +17,12 @@ class PryRails::ShowRoutes < Pry::ClassCommand
|
|
17
17
|
Rails.application.reload_routes!
|
18
18
|
all_routes = Rails.application.routes.routes
|
19
19
|
|
20
|
-
formatted =
|
21
|
-
|
20
|
+
formatted =
|
21
|
+
if Rails::VERSION::MAJOR >= 6
|
22
|
+
process_rails_6_and_higher(all_routes)
|
23
|
+
elsif Rails::VERSION::MAJOR == 4 || Rails::VERSION::MAJOR == 5
|
22
24
|
process_rails_4_and_5(all_routes)
|
23
|
-
|
25
|
+
elsif Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR >= 2
|
24
26
|
process_rails_3_2(all_routes)
|
25
27
|
else
|
26
28
|
process_rails_3_0_and_3_1(all_routes)
|
@@ -64,12 +66,26 @@ class PryRails::ShowRoutes < Pry::ClassCommand
|
|
64
66
|
|
65
67
|
def process_rails_3_2(all_routes)
|
66
68
|
require 'rails/application/route_inspector'
|
69
|
+
|
67
70
|
Rails::Application::RouteInspector.new.format(all_routes)
|
68
71
|
end
|
69
72
|
|
70
73
|
def process_rails_4_and_5(all_routes)
|
71
74
|
require 'action_dispatch/routing/inspector'
|
72
|
-
|
75
|
+
|
76
|
+
ActionDispatch::Routing::RoutesInspector.
|
77
|
+
new(all_routes).
|
78
|
+
format(ActionDispatch::Routing::ConsoleFormatter.new).
|
79
|
+
split(/\n/)
|
80
|
+
end
|
81
|
+
|
82
|
+
def process_rails_6_and_higher(all_routes)
|
83
|
+
require 'action_dispatch/routing/inspector'
|
84
|
+
|
85
|
+
ActionDispatch::Routing::RoutesInspector.
|
86
|
+
new(all_routes).
|
87
|
+
format(ActionDispatch::Routing::ConsoleFormatter::Sheet.new).
|
88
|
+
split(/\n/)
|
73
89
|
end
|
74
90
|
|
75
91
|
PryRails::Commands.add_command(self)
|
data/lib/pry-rails/prompt.rb
CHANGED
@@ -13,7 +13,11 @@ module PryRails
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def project_name
|
16
|
-
Rails
|
16
|
+
if Rails::VERSION::MAJOR >= 6
|
17
|
+
Rails.application.class.module_parent_name.underscore
|
18
|
+
else
|
19
|
+
Rails.application.class.parent_name.underscore
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/pry-rails/railtie.rb
CHANGED
@@ -14,18 +14,37 @@ module PryRails
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
if Rails::VERSION::MAJOR
|
18
|
-
Rails::VERSION::MAJOR == 6
|
17
|
+
if Rails::VERSION::MAJOR >= 4
|
19
18
|
Rails.application.config.console = Pry
|
20
19
|
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
major = Rails::VERSION::MAJOR
|
22
|
+
minor = Rails::VERSION::MINOR
|
23
|
+
|
24
|
+
if (major == 3 && minor >= 2) || (major >= 4 && (major < 7 || (major == 7 && minor < 2)))
|
25
25
|
require "rails/console/app"
|
26
26
|
require "rails/console/helpers"
|
27
27
|
TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
|
28
28
|
end
|
29
|
+
|
30
|
+
if major > 7 || (major == 7 && minor >= 2)
|
31
|
+
require "rails/commands/console/irb_console"
|
32
|
+
|
33
|
+
Module.new do
|
34
|
+
def reload!
|
35
|
+
puts "Reloading..."
|
36
|
+
Rails.application.reloader.reload!
|
37
|
+
end
|
38
|
+
|
39
|
+
::IRB::HelperMethod.helper_methods.each do |name, helper_method_class|
|
40
|
+
define_method name do |*args, **opts, &block|
|
41
|
+
helper_method_class.instance.execute(*args, **opts, &block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
TOPLEVEL_BINDING.eval("self").extend self
|
46
|
+
end
|
47
|
+
end
|
29
48
|
end
|
30
49
|
end
|
31
50
|
end
|
data/lib/pry-rails/version.rb
CHANGED
data/pry-rails.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency "pry", ">= 0.
|
23
|
+
s.add_dependency "pry", ">= 0.13.0"
|
24
24
|
s.add_development_dependency "appraisal"
|
25
25
|
s.add_development_dependency "minitest"
|
26
26
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails52.dockerfile
|
8
|
+
image: pryrails_scenario_rails52
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails52:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails52.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails52: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails60.dockerfile
|
8
|
+
image: pryrails_scenario_rails60
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails60:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails60.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails60: {}
|
data/scenarios.yml
CHANGED
@@ -2,7 +2,7 @@ project: pryrails
|
|
2
2
|
|
3
3
|
shared:
|
4
4
|
from: ruby:2.4
|
5
|
-
cmd: "(bundle check || bundle install) && bundle exec rake"
|
5
|
+
cmd: "(bundle check || (gem install bundler && bundle install)) && bundle exec rake"
|
6
6
|
service:
|
7
7
|
volumes:
|
8
8
|
- bundle_{{scenario_name}}:/usr/local/bundle
|
@@ -25,3 +25,6 @@ scenarios:
|
|
25
25
|
rails42: {}
|
26
26
|
rails50: {}
|
27
27
|
rails51: {}
|
28
|
+
rails52: {}
|
29
|
+
rails60:
|
30
|
+
from: ruby:2.5
|
data/spec/railtie_spec.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1)
|
5
|
+
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1) ||
|
6
|
+
Rails::VERSION::MAJOR >= 6
|
6
7
|
require 'rails/command'
|
7
8
|
require 'rails/commands/console/console_command'
|
8
9
|
else
|
data/spec/show_models_spec.rb
CHANGED
data/spec/show_routes_spec.rb
CHANGED
@@ -10,20 +10,20 @@ describe "show-routes" do
|
|
10
10
|
it "should print a list of routes" do
|
11
11
|
output = mock_pry('show-routes', 'exit-all')
|
12
12
|
|
13
|
-
output.must_match %r{
|
13
|
+
output.must_match %r{edit_pokemon GET /pokemon/edit}
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should print a list of routes which include grep option" do
|
17
17
|
output = mock_pry('show-routes -G edit', 'exit-all')
|
18
18
|
|
19
|
-
output.must_match %r{
|
20
|
-
output.must_match %r{
|
19
|
+
output.must_match %r{edit_pokemon GET /pokemon/edit}
|
20
|
+
output.must_match %r{ edit_beer GET /beer/edit}
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should filter list based on multiple grep options" do
|
24
24
|
output = mock_pry('show-routes -G edit -G pokemon', 'exit-all')
|
25
25
|
|
26
|
-
output.must_match %r{
|
26
|
+
output.must_match %r{edit_pokemon GET /pokemon/edit}
|
27
27
|
output.wont_match %r{edit_beer}
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Wenglewski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.13.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.13.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- robin@wenglewski.de
|
58
58
|
executables: []
|
@@ -103,6 +103,12 @@ files:
|
|
103
103
|
- scenarios/rails51.docker-compose.yml
|
104
104
|
- scenarios/rails51.dockerfile
|
105
105
|
- scenarios/rails51.gemfile
|
106
|
+
- scenarios/rails52.docker-compose.yml
|
107
|
+
- scenarios/rails52.dockerfile
|
108
|
+
- scenarios/rails52.gemfile
|
109
|
+
- scenarios/rails60.docker-compose.yml
|
110
|
+
- scenarios/rails60.dockerfile
|
111
|
+
- scenarios/rails60.gemfile
|
106
112
|
- spec/config/config.ru
|
107
113
|
- spec/config/database.yml
|
108
114
|
- spec/config/environment.rb
|
@@ -119,7 +125,7 @@ homepage: https://github.com/rweng/pry-rails
|
|
119
125
|
licenses:
|
120
126
|
- MIT
|
121
127
|
metadata: {}
|
122
|
-
post_install_message:
|
128
|
+
post_install_message:
|
123
129
|
rdoc_options: []
|
124
130
|
require_paths:
|
125
131
|
- lib
|
@@ -134,9 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
140
|
- !ruby/object:Gem::Version
|
135
141
|
version: '0'
|
136
142
|
requirements: []
|
137
|
-
|
138
|
-
|
139
|
-
signing_key:
|
143
|
+
rubygems_version: 3.4.1
|
144
|
+
signing_key:
|
140
145
|
specification_version: 4
|
141
146
|
summary: Use Pry as your rails console
|
142
147
|
test_files:
|