pry-rails 0.3.5 → 0.3.9

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile +1 -1
  4. data/Rakefile +8 -1
  5. data/Readme.md +34 -11
  6. data/lib/pry-rails/commands/show_models.rb +4 -0
  7. data/lib/pry-rails/commands/show_routes.rb +35 -6
  8. data/lib/pry-rails/model_formatter.rb +22 -12
  9. data/lib/pry-rails/prompt.rb +29 -19
  10. data/lib/pry-rails/railtie.rb +2 -2
  11. data/lib/pry-rails/version.rb +1 -1
  12. data/pry-rails.gemspec +1 -1
  13. data/scenarios/rails30.docker-compose.yml +15 -0
  14. data/scenarios/rails30.dockerfile +5 -0
  15. data/scenarios/rails30.gemfile +7 -0
  16. data/scenarios/rails31.docker-compose.yml +15 -0
  17. data/scenarios/rails31.dockerfile +5 -0
  18. data/scenarios/rails31.gemfile +8 -0
  19. data/scenarios/rails32.docker-compose.yml +15 -0
  20. data/scenarios/rails32.dockerfile +5 -0
  21. data/scenarios/rails32.gemfile +8 -0
  22. data/scenarios/rails40.docker-compose.yml +15 -0
  23. data/scenarios/rails40.dockerfile +5 -0
  24. data/scenarios/rails40.gemfile +6 -0
  25. data/scenarios/rails41.docker-compose.yml +15 -0
  26. data/scenarios/rails41.dockerfile +5 -0
  27. data/scenarios/rails41.gemfile +7 -0
  28. data/scenarios/rails42.docker-compose.yml +15 -0
  29. data/scenarios/rails42.dockerfile +5 -0
  30. data/scenarios/rails42.gemfile +7 -0
  31. data/scenarios/rails50.docker-compose.yml +15 -0
  32. data/scenarios/rails50.dockerfile +5 -0
  33. data/scenarios/rails50.gemfile +7 -0
  34. data/scenarios/rails51.docker-compose.yml +15 -0
  35. data/scenarios/rails51.dockerfile +5 -0
  36. data/scenarios/rails51.gemfile +7 -0
  37. data/scenarios/rails52.docker-compose.yml +15 -0
  38. data/scenarios/rails52.dockerfile +5 -0
  39. data/scenarios/rails52.gemfile +7 -0
  40. data/scenarios/rails60.docker-compose.yml +15 -0
  41. data/scenarios/rails60.dockerfile +5 -0
  42. data/scenarios/rails60.gemfile +7 -0
  43. data/scenarios.yml +30 -0
  44. data/spec/config/environment.rb +6 -4
  45. data/spec/find_route_spec.rb +12 -12
  46. data/spec/railtie_spec.rb +8 -1
  47. data/spec/recognize_path_spec.rb +7 -7
  48. data/spec/show_model_spec.rb +4 -4
  49. data/spec/show_models_spec.rb +19 -5
  50. data/spec/show_routes_spec.rb +15 -1
  51. metadata +35 -12
  52. data/Appraisals +0 -40
  53. data/gemfiles/rails30.gemfile +0 -8
  54. data/gemfiles/rails31.gemfile +0 -9
  55. data/gemfiles/rails32.gemfile +0 -9
  56. data/gemfiles/rails40.gemfile +0 -9
  57. data/gemfiles/rails41.gemfile +0 -9
  58. data/gemfiles/rails42.gemfile +0 -9
  59. data/gemfiles/rails50.gemfile +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8fd6ae367ba116b763e2a8b73f7e344bf88d339
4
- data.tar.gz: 386621db935531fa72a9283fcb7f088e9d279f2b
3
+ metadata.gz: 41aa1ef9e06430dee0459e3bd3d33e532917e53b
4
+ data.tar.gz: ba1c80d4a6d03aacd095cb8d809ac26666dd4c10
5
5
  SHA512:
