GithubHelp home page GithubHelp logo

journey's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

journey's Issues

Version 1.0.2 changes behavior of path helpers for non-persisted models

Here are steps to reproduce:

rails new test_app
cd test_app
rails generate scaffold User name:string
rake db:migrate

Change the beginning of app/views/users/_form.html.erb to:

<div><%= user_path(@user) %></div>
<%= form_for(@user, :url => user_path(@user)) do |f| %>
...

(add explicit URL).

Now:

§ rake test:functionals
Run options: 

# Running tests:

....E..

Finished tests in 0.237093s, 29.5243 tests/s, 37.9598 assertions/s.

  1) Error:
test_should_get_new(UsersControllerTest):
ActionView::Template::Error: No route matches {:action=>"show", :controller=>"users", :id=>#<User id: nil, name: nil, created_at: nil, updated_at: nil>}
...

This does not happen if i add gem 'journey', '1.0.1' to Gemfile.

1.0.2 confusing show and index

I upgraded to 1.0.2 and an index path of mine (localhost:3000/students) was giving this error:

No route matches {:action=>"show", :controller=>"students"}

I went back to 1.0.1 and it went back to working.

Here's the students section of my routes file:

resources :students, :only => [:show, :index] do
  resources :enrollments,          :only => [:index, :create, :destroy, :new]
  resources :advisorships,         :only => [:index]
  resources :questionnaires,       :only => [:index]
  resources :assessments,          :only => [:index],                                   :path => 'tests',  :as => 'tests'
  resources :test_attempts,        :only => [:create, :new, :destroy],                  :path => 'tests'
  resources :breadth_requirements, :only => [:index, :destroy, :new, :create, :update], :path => 'breadth'
end

journey 1.0.4 functional test environment differs from production/dev

Journey 1.0.4 appears to be stricter than an application in production is able to be.

Functional tests fail with ActionController::RoutingError: No route matches while the dev and production environment continue to work flawlessly (!)

(See also http://stackoverflow.com/questions/11466917/routing-error-when-updating-to-rails-3-2-6-or-rspec-2-11-0#comment-16419315 - and a lot of other similar reports there)

Apparently the testing environment requires exact parameter names while they are obviously invisible and thus irrelevant to the router in production. Due to this we might consider that a bug in journey.

Example:

If there is a route like this:

# rake routes
user GET    /users/:id(.:format)  users#show

Nothing tells the application the variable name (id). It can only be estimated by looking at the structure of the route definition.

Now, in a functional test on the other hand, we need to (?) declare a parameter by providing its name and assign the desired value like so:

get :show, id: @user.id
# or /users/1 in URL format

If we use a different parameter name like so:

get :show, encoded_id: @user.encoded_id

That technically still matches the route definition of /users/1. However, in a functional test, the system knows about the absence of a parameter named encoded_id and thus believes we try to use an inexistant route.

It might appear elegant to disallow that, but it fails to reflect the behaviour of the production environment while exactly that should be the goal of the testing env.

In a project I worked around that problem by adding according routes (e.g. get ':encoded_id' => 'users#show'), but as that is only necessary for the tests to run and irrelevant for production, that is, of course, very dirty.

Utils escape functions don't handle URI's with % characters

The escape_path and escape_fragment functions don't escape URI's properly when the URI contains a % character. The % character should be escaped as %25. Otherwise, when dealing with a URI which contains %, Rails will fail with a Bad URI error.

unicode urls and redirection

I have a site with URLs that include escaped utf-8, like http://kanjidamage.com/kanji/4-total-%E4%BA%86

I want to redirect from www to the naked domain, so I added the following to my routes

constraints(:host => "www.kanjidamage.com") do
  match '*source', to: redirect("http://kanjidamage.com/%{source}")
  root to: redirect("http://kanjidamage.com/")
end

The issue is, source gets escaped to for example /kanji/4-total-了, which then redirects to http://kanjidamage.com/kanji/4-total-了, which is an invalid url and everything blows up.

Normally unescaping %encoding is a good thing, but this time it is biting me. I'm not sure if this is a bug or not, but I couldn't come up with a workaround.

journey doesn't install properly

I get the following error while running the bundler, why is it failing here

Installing journey (1.0.4) [/home/foo/.rvm/gems/ruby-1.9.3-p362@bar/specifications/erubis-2.7.0.gemspec] isn't a Gem::Specification (NilClass instead).

Journey accepts empty strings for required parts

Although 70d101b fixes the generation of URLs when passed nil required params it still works with empty strings, e.g:

get '/foo/:bar', :to => 'foo#bar', :as => :foobar
>> app.foobar_path("")
=> "/foo/"

Rack::Mount raises an error in the same situation, so is a regression from Rails 3.1 to Rails 3.2. This can be fixed by changing verified_required_parts! to:

def verify_required_parts! route, parts
  tests = route.path.requirements
  route.required_parts.all? { |key|
    if tests.key? key
      /\A#{tests[key]}\Z/ === parts[key]
    elsif parts[key].to_s.empty?
      false
    else
      true
    end
  }
end

If this is acceptable I can push the fix and tests (I'll also add an integration test in Rails). I have write access to the repository but I thought I'd run it past you first out of courtesy. 😄

1.0.2 routing problem

a running rails3.2.1 application fail when updating journey from 1.01 to 1.0.2

routes.rb

  resources :sessions, :only => [:new, :create, :destroy], :path => 'login', :as =>"login"
  match "/logout" => "sessions#destroy", :as => "logout"
  root :to => 'sessions#new'

on first attempt to go to root : ex: loalhost:3000
I got this error:

Started GET "/" for 127.0.0.1 at Mon Feb 20 22:58:17 +0100 2012
Processing by SessionsController#new as HTML
  Rendered sessions/new.html.erb within layouts/application (78.1ms)
Completed 500 Internal Server Error in 422ms

ActionController::RoutingError (No route matches {:action=>"destroy", :controller=>"sessions"}):
  app/views/sessions/new.html.erb:5:in `_app_views_sessions_new_html_erb___532917218_68363088'


  Rendered C:/Soft/Dvlt/ruby/ruby187/lib/ruby/gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.0ms)

rake routes give:

     login_index POST   /login(.:format)                  sessions#create
       new_login GET    /login/new(.:format)              sessions#new
           login DELETE /login/:id(.:format)              sessions#destroy
          logout        /logout(.:format)                 sessions#destroy
info_pwd_mailbox GET    /mailboxes/:id/info_pwd(.:format) mailboxes#info_pwd
 to_list_mailbox GET    /mailboxes/:id/to_list(.:format)  mailboxes#to_list
loaddb_mailboxes POST   /mailboxes/loaddb(.:format)       mailboxes#loaddb
       mailboxes GET    /mailboxes(.:format)              mailboxes#index
                 POST   /mailboxes(.:format)              mailboxes#create
    edit_mailbox GET    /mailboxes/:id/edit(.:format)     mailboxes#edit
         mailbox GET    /mailboxes/:id(.:format)          mailboxes#show
                 PUT    /mailboxes/:id(.:format)          mailboxes#update
     historiques GET    /historiques(.:format)            historiques#index
            root        /                                 sessions#new

the view is a classic login view with in line 5:

    <%= form_tag(login_path) do %>

the new method on the controller is:

  def new
  end

going back to 1.0.1 resolve the problem
any advice ?

Route params don't seem to allow periods in values

Update: This issue has evolved into something different than what was originally suspected as the problem. Read this comment for the actual issue


I've only given this a very brief look, but after upgrading to Rails 3.2.0.rc1, one of our custom routes failed to match certain paths that we expected them to match. It seems that when a route parameter's value contains periods, the match no longer succeeds.

I haven't spent any time grokking the journey codebase yet; however here's a test that I got to fail, but that I would have expected to pass.

# in test/nfa/test_simulator.rb
def test_simulate_periods
  sim = simulator_for ['/whois/:domain']
  assert_match sim, '/whois/example'
  assert_match sim, '/whois/example.com'
  assert_match sim, '/whois/www.example.com'
  refute_match sim, '/whois/'
end

version 1.0.2 breaks respond_with

I think something is wrong with the respond_with when using journey 1.0.2

i am having issues using backbone with rails and when i try to create a record it seems to respond to the wrong url.

ActionController::RoutingError (No route matches {:action=>"show", :controller=>"contacts", :account_id=>#<Contact id: 53, first_name: "eee", account_id: 1, created_at: "2012-02-21 08:19:20", updated_at: "2012-02-21 08:19:20", last_name: "eee", type: "Client">}):
app/controllers/contacts_controller.rb:15:in `create'

my controller looks like this

def create
    respond_with current_account.contacts.create(params[:contact])
end

only happens with journey 1.0.2

i had to downgrade to 1.0.1 to get it working again.

Attempt to namespace a controller

I have a view in admin namespace served by Admin::DashboardController#show. This view has url_for(:controller => 'stats', :action => 'show')

In journey 1.0.3 this works as expected. In journey 1.0.4 it fails, because it tries to namespace the controller:

ActionController::RoutingError (No route matches {:controller=>"admin/stats", :action=>"show"})

There should be an option to preserve trailing slashes

In few corner cases, application may depend on trailing slashes. For example, if we want to implement "folder"-like HTTP interface, to display folder/file info when request is "GET /folder" and folder contents with "GET /folder/".

Right now trailing slashes removed by Utils.normalize_path, but it's not conform RFC 3986, where trailing slash actually matters.

Redirect routes being selected when no valid route is available.

Hi guys,

I've been struggling for a few hours with a wrong route being generated when using url_for. I've solved why that's happening, but I believe the the symptom I was getting is a different bug.

Minimal App

To create a minimal app that highlights the problem (you can just copy paste this in)

rails new redirect_bug
cd redirect_bug
rails g scaffold user
rails g scaffold user/media_files
n
rake db:migrate

Change the routes.rb to:

RedirectBug::Application.routes.draw do
  resources :users do
    resources :media_files, controller: "User::MediaFiles"
  end
  get '/google', to: redirect("http://www.google.com")  
end

And add the following to the end of both app/views/users/index.html.erb and app/views/user/media_files/index.html.erb

<%= url_for({:foo => :bar}) %>
  • Start the server, and go to /users/.
  • Note the url at the bottom is /users?foo=bar
  • Go to /users/new.
  • Click "Create User"
  • Go to /users/1/media_files
  • Note the url at the bottom is /google?controller=user%2Fmedia_files&foo=bar

Where it occurs

As far as I can tell, this occurs on any page that has a URL that cannot itself be reverse engineered.
If you change the route from:
resources :media_files, class_name: "User::MediaFiles"
to:
resources :media_files, class_name: "user/media_files"
then the error will go away, because url_for will correctly find the route.

The bigger problem

The bigger issue is that match_routes seems to always contain all routes that have redirect as part of them, even if they don't in any way match - this means I never get a routing error.

Specifically this is my output of the hash after it has been 'scored':

{0=>[
    [0, #<Journey::Route:0x007fd6a0c23340 @name=nil, @app=#<Sprockets::Environment:0x3feb4df59204 root="/Users/iHiD/Projects/tmp/redirect_bug", paths=["/Users/iHiD/Projects/tmp/redirect_bug/app/assets/images", "/Users/iHiD/Projects/tmp/redirect_bug/app/assets/javascripts", "/Users/iHiD/Projects/tmp/redirect_bug/app/assets/stylesheets", "/Users/iHiD/Projects/tmp/redirect_bug/vendor/assets/javascripts", "/Users/iHiD/Projects/tmp/redirect_bug/vendor/assets/stylesheets", "/Users/iHiD/.rvm/gems/ruby-1.9.3-p0/gems/jquery-rails-2.1.1/vendor/assets/javascripts", "/Users/iHiD/.rvm/gems/ruby-1.9.3-p0/gems/coffee-rails-3.2.2/lib/assets/javascripts"],
         digest="9f3b95dd7ea3030dc35985c0a8020862">, @path=#<Journey::Path::Pattern:0x007fd6a0c23cf0 @anchored=false, @spec=/assets, @requirements={}, @separators="/.?", @names=[],
         @optional_names=[],
         @required_names=[],
         @re=/\A\/assets/, @offsets=[0]>, @verb=//, @ip=//, @constraints={}, @defaults={}, @required_defaults={}, @required_parts=[],
         @parts=[],
         @decorated_ast=nil, @precedence=0>
    ],
    [15, #<Journey::Route:0x007fd6a0bf2858 @name="google", @app=#<ActionDispatch::Routing::Redirect:0x007fd6a0bf49c8 @status=301, @block=#<Proc:0x007fd6a0bf49f0@/Users/iHiD/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.6/lib/action_dispatch/routing/redirection.rb:106 (lambda)>>, @path=#<Journey::Path::Pattern:0x007fd6a0bf38e8 @anchored=true, @spec=/google(.:format), @requirements={}, @separators="/.?", @names=["format"],
         @optional_names=["format"],
         @required_names=[],
         @re=nil, @offsets=nil>, @verb=/^GET$/, @ip=//, @constraints={:request_method=>/^GET$/}, @defaults={}, @required_defaults={}, @required_parts=[],
         @parts=[:format],
         @decorated_ast=/google(.:format), @precedence=15>
    ]
]}

I've just lost most of my day tracking down this (and specifically the change in the routes.rb), so I can't look into this any more at the moment, but I hope someone who has more knowledge of the code might be able to see quickly why this happens.

Also, could someone please advise me where best to post the issue with user/media_files vs User::MediaFiles not working in the same way (IMO, they should both work two-ways or one should not work at all). I'm not sure whether that falls under ActiveDispatch or here.

Thanks for all your hard work guys - I hope it's a quick one to solve!
Jez (iHiD)

Exception in sub-resource with specified module

Hope I've got the right gem - apologies in advance if not.

In my Rails app, I have some routes defined like this:

  resources :blogs do
    scope :module => :blogs do
      resources :posts
    end
  end

I am trying to have a URL like /blogs/1/posts/2, which routes to the Blogs::PostsController.

Trying to get a URL for a posts path results in an exception:

Loading development environment (Rails 3.2.12)
irb(main):001:0> include ActionDispatch::Routing::UrlFor; include Rails.application.routes.url_helpers
=> Object
irb(main):002:0> url_for(:controller => 'blogs/posts', :action => :index)
ActionController::RoutingError: No route matches {:controller=>"blogs/posts"}
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:533:in `raise_routing_error'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:529:in `rescue in generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:521:in `generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:562:in `generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:587:in `url_for'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/url_for.rb:148:in `url_for'
        from (irb):2
        from /path/to/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
        from /path/to/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
        from /path/to/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

route_set.rb:529 is a rescue for Journey::Router::RoutingError, so I commented that out (sorry, I'm not very good with the ruby debugger yet). This gave me a new trace:

Loading development environment (Rails 3.2.12)
irb(main):001:0> include ActionDispatch::Routing::UrlFor; include Rails.application.routes.url_helpers
=> Object
irb(main):002:0> url_for(:controller => 'blogs/posts', :action => :index)
Journey::Router::RoutingError: Journey::Router::RoutingError
        from /path/to/gems/journey-1.0.4/lib/journey/formatter.rb:46:in `generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:521:in `generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:562:in `generate'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:587:in `url_for'
        from /path/to/gems/actionpack-3.2.12/lib/action_dispatch/routing/url_for.rb:148:in `url_for'
        from (irb):2
        from /path/to/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
        from /path/to/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
        from /path/to/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

I looked at formatter.rb but it's greek to me. I'd try to help with a patch if someone could point me in the right direction.

By the way, defining my route this way instead, without the outer resource wrapper, works fine:

  scope :module => :blogs do
    resources :posts
  end

...but that's not what I want to do, because then the URL is like /posts/2 instead of /blogs/1/posts/2.

assets URLs fall into own routes rules

In development, on a page load, and not all but a considerable number of JS requests like:

/assets/app/models/i18n.js?body=1

do not return corresponding JS asset, but they fall into my default routes rule:

match '*all' => 'limbo#redirect_to_there'

using JRuby + Puma + Rails 3.2.11, journey 1.0.4

ActionController::RoutingError in controller specs

I'm using rspec and since i've installed journey 1.0.4 my controller-specs are failing. I now receive: ActionController::RoutingError with No route matches {:term=>"gitt", :controller=>"some_controller", :action=>"autocomplete"}
. The code lives inside a rails engine and it is possible that I don't have any routes setup because they are defined in the hosting rails app. Do I need to fiddle with the dummy application?

Everything worked with journey 1.0.3. I'm not sure if this is a regression or if it was just a coincidence that it worked before.

It would be nice if you could avoid bundling 3rd party libraries

Hello,

Trying to package journey for Fedora, I have noticed that you bundle 3rd party libraries, namely D3 and may be others (what is the origin of fsm.js?). Since Fedora prohibits bundling of libraries for good reasons [1], could you please consider removal of this library?

Also, I have the feeling that this is not essential functionality, so may be move into some optional gem would be nice.

Vit

[1] https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries

Please deprecate Journey

Based on #49, it seems that journey was deprecated. Could you please add the notice somewhere? The thing is that this might be issue for Fedora, since Fedora prohibits bundling and Journey used to be independent gem. Hence I should unbundle Journey again, but that would make no sense.

Thanks

1.0.3 -> 1.0.4 update breaks @request.host in tests

Hello

Upon updating journey from 1.0.3 to 1.0.4 test behaviour have changed in regard to subdomains.
Consider this test:

      it "returns success for correct domain" do
        @request.host = "something.example.com"
        get 'show'

        response.should be_success
      end

With 1.0.3 it get passes host data and subdomain constraints are evaluated. With 1.0.4 however get doesn't host data, resulting in different or not constraint match, which breaks behaviour completely.

Writing this test like this will work:

      it "returns success for correct domain" do
        get 'show', subdomain: "something"

        response.should be_success
      end

However @request.host method allows for setting subdomains in shared examples, which we employ in our tests.

Namespace Conflict: Journey is a very generic name

Hi. Sorry for arriving a bit late here, but we only just got round to starting an upgrade to Rails 3.2.

Unfortunately, we have a model in our project called "Journey". This causes a conflict with this new Journey module in Rails 3.2.

Firstly, is there a known way to get around this issue? (I can't think of any, but you never know.)

Secondly, could you consider renaming the project to something that isn't a common noun? Even a made-up verbal noun would be better than "journey", like "journeying", "journeyer", "travelling", or "actionjourney". Who cares to be honest, as far as I can tell no one is every actually going to type it in except the few programmers maintaining ActionPack and the project itself.

I really hope this can be resolved, in the meantime we're rolling back to Rails 3.1.

journey.gemspec references files that do not exist in its github repository

Line 13 of journey.gemspec references the following files that do not exist in the rails/journey github repository.

  • lib/journey/definition/node.rb
  • lib/journey/definition/parser.rb
  • lib/journey/definition/parser.y
  • lib/journey/definition/parser_extras.rb
  • lib/journey/definition/scanner.rb
  • .gemtest

In an excerpt from bundler:

Using journey (1.0.0.20110902101342) from git://github.com/rails/journey (at master)
journey at C:/Rubies/Ruby187/lib/ruby/gems/1.8/bundler/gems/journey-bc37b94050c0 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  ["lib/journey/definition/node.rb", "lib/journey/definition/parser.rb", "lib/journey/definition/parser.y", "lib/journey
/definition/parser_extras.rb", "lib/journey/definition/scanner.rb", ".gemtest"] are not files

Are there missing files in the repository or too many files named in the s.files line in the gemspec?

Dynamic URLs do not work anymore with journey 1.0.2

I upgraded from rails 3.2.1 to 3.2.3 and dynamic URLs did not work anymore. The problem was related to the upgrade of journey 1.0.1 to journey 1.0.3, but also the downgrade to journey 1.0.2 did not help; 1.0.2 has the same problem. 1.0.1 works fine.
The failure is caused by line 107 in formatter.rb:
journey 1.0.1: true
journey 1.0.2: parts.fetch(key) {false}

It is also the only difference between both files, so If I use journey 1.0.2 and if I replace formatter.rb from that one from journey 1.0.1, everything works fine.

In the example below you'll see, that the failure message does not match the request. The request should be routed to the action 'show_cluster', but it is routed to 'concrete_testcase', which comes in alphabetical order before 'show_cluster' ...

URL:
http://192.168.123.199:3000/test_cluster/show_cluster/93

failure message in browser:
Routing Error

No route matches {:controller=>"test_cluster", :action=>"concrete_testcase"}

Try running rake routes for more information on available routes.

rake routes:

test_cluster_show_cluster GET  /test_cluster/show_cluster/:rel_id(.:format)                         test_cluster#show_cluster
test_cluster_concrete_testcase GET  /test_cluster/concrete_testcase/:rel_id/:cluster_id(.:format)        test_cluster#concrete_testcase

routes.rb:

get "test_cluster/show_cluster/:rel_id" => "test_cluster#show_cluster", as: "test_cluster_show_cluster"
get "test_cluster/concrete_testcase/:rel_id/:cluster_id" => "test_cluster#concrete_testcase", as: "test_cluster_concrete_testcase"

Invalid characters in source code

Clean install of Rails 3 on Ubuntu 10.04 LTS, using Ruby 1.9.3p194. System locale is UTF-8.

Installing ri documentation for journey-1.0.4...
unable to convert U+03B5 from UTF-8 to US-ASCII for lib/journey/nfa/dot.rb, skipping
unable to convert U+25CB from UTF-8 to US-ASCII for lib/journey/visitors.rb, skipping

Rdoc 3.9.4, RubyGems 1.8.23.

Validating the files with uconv -f UTF-8 :

$ uconv -f UTF-8 dot.rb 
Conversion from Unicode to codepage failed at input byte position 178. Unicode: 03b5 Error: Invalid character found
$ uconv -f UTF-8 visitors.rb 
Conversion from Unicode to codepage failed at input byte position 3233. Unicode: 25cb Error: Invalid character found

Both files claim to be UTF-8 at the top.

Route#format is inconsistent for optional substrings

Route#format gets a little confused when an optional substring doesn't include a symbol argument:

#!/usr/bin/env ruby

require 'journey'

def format(path, opts = {})
  pattern = Journey::Path::Pattern.new(path)
  route = Journey::Route.new(nil, nil, pattern, {})
  route.format(opts)
end

puts format('/foo(bar)')
puts format('/foo(bar)/:baz', :baz => 42)

# output:
#
# bash-3.2$ ./journey_bug.rb
# /foo
# /foobar/42
#
# Why are these not either both foo or both foobar?

Add License information to gemfile

This will make it show up on rubygems.org. I'm doing due diligence on our gems and need to find out the licenses for all the gems. Having it show up on rubygems.org cuts out the step of having to go to the github repo.

Journey::Parser.new.parse("/:language/.*(.:format)") fails with Racc::ParseError: parse error on value "(" (LPAREN)

Using journey 1.0.4 / ruby 2.0.0 I get this error:

Journey::Parser.new.parse "/:language/.*(.:format)"
Racc::ParseError: 
parse error on value "(" (LPAREN)
    from /home/mau/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/racc/parser.rb:529:in `on_error'
    from /home/mau/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/racc/parser.rb:258:in `_racc_do_parse_c'
    from /home/mau/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/racc/parser.rb:258:in `do_parse'
    from /home/mau/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/journey-1.0.4/lib/journey/parser_extras.rb:15:in `parse'
    from (irb):2
    from /home/mau/.rbenv/versions/2.0.0-p0/bin/irb:12:in `<main>'

extra ?id= parameter when using a SimpleDelegator

I use SimpleDelegator in my application to wrap some model objects (Decorators). I noticed, that all the urls I generate using wrapped objects look like: /articles/4?id=4
I tried to figure out where to source of this id param is and locked it down to the following line in journey:

formatter.rb:39

z = Hash[options.to_a - data.to_a - route.defaults.to_a]

Both options and data contain the wrapped objects but ruby does not recognize it as the same object and it is then leftover in the options hash. The following irb session should illustrate the situation.

ruby-1.9.3-p0 :024 > class Decorator < SimpleDelegator
ruby-1.9.3-p0 :025?>   end
 => nil 
ruby-1.9.3-p0 :026 > decorator = Decorator.new('test')
 => "test" 
ruby-1.9.3-p0 :027 > [[:id, decorator]] - [[:id, decorator]]
 => [[:id, "test"]] 

I tried to figure out how Array#- is implemented but I lack the necessary C-skills to debug this one further.

1.0.3 -> 1.0.4 update breaks url_for in tests

When upgrading to journey 1.0.4 from 1.0.3 the following code breaks in test environment but works in development environment:

<%= link_to "link", url_for %>

ActionView::Template::Error:
       No route matches {}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.