Sha256: d7254a821ad3d42e41cb846226b5c020713de0629d95338748e6a7f5339a4070

Contents?: true

Size: 959 Bytes

Versions: 12

Compression:

Stored size: 959 Bytes

Contents

class PryRails::RecognizePath < Pry::ClassCommand
  match 'recognize-path'
  group 'Rails'
  description 'See which route matches a URL.'
  command_options argument_required: true
  banner <<-BANNER
    Usage: recognize-path <path> [-m|--method METHOD]

    Verifies that a given path is mapped to the right controller and action.

    recognize-path example.com
    recognize-path example.com -m post
  BANNER

  def options(opt)
    opt.on :m, :method, "Methods", :argument => true
  end

  def process(path)
    method = (opts.m? ? opts[:m] : :get)
    routes = Rails.application.routes

    begin
      info = routes.recognize_path("http://#{path}", :method => method)
    rescue ActionController::UnknownHttpMethod
      output.puts "Unknown HTTP method: #{method}"
    rescue ActionController::RoutingError => e
      output.puts e
    end

    output.puts Pry::Helpers::BaseHelpers.colorize_code(info)
  end

  PryRails::Commands.add_command(self)
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
pry-rails-0.3.11 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.10 lib/pry-rails/commands/recognize_path.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-rails-0.3.9/lib/pry-rails/commands/recognize_path.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-rails-0.3.9/lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.9 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.8 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.7 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.6 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.5 lib/pry-rails/commands/recognize_path.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/pry-rails-0.3.4/lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.4 lib/pry-rails/commands/recognize_path.rb
pry-rails-0.3.3 lib/pry-rails/commands/recognize_path.rb