Permalink
Browse files

Add support for | in Rails patterns.

  • Loading branch information...
rkh committed Nov 29, 2014
1 parent 1b8ba87 commit 50ae34b84a6ee5ce8936e908e0076782d4a45c86
Showing with 13 additions and 4 deletions.
  1. +1 −0 README.md
  2. +3 −2 mustermann-rails/README.md
  3. +2 −2 mustermann-rails/lib/mustermann/rails.rb
  4. +7 −0 mustermann-rails/spec/rails_spec.rb
View
@@ -279,6 +279,7 @@ As there has been no stable release yet, the API might still change, though I co
* `Mustermann::Sinatra#|` may now generate a Sinatra pattern instead of a real composite.
* Add syntax highlighting support for composite patterns.
* Remove routers (they were out of scope for the main gem).
* Rails patterns: Add Rails 5.0 compatibility mode, make it default.
* Improve documentation.
* **Mustermann 1.0.0** (before Sinatra 2.0)
* First stable release.
@@ -90,9 +90,10 @@ Mustermann.new('/', type: :rails, version: Rails::VERSION::STRING)
</td>
</tr>
<tr>
<td><b>|</b></td>
<td><i>expression</i> <b>|</b> <i>expression</i></td>
<td>
Starting with 3.2 compatibility mode, this will raise a `Mustermann::ParseError`. While Ruby on Rails happily parses this character, it will result in broken routes due to a buggy implementation.
3.2+ mode: This will raise a `Mustermann::ParseError`. While Ruby on Rails happily parses this character, it will result in broken routes due to a buggy implementation.<br>
5.0 mode: It will match if any of the nested expressions matches.
</td>
</tr>
<tr>
@@ -40,7 +40,7 @@ class Rails < AST::Pattern
# escapes got fixed in 4.2
version('4.2') { on(?\\) { |c| node(:char, expect(/./)) } }
# uncomment if Rails 5.0 fixes |
# version('5.0') { on(?|) { |c| node(:or) }}
# Rails 5.0 fixes |
version('5.0') { on(?|) { |c| node(:or) }}
end
end
@@ -636,5 +636,12 @@
it { should_not match(':foo') }
end
end
context '5.0' do
pattern 'foo|bar', version: '5.0' do
it { should match('foo') }
it { should match('bar') }
end
end
end
end

0 comments on commit 50ae34b

Please sign in to comment.