pry-rails 0.3.5 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +1 -1
- data/Rakefile +8 -1
- data/Readme.md +34 -11
- data/lib/pry-rails/commands/show_models.rb +4 -0
- data/lib/pry-rails/commands/show_routes.rb +35 -6
- data/lib/pry-rails/model_formatter.rb +22 -12
- data/lib/pry-rails/prompt.rb +29 -19
- data/lib/pry-rails/railtie.rb +2 -2
- data/lib/pry-rails/version.rb +1 -1
- data/pry-rails.gemspec +1 -1
- data/scenarios/rails30.docker-compose.yml +15 -0
- data/scenarios/rails30.dockerfile +5 -0
- data/scenarios/rails30.gemfile +7 -0
- data/scenarios/rails31.docker-compose.yml +15 -0
- data/scenarios/rails31.dockerfile +5 -0
- data/scenarios/rails31.gemfile +8 -0
- data/scenarios/rails32.docker-compose.yml +15 -0
- data/scenarios/rails32.dockerfile +5 -0
- data/scenarios/rails32.gemfile +8 -0
- data/scenarios/rails40.docker-compose.yml +15 -0
- data/scenarios/rails40.dockerfile +5 -0
- data/scenarios/rails40.gemfile +6 -0
- data/scenarios/rails41.docker-compose.yml +15 -0
- data/scenarios/rails41.dockerfile +5 -0
- data/scenarios/rails41.gemfile +7 -0
- data/scenarios/rails42.docker-compose.yml +15 -0
- data/scenarios/rails42.dockerfile +5 -0
- data/scenarios/rails42.gemfile +7 -0
- data/scenarios/rails50.docker-compose.yml +15 -0
- data/scenarios/rails50.dockerfile +5 -0
- data/scenarios/rails50.gemfile +7 -0
- data/scenarios/rails51.docker-compose.yml +15 -0
- data/scenarios/rails51.dockerfile +5 -0
- data/scenarios/rails51.gemfile +7 -0
- 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 +30 -0
- data/spec/config/environment.rb +6 -4
- data/spec/find_route_spec.rb +12 -12
- data/spec/railtie_spec.rb +8 -1
- data/spec/recognize_path_spec.rb +7 -7
- data/spec/show_model_spec.rb +4 -4
- data/spec/show_models_spec.rb +19 -5
- data/spec/show_routes_spec.rb +15 -1
- metadata +35 -12
- data/Appraisals +0 -40
- data/gemfiles/rails30.gemfile +0 -8
- data/gemfiles/rails31.gemfile +0 -9
- data/gemfiles/rails32.gemfile +0 -9
- data/gemfiles/rails40.gemfile +0 -9
- data/gemfiles/rails41.gemfile +0 -9
- data/gemfiles/rails42.gemfile +0 -9
- data/gemfiles/rails50.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41aa1ef9e06430dee0459e3bd3d33e532917e53b
|
4
|
+
data.tar.gz: ba1c80d4a6d03aacd095cb8d809ac26666dd4c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a454d20554dde8a311f9d30d839ea768b5906e4cad43c758d6783d972744aca56cd0c75ed7df56449fc18aca8b882c32df7b59266980d3ec0c79258a96c7cd0
|
7
|
+
data.tar.gz: cc3610d5d6e7691dc34f4f2f0f668fc4e0af999956fab25cfc6fb200347df8e9346d222aa94fd92066d4e9aa29382c8e566d232427c4ea77e99f35965ea0912e
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -23,7 +23,14 @@ end
|
|
23
23
|
|
24
24
|
desc 'Start the Rails console'
|
25
25
|
task :console => :development_env do
|
26
|
-
|
26
|
+
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1) ||
|
27
|
+
Rails::VERSION::MAJOR >= 6
|
28
|
+
require 'rails/command'
|
29
|
+
require 'rails/commands/console/console_command'
|
30
|
+
else
|
31
|
+
require 'rails/commands/console'
|
32
|
+
end
|
33
|
+
|
27
34
|
Rails::Console.start(Rails.application)
|
28
35
|
end
|
29
36
|
|
data/Readme.md
CHANGED
@@ -78,27 +78,50 @@ irb(main):001:0>
|
|
78
78
|
|
79
79
|
## Custom Rails prompt
|
80
80
|
|
81
|
-
If you want to include the current Rails environment and project name
|
81
|
+
If you want to permanently include the current Rails environment and project name
|
82
|
+
in the Pry prompt, put the following lines in your project's `.pryrc`:
|
82
83
|
|
83
84
|
```ruby
|
84
|
-
|
85
|
-
|
85
|
+
Pry.config.prompt = Pry::Prompt[:rails][:value]
|
86
|
+
```
|
87
|
+
|
88
|
+
If `.pryrc` could be loaded without pry-rails being available or installed,
|
89
|
+
guard against setting `Pry.config.prompt` to `nil`:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
if Pry::Prompt[:rails]
|
93
|
+
Pry.config.prompt = Pry::Prompt[:rails][:value]
|
86
94
|
end
|
87
95
|
```
|
88
96
|
|
97
|
+
Check out `change-prompt --help` for information about temporarily
|
98
|
+
changing the prompt for the current Pry session.
|
99
|
+
|
89
100
|
# Developing and Testing
|
90
101
|
|
91
|
-
|
92
|
-
|
102
|
+
This repo uses [Roadshow] to generate a [Docker Compose] file for each
|
103
|
+
supported version of Rails (with a compatible version of Ruby for each one).
|
104
|
+
|
105
|
+
To run specs across all versions, you can either [get the Roadshow tool] and
|
106
|
+
run `roadshow run`, or use Docker Compose directly:
|
107
|
+
|
108
|
+
```
|
109
|
+
$ for fn in scenarios/*.docker-compose-yml; do docker-compose -f $fn run --rm scenario; done
|
110
|
+
```
|
111
|
+
|
112
|
+
You can also manually run the Rails console and server on each version with
|
113
|
+
`roadshow run rake console` and `roadshow run rake server`, or run them on a
|
114
|
+
specific version with, e.g., `roadshow run -s rails40 rake console`.
|
93
115
|
|
94
|
-
|
95
|
-
|
96
|
-
|
116
|
+
To update the set of scenarios, edit `scenarios.yml` and run `roadshow
|
117
|
+
generate`, although the Gemfiles in the `scenarios` directory need to be
|
118
|
+
maintained manually.
|
97
119
|
|
98
|
-
|
99
|
-
|
120
|
+
[Roadshow]: https://github.com/rf-/roadshow
|
121
|
+
[Docker Compose]: https://docs.docker.com/compose/
|
122
|
+
[get the Roadshow tool]: https://github.com/rf-/roadshow/releases
|
100
123
|
|
101
124
|
# Alternative
|
102
125
|
|
103
126
|
If you want to enable pry everywhere, make sure to check out
|
104
|
-
[pry everywhere](http://lucapette.me/pry-everywhere
|
127
|
+
[pry everywhere](http://lucapette.me/pry-everywhere).
|
@@ -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
|
@@ -8,23 +8,38 @@ class PryRails::ShowRoutes < Pry::ClassCommand
|
|
8
8
|
BANNER
|
9
9
|
|
10
10
|
def options(opt)
|
11
|
-
opt.on :G, "grep", "Filter output by regular expression",
|
11
|
+
opt.on :G, "grep", "Filter output by regular expression",
|
12
|
+
:argument => true,
|
13
|
+
:as => Array
|
12
14
|
end
|
13
15
|
|
14
16
|
def process
|
15
17
|
Rails.application.reload_routes!
|
16
18
|
all_routes = Rails.application.routes.routes
|
17
19
|
|
18
|
-
formatted =
|
19
|
-
|
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
|
20
24
|
process_rails_4_and_5(all_routes)
|
21
|
-
|
25
|
+
elsif Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR >= 2
|
22
26
|
process_rails_3_2(all_routes)
|
23
27
|
else
|
24
28
|
process_rails_3_0_and_3_1(all_routes)
|
25
29
|
end
|
26
30
|
|
27
|
-
output.puts formatted
|
31
|
+
output.puts grep_routes(formatted).join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Takes an array of lines. Returns a list filtered by the conditions in
|
35
|
+
# `opts[:G]`.
|
36
|
+
def grep_routes(formatted)
|
37
|
+
return formatted unless opts[:G]
|
38
|
+
grep_opts = opts[:G]
|
39
|
+
|
40
|
+
grep_opts.reduce(formatted) do |lines, pattern|
|
41
|
+
lines.grep(Regexp.new(pattern))
|
42
|
+
end
|
28
43
|
end
|
29
44
|
|
30
45
|
# Cribbed from https://github.com/rails/rails/blob/3-1-stable/railties/lib/rails/tasks/routes.rake
|
@@ -51,12 +66,26 @@ class PryRails::ShowRoutes < Pry::ClassCommand
|
|
51
66
|
|
52
67
|
def process_rails_3_2(all_routes)
|
53
68
|
require 'rails/application/route_inspector'
|
69
|
+
|
54
70
|
Rails::Application::RouteInspector.new.format(all_routes)
|
55
71
|
end
|
56
72
|
|
57
73
|
def process_rails_4_and_5(all_routes)
|
58
74
|
require 'action_dispatch/routing/inspector'
|
59
|
-
|
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/)
|
60
89
|
end
|
61
90
|
|
62
91
|
PryRails::Commands.add_command(self)
|
@@ -49,12 +49,12 @@ module PryRails
|
|
49
49
|
|
50
50
|
model.relations.each do |other_model, ref|
|
51
51
|
options = []
|
52
|
-
options << 'autosave' if ref.options[:autosave]
|
53
|
-
options << 'autobuild' if ref.options[:autobuild]
|
54
|
-
options << 'validate' if ref.options[:validate]
|
52
|
+
options << 'autosave' if ref.options[:autosave] || ref.autosave?
|
53
|
+
options << 'autobuild' if ref.options[:autobuild] || ref.autobuilding?
|
54
|
+
options << 'validate' if ref.options[:validate] || ref.validate?
|
55
55
|
|
56
|
-
if ref.options[:dependent]
|
57
|
-
options << "dependent-#{ref.options[:dependent]}"
|
56
|
+
if ref.options[:dependent] || ref.dependent
|
57
|
+
options << "dependent-#{ref.options[:dependent] || ref.dependent}"
|
58
58
|
end
|
59
59
|
|
60
60
|
out.push format_association \
|
@@ -82,13 +82,23 @@ module PryRails
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def kind_of_relation(relation)
|
85
|
-
case relation.to_s.sub(/^Mongoid::Relations
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
85
|
+
case relation.to_s.sub(/^Mongoid::(Relations::|Association::)/, '')
|
86
|
+
when 'Referenced::Many', 'Referenced::HasMany::Proxy'
|
87
|
+
'has_many'
|
88
|
+
when 'Referenced::One', 'Referenced::HasOne::Proxy'
|
89
|
+
'has_one'
|
90
|
+
when 'Referenced::In', 'Referenced::BelongsTo::Proxy'
|
91
|
+
'belongs_to'
|
92
|
+
when 'Referenced::HasAndBelongsToMany::Proxy'
|
93
|
+
'has_and_belongs_to_many'
|
94
|
+
when 'Embedded::Many', 'Embedded::EmbedsMany::Proxy'
|
95
|
+
'embeds_many'
|
96
|
+
when 'Embedded::One', 'Embedded::EmbedsOne::Proxy'
|
97
|
+
'embeds_one'
|
98
|
+
when 'Embedded::In', 'Embedded::EmbeddedIn::Proxy'
|
99
|
+
'embedded_in'
|
100
|
+
else
|
101
|
+
'(unknown relation)'
|
92
102
|
end
|
93
103
|
end
|
94
104
|
|
data/lib/pry-rails/prompt.rb
CHANGED
@@ -13,29 +13,39 @@ module PryRails
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def project_name
|
16
|
-
|
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
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
desc = "Includes the current Rails environment and project folder name.\n" \
|
26
|
+
"[1] [project_name][Rails.env] pry(main)>"
|
27
|
+
if Pry::Prompt.respond_to?(:add)
|
28
|
+
Pry::Prompt.add 'rails', desc, %w(> *) do |target_self, nest_level, pry, sep|
|
29
|
+
"[#{pry.input_ring.size}] " \
|
30
|
+
"[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
|
31
|
+
"#{pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
|
32
|
+
"#{":#{nest_level}" unless nest_level.zero?}#{sep} "
|
33
|
+
end
|
34
|
+
else
|
35
|
+
draw_prompt = lambda do |target_self, nest_level, pry, sep|
|
29
36
|
"[#{pry.input_array.size}] " \
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
"[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
|
38
|
+
"#{pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
|
39
|
+
"#{":#{nest_level}" unless nest_level.zero?}#{sep} "
|
33
40
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
prompts = [
|
42
|
+
proc do |target_self, nest_level, pry|
|
43
|
+
draw_prompt.call(target_self, nest_level, pry, '>')
|
44
|
+
end,
|
45
|
+
proc do |target_self, nest_level, pry|
|
46
|
+
draw_prompt.call(target_self, nest_level, pry, '*')
|
47
|
+
end
|
48
|
+
]
|
49
|
+
Pry::Prompt::MAP["rails"] = {value: prompts, description: desc}
|
50
|
+
end
|
41
51
|
end
|
data/lib/pry-rails/railtie.rb
CHANGED
@@ -14,12 +14,12 @@ module PryRails
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
if Rails::VERSION::MAJOR
|
17
|
+
if Rails::VERSION::MAJOR >= 4
|
18
18
|
Rails.application.config.console = Pry
|
19
19
|
end
|
20
20
|
|
21
21
|
if (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 2) ||
|
22
|
-
Rails::VERSION::MAJOR
|
22
|
+
Rails::VERSION::MAJOR >= 4
|
23
23
|
require "rails/console/app"
|
24
24
|
require "rails/console/helpers"
|
25
25
|
TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
|
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.10.4"
|
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/rails30.dockerfile
|
8
|
+
image: pryrails_scenario_rails30
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails30:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails30.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails30: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails31.dockerfile
|
8
|
+
image: pryrails_scenario_rails31
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails31:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails31.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails31: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails32.dockerfile
|
8
|
+
image: pryrails_scenario_rails32
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails32:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails32.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails32: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails40.dockerfile
|
8
|
+
image: pryrails_scenario_rails40
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails40:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails40.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails40: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails41.dockerfile
|
8
|
+
image: pryrails_scenario_rails41
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails41:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails41.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails41: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails42.dockerfile
|
8
|
+
image: pryrails_scenario_rails42
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails42:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails42.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails42: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails50.dockerfile
|
8
|
+
image: pryrails_scenario_rails50
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails50:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails50.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails50: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails51.dockerfile
|
8
|
+
image: pryrails_scenario_rails51
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails51:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails51.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails51: {}
|
@@ -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
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
project: pryrails
|
2
|
+
|
3
|
+
shared:
|
4
|
+
from: ruby:2.4
|
5
|
+
cmd: "(bundle check || (gem install bundler && bundle install)) && bundle exec rake"
|
6
|
+
service:
|
7
|
+
volumes:
|
8
|
+
- bundle_{{scenario_name}}:/usr/local/bundle
|
9
|
+
environment:
|
10
|
+
BUNDLE_GEMFILE: scenarios/{{scenario_name}}.gemfile
|
11
|
+
volumes:
|
12
|
+
bundle_{{scenario_name}}:
|
13
|
+
|
14
|
+
scenarios:
|
15
|
+
rails30:
|
16
|
+
from: ruby:2.0
|
17
|
+
rails31:
|
18
|
+
from: ruby:2.0
|
19
|
+
rails32:
|
20
|
+
from: ruby:2.0
|
21
|
+
rails40:
|
22
|
+
from: ruby:2.3
|
23
|
+
rails41:
|
24
|
+
from: ruby:2.3
|
25
|
+
rails42: {}
|
26
|
+
rails50: {}
|
27
|
+
rails51: {}
|
28
|
+
rails52: {}
|
29
|
+
rails60:
|
30
|
+
from: ruby:2.5
|
data/spec/config/environment.rb
CHANGED
@@ -4,6 +4,11 @@ require 'active_support/core_ext'
|
|
4
4
|
|
5
5
|
require 'pry-rails'
|
6
6
|
|
7
|
+
begin
|
8
|
+
require 'mongoid'
|
9
|
+
rescue LoadError # Mongoid doesn't support Rails 3.0
|
10
|
+
end
|
11
|
+
|
7
12
|
# Initialize our test app
|
8
13
|
|
9
14
|
class TestApp < Rails::Application
|
@@ -58,9 +63,7 @@ class Pokemon < ActiveRecord::Base
|
|
58
63
|
has_many :beers, :through => :hacker
|
59
64
|
end
|
60
65
|
|
61
|
-
|
62
|
-
require 'mongoid'
|
63
|
-
|
66
|
+
if defined?(Mongoid)
|
64
67
|
class Artist
|
65
68
|
include Mongoid::Document
|
66
69
|
|
@@ -75,5 +78,4 @@ begin
|
|
75
78
|
field :name, :type => String
|
76
79
|
embedded_in :artist
|
77
80
|
end
|
78
|
-
rescue LoadError # Mongoid doesn't support Rails 3.0
|
79
81
|
end
|
data/spec/find_route_spec.rb
CHANGED
@@ -16,29 +16,29 @@ describe "find-route" do
|
|
16
16
|
|
17
17
|
it 'returns the route for a single action' do
|
18
18
|
output = mock_pry('find-route Admin::UsersController#show', 'exit-all')
|
19
|
-
output.must_match
|
20
|
-
output.wont_match
|
19
|
+
output.must_match(/show GET/)
|
20
|
+
output.wont_match(/index GET/)
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'returns all the routes for a controller' do
|
24
24
|
output = mock_pry('find-route Admin::UsersController', 'exit-all')
|
25
|
-
output.must_match
|
26
|
-
output.must_match
|
27
|
-
output.must_match
|
28
|
-
output.must_match
|
29
|
-
output.must_match
|
30
|
-
output.must_match
|
31
|
-
output.must_match
|
25
|
+
output.must_match(/index GET/)
|
26
|
+
output.must_match(/show GET/)
|
27
|
+
output.must_match(/new GET/)
|
28
|
+
output.must_match(/edit GET/)
|
29
|
+
output.must_match(/update (PATCH|PUT)/)
|
30
|
+
output.must_match(/update PUT/)
|
31
|
+
output.must_match(/destroy DELETE/)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'returns all routes for controllers under a namespace' do
|
35
35
|
output = mock_pry('find-route Admin', 'exit-all')
|
36
|
-
output.must_match
|
37
|
-
output.must_match
|
36
|
+
output.must_match(/Routes for Admin::UsersController/)
|
37
|
+
output.must_match(/Routes for Admin::ImagesController/)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns no routes found when controller is not recognized' do
|
41
41
|
output = mock_pry('find-route Foo', 'exit-all')
|
42
|
-
output.must_match
|
42
|
+
output.must_match(/No routes found/)
|
43
43
|
end
|
44
44
|
end
|
data/spec/railtie_spec.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
|
4
|
+
|
5
|
+
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1) ||
|
6
|
+
Rails::VERSION::MAJOR >= 6
|
7
|
+
require 'rails/command'
|
8
|
+
require 'rails/commands/console/console_command'
|
9
|
+
else
|
10
|
+
require 'rails/commands/console'
|
11
|
+
end
|
5
12
|
|
6
13
|
describe PryRails::Railtie do
|
7
14
|
it 'should start Pry instead of IRB and make the helpers available' do
|
data/spec/recognize_path_spec.rb
CHANGED
@@ -28,21 +28,21 @@ describe "recognize-path" do
|
|
28
28
|
|
29
29
|
it "prints info about controller/action that is bound to the given path" do
|
30
30
|
output = mock_pry('recognize-path example.com', 'exit-all')
|
31
|
-
output.must_match
|
32
|
-
output.must_match
|
31
|
+
output.must_match(/controller.+foo/)
|
32
|
+
output.must_match(/action.+index/)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "accepts short path" do
|
36
36
|
output = mock_pry('recognize-path /booms/1/edit', 'exit-all')
|
37
|
-
output.must_match
|
38
|
-
output.must_match
|
39
|
-
output.must_match
|
37
|
+
output.must_match(/action.+edit/)
|
38
|
+
output.must_match(/controller.+booms/)
|
39
|
+
output.must_match(/id.+1/)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "accepts -m switch" do
|
43
43
|
output = mock_pry('recognize-path example.com/booms -m post', 'exit-all')
|
44
|
-
output.must_match
|
45
|
-
output.must_match
|
44
|
+
output.must_match(/controller.+booms/)
|
45
|
+
output.must_match(/action.+create/)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "doesn't accept unknown methods" do
|
data/spec/show_model_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe "show-
|
5
|
+
describe "show-model" do
|
6
6
|
it "should print one ActiveRecord model" do
|
7
7
|
output = mock_pry('show-model Beer', 'exit-all')
|
8
8
|
|
@@ -32,8 +32,8 @@ Artist
|
|
32
32
|
embeds_many :instruments (validate)
|
33
33
|
MODEL
|
34
34
|
|
35
|
-
output.gsub!
|
36
|
-
output.gsub!
|
35
|
+
output.gsub!(/^ *_type: String\n/, '') # mongoid 3.0 and 3.1 differ on this
|
36
|
+
output.gsub!(/Moped::BSON/, 'BSON') # mongoid 3 and 4 differ on this
|
37
37
|
output.must_equal expected
|
38
38
|
end
|
39
39
|
end
|
@@ -50,6 +50,6 @@ MODEL
|
|
50
50
|
|
51
51
|
it "should print help if no model name is given" do
|
52
52
|
output = mock_pry('show-model', 'exit-all')
|
53
|
-
output.must_match
|
53
|
+
output.must_match(/Usage: show-model/)
|
54
54
|
end
|
55
55
|
end
|
data/spec/show_models_spec.rb
CHANGED
@@ -42,13 +42,27 @@ Instrument
|
|
42
42
|
embedded_in :artist
|
43
43
|
MODELS
|
44
44
|
|
45
|
+
internal_models = <<MODELS
|
46
|
+
ActiveRecord::InternalMetadata
|
47
|
+
key: string
|
48
|
+
value: string
|
49
|
+
created_at: datetime
|
50
|
+
updated_at: datetime
|
51
|
+
MODELS
|
52
|
+
|
53
|
+
expected_output = ar_models
|
54
|
+
|
45
55
|
if defined?(Mongoid)
|
46
|
-
output.gsub!
|
47
|
-
output.gsub!
|
48
|
-
|
49
|
-
else
|
50
|
-
output.must_equal ar_models
|
56
|
+
output.gsub!(/^ *_type: String\n/, '') # mongoid 3.0 and 3.1 differ on this
|
57
|
+
output.gsub!(/Moped::BSON/, 'BSON') # mongoid 3 and 4 differ on this
|
58
|
+
expected_output += mongoid_models
|
51
59
|
end
|
60
|
+
|
61
|
+
if Rails::VERSION::MAJOR >= 5
|
62
|
+
expected_output = internal_models + expected_output
|
63
|
+
end
|
64
|
+
|
65
|
+
output.must_equal expected_output
|
52
66
|
end
|
53
67
|
|
54
68
|
it "should highlight the given phrase with --grep" do
|
data/spec/show_routes_spec.rb
CHANGED
@@ -10,6 +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
|
+
end
|
15
|
+
|
16
|
+
it "should print a list of routes which include grep option" do
|
17
|
+
output = mock_pry('show-routes -G edit', 'exit-all')
|
18
|
+
|
19
|
+
output.must_match %r{edit_pokemon GET /pokemon/edit}
|
20
|
+
output.must_match %r{ edit_beer GET /beer/edit}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should filter list based on multiple grep options" do
|
24
|
+
output = mock_pry('show-routes -G edit -G pokemon', 'exit-all')
|
25
|
+
|
26
|
+
output.must_match %r{edit_pokemon GET /pokemon/edit}
|
27
|
+
output.wont_match %r{edit_beer}
|
14
28
|
end
|
15
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Wenglewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-30 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.10.4
|
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.10.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,18 +60,10 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
-
- Appraisals
|
64
63
|
- Gemfile
|
65
64
|
- LICENCE
|
66
65
|
- Rakefile
|
67
66
|
- Readme.md
|
68
|
-
- gemfiles/rails30.gemfile
|
69
|
-
- gemfiles/rails31.gemfile
|
70
|
-
- gemfiles/rails32.gemfile
|
71
|
-
- gemfiles/rails40.gemfile
|
72
|
-
- gemfiles/rails41.gemfile
|
73
|
-
- gemfiles/rails42.gemfile
|
74
|
-
- gemfiles/rails50.gemfile
|
75
67
|
- lib/pry-rails.rb
|
76
68
|
- lib/pry-rails/commands.rb
|
77
69
|
- lib/pry-rails/commands/find_route.rb
|
@@ -86,6 +78,37 @@ files:
|
|
86
78
|
- lib/pry-rails/railtie.rb
|
87
79
|
- lib/pry-rails/version.rb
|
88
80
|
- pry-rails.gemspec
|
81
|
+
- scenarios.yml
|
82
|
+
- scenarios/rails30.docker-compose.yml
|
83
|
+
- scenarios/rails30.dockerfile
|
84
|
+
- scenarios/rails30.gemfile
|
85
|
+
- scenarios/rails31.docker-compose.yml
|
86
|
+
- scenarios/rails31.dockerfile
|
87
|
+
- scenarios/rails31.gemfile
|
88
|
+
- scenarios/rails32.docker-compose.yml
|
89
|
+
- scenarios/rails32.dockerfile
|
90
|
+
- scenarios/rails32.gemfile
|
91
|
+
- scenarios/rails40.docker-compose.yml
|
92
|
+
- scenarios/rails40.dockerfile
|
93
|
+
- scenarios/rails40.gemfile
|
94
|
+
- scenarios/rails41.docker-compose.yml
|
95
|
+
- scenarios/rails41.dockerfile
|
96
|
+
- scenarios/rails41.gemfile
|
97
|
+
- scenarios/rails42.docker-compose.yml
|
98
|
+
- scenarios/rails42.dockerfile
|
99
|
+
- scenarios/rails42.gemfile
|
100
|
+
- scenarios/rails50.docker-compose.yml
|
101
|
+
- scenarios/rails50.dockerfile
|
102
|
+
- scenarios/rails50.gemfile
|
103
|
+
- scenarios/rails51.docker-compose.yml
|
104
|
+
- scenarios/rails51.dockerfile
|
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
|
89
112
|
- spec/config/config.ru
|
90
113
|
- spec/config/database.yml
|
91
114
|
- spec/config/environment.rb
|
data/Appraisals
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
appraise "rails30" do
|
2
|
-
gem "rails", "3.0.20"
|
3
|
-
gem "sqlite3"
|
4
|
-
end
|
5
|
-
|
6
|
-
appraise "rails31" do
|
7
|
-
gem "rails", "3.1.12"
|
8
|
-
gem "mongoid"
|
9
|
-
gem "sqlite3"
|
10
|
-
end
|
11
|
-
|
12
|
-
appraise "rails32" do
|
13
|
-
gem "rails", "3.2.21"
|
14
|
-
gem "mongoid"
|
15
|
-
gem "sqlite3"
|
16
|
-
end
|
17
|
-
|
18
|
-
appraise "rails40" do
|
19
|
-
gem "rails", "4.0.13"
|
20
|
-
gem "mongoid"
|
21
|
-
gem "sqlite3"
|
22
|
-
end
|
23
|
-
|
24
|
-
appraise "rails41" do
|
25
|
-
gem "rails", "4.1.9"
|
26
|
-
gem "mongoid"
|
27
|
-
gem "sqlite3"
|
28
|
-
end
|
29
|
-
|
30
|
-
appraise "rails42" do
|
31
|
-
gem "rails", "4.2.0"
|
32
|
-
gem "mongoid"
|
33
|
-
gem "sqlite3"
|
34
|
-
end
|
35
|
-
|
36
|
-
appraise "rails50" do
|
37
|
-
gem "rails", github: "rails/rails"
|
38
|
-
gem 'arel', github: "rails/arel"
|
39
|
-
gem "sqlite3"
|
40
|
-
end
|
data/gemfiles/rails30.gemfile
DELETED
data/gemfiles/rails31.gemfile
DELETED
data/gemfiles/rails32.gemfile
DELETED
data/gemfiles/rails40.gemfile
DELETED
data/gemfiles/rails41.gemfile
DELETED
data/gemfiles/rails42.gemfile
DELETED