final_routes 0.0.1
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.
- data/Gemfile +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +18 -0
- data/lib/final_routes.rb +7 -0
- data/lib/final_routes/engine.rb +8 -0
- data/lib/final_routes/final_route_mapper.rb +7 -0
- data/lib/final_routes/route_set_finalizer.rb +17 -0
- data/lib/final_routes/version.rb +3 -0
- metadata +66 -0
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Daniel Duvall
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= FinalRoutes
|
2
|
+
|
3
|
+
Adds support to Rails for final routes.
|
4
|
+
This project rocks and uses MIT-LICENSE.
|
5
|
+
|
6
|
+
FinalRoutes is currently licensed under the MIT free-software license. A copy
|
7
|
+
of the terms is distributed as the file MIT-LICENSE.
|
8
|
+
|
9
|
+
WARNING: This gem is slightly evil in its implementation. Use at your own
|
10
|
+
risk. Or better yet, take a peak under the hood and decide for yourself.
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
Use +final+ in your routes to create mappings that apply after all host
|
15
|
+
application routes and all engine routes.
|
16
|
+
|
17
|
+
MyRailsApp::Application.routes.draw do
|
18
|
+
# ... application routes
|
19
|
+
|
20
|
+
final do
|
21
|
+
# some catch-all route
|
22
|
+
match ':slug' => 'pages#show'
|
23
|
+
end
|
24
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
|
12
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
13
|
+
rdoc.rdoc_dir = 'rdoc'
|
14
|
+
rdoc.title = 'FinalRoutes'
|
15
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
16
|
+
rdoc.rdoc_files.include('README.rdoc')
|
17
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
18
|
+
end
|
data/lib/final_routes.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
module FinalRoutes
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
initializer 'final_routes.add_final_mapper', :before => :set_routes_reloader do |app|
|
4
|
+
app.routes.extend(FinalRoutes::RouteSetFinalizer)
|
5
|
+
ActionDispatch::Routing::Mapper.module_eval { include FinalRoutes::FinalRouteMapper }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module FinalRoutes
|
2
|
+
module RouteSetFinalizer
|
3
|
+
def add_final(blk)
|
4
|
+
(@finals ||= []) << blk
|
5
|
+
end
|
6
|
+
|
7
|
+
def clear!
|
8
|
+
@finals.clear if @finals
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@finals.each { |final| draw(&final) } if @disable_clear_and_finalize
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: final_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Duvall
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-16 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &5262220 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.10
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *5262220
|
25
|
+
description: Adds support in Rails apps for final routes, routes that are drawn after
|
26
|
+
all engines have drawn their own.
|
27
|
+
email:
|
28
|
+
- dan@mutual.io
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/final_routes/engine.rb
|
34
|
+
- lib/final_routes/final_route_mapper.rb
|
35
|
+
- lib/final_routes/route_set_finalizer.rb
|
36
|
+
- lib/final_routes/version.rb
|
37
|
+
- lib/final_routes.rb
|
38
|
+
- MIT-LICENSE
|
39
|
+
- Rakefile
|
40
|
+
- Gemfile
|
41
|
+
- README.rdoc
|
42
|
+
homepage:
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.6
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Final routes in Rails.
|
66
|
+
test_files: []
|