6
- metadata.gz: d71528bac8e319bd6878f7b182c2eb66499fcb9dc627f336a5cd224de963df5251fde703405d4e2aaf5e3ea4c02116225364f9d4c7ccd13ee5fe369f6fbe423e
7
- data.tar.gz: b5af4a6bd4b96b9710c4acec78a8c5a65f193f936feb104198f0094371d2bff8649bf3aa47236dc83a7138104d9792a2305396e84e5f67fb42a334a4aaefda12
6
+ metadata.gz: 4a454d20554dde8a311f9d30d839ea768b5906e4cad43c758d6783d972744aca56cd0c75ed7df56449fc18aca8b882c32df7b59266980d3ec0c79258a96c7cd0
7
+ data.tar.gz: cc3610d5d6e7691dc34f4f2f0f668fc4e0af999956fab25cfc6fb200347df8e9346d222aa94fd92066d4e9aa29382c8e566d232427c4ea77e99f35965ea0912e
data/.gitignore CHANGED
@@ -4,4 +4,4 @@ Gemfile.lock
4
4
  pkg/*
5
5
  spec/log
6
6
  spec/tmp
7
- gemfiles/*.lock
7
+ scenarios/*.lock
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in pry-rails.gemspec
4
4
  gemspec
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
- require 'rails/commands/console'
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 in the pry prompt, put the following lines in your project's `.pryrc`:
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
- if defined?(PryRails::RAILS_PROMPT)
85
- Pry.config.prompt = PryRails::RAILS_PROMPT
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
- To generate Gemfiles for Rails 3.0, 3.1, 3.2, 4.0, 4.1, and 4.2, run `rake
92
- appraisal:gemfiles appraisal:install`.
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
- You can then run the tests across all four versions with `rake appraisal`. You
95
- can also manually run the Rails console and server with `rake appraisal
96
- console` and `rake appraisal server`.
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
- For a specific version of Rails, use `rake appraisal:rails30`, `rake
99
- appraisal:rails31`, `rake appraisal:rails32`, etc.
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", :argument => true
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 = case Rails.version.to_s
19
- when /^[45]/
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
- when /^3\.2/
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.grep(Regexp.new(opts[:G] || ".")).join("\n")
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
- ActionDispatch::Routing::RoutesInspector.new(all_routes).format(ActionDispatch::Routing::ConsoleFormatter.new).split(/\n/)
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
- when 'Referenced::Many' then 'has_many'
87
- when 'Referenced::One' then 'has_one'
88
- when 'Referenced::In' then 'belongs_to'
89
- when 'Embedded::Many' then 'embeds_many'
90
- when 'Embedded::One' then 'embeds_one'
91
- when 'Embedded::In' then 'embedded_in'
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
 
@@ -13,29 +13,39 @@ module PryRails
13
13
  end
14
14
 
15
15
  def project_name
16
- File.basename(Rails.root)
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
- RAILS_PROMPT = [
22
- proc do |target_self, nest_level, pry|
23
- "[#{pry.input_array.size}] " \
24
- "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
25
- "#{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
26
- "#{":#{nest_level}" unless nest_level.zero?}> "
27
- end,
28
- proc do |target_self, nest_level, pry|
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
- "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \
31
- "#{Pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \
32
- "#{":#{nest_level}" unless nest_level.zero?}* "
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
- Pry::Prompt::MAP["rails"] = {
37
- value: RAILS_PROMPT,
38
- description: "Includes the current Rails environment and project folder name.\n" \
39
- "[1] [project_name][Rails.env] pry(main)>"
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
@@ -14,12 +14,12 @@ module PryRails
14
14
  end
15
15
  end
16
16
 
17
- if Rails::VERSION::MAJOR == 4 || Rails::VERSION::MAJOR == 5
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 == 4 || Rails::VERSION::MAJOR == 5
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
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module PryRails
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.9"
5
5
  end
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.9.10"
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,5 @@
1
+ FROM ruby:2.0
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.0.0"
4
+ gem "sqlite3"
5
+ gem "test-unit"
6
+
7
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.0
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.1.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+ gem "test-unit"
7
+
8
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.0
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 3.2.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+ gem "test-unit"
7
+
8
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.3
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 4.0.0"
4
+ gem "sqlite3"
5
+
6
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.3
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 4.1.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.4
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 4.2.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.4
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.0.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.4
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.1.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
@@ -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,5 @@
1
+ FROM ruby:2.4
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.2.0"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
@@ -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: {}
@@ -0,0 +1,5 @@
1
+ FROM ruby:2.5
2
+ RUN mkdir -p /scenario
3
+ WORKDIR /scenario
4
+ ENV LANG=C.UTF-8
5
+ CMD (bundle check || (gem install bundler && bundle install)) && bundle exec rake
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", github: "rails/rails"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec :path => "../"
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
@@ -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
- begin
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
@@ -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 /show GET/
20
- output.wont_match /index GET/
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 /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/
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 /Routes for Admin::UsersController/
37
- output.must_match /Routes for Admin::ImagesController/
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 /No routes found/
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
- require 'rails/commands/console'
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
@@ -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 /controller.+foo/
32
- output.must_match /action.+index/
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 /action.+edit/
38
- output.must_match /controller.+booms/
39
- output.must_match /id.+1/
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 /controller.+booms/
45
- output.must_match /action.+create/
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "show-models" do
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! /^ *_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
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 /Usage: show-model/
53
+ output.must_match(/Usage: show-model/)
54
54
  end
55
55
  end
@@ -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! /^ *_type: String\n/, '' # mongoid 3.0 and 3.1 differ on this
47
- output.gsub! /Moped::BSON/, 'BSON' # mongoid 3 and 4 differ on this
48
- output.must_equal [ar_models, mongoid_models].join
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
@@ -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{^edit_pokemon GET /pokemon/edit}
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.5
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: 2017-02-14 00:00:00.000000000 Z
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.9.10
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.9.10
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
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "3.0.20"
6
- gem "sqlite3"
7
-
8
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "3.1.12"
6
- gem "mongoid"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "3.2.21"
6
- gem "mongoid"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.0.13"
6
- gem "mongoid"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.1.9"
6
- gem "mongoid"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "4.2.0"
6
- gem "mongoid"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", :github => "rails/rails"
6
- gem "arel", :github => "rails/arel"
7
- gem "sqlite3"
8
-
9
- gemspec :path => "../"