rails_reroute 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Will automatically pull in this gem and all its
4
+ # dependencies specified in the gemspec
5
+ gem "rails"
6
+ gem "rails_reroute", :path => File.expand_path("..", __FILE__)
7
+
8
+ # These are development dependencies
9
+ gem "rake"
10
+ gem "rspec"
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Nathaniel Barnes
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 ADDED
@@ -0,0 +1,7 @@
1
+ Rails reroute allows you to full reroute your request from within a controller without having to duplicate code across controllers. Just plug it in and it works.
2
+
3
+ class AirTrafficController < ApplicationController
4
+ def index
5
+ reroute "status"
6
+ end
7
+ end
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler"
2
+ Bundler.setup
3
+
4
+ require "rspec/core/rake_task"
5
+ Rspec::Core::RakeTask.new(:spec)
6
+
7
+ gemspec = eval(File.read("rails_reroute.gemspec"))
8
+
9
+ task :build => "#{gemspec.full_name}.gem"
10
+
11
+ file "#{gemspec.full_name}.gem" => gemspec.files + ["rails_reroute.gemspec"] do
12
+ system "gem build rails_reroute.gemspec"
13
+ system "gem install rails_reroute-0.1.gem"
14
+ end
@@ -0,0 +1,29 @@
1
+ module RailsReroute
2
+ class Railtie < Rails::Railtie
3
+ initializer "rails_reroute.initializer" do
4
+ ActionController::Base.class_eval do
5
+ def reroute new_route
6
+ new_paths = {"PATH_INFO" => "#{new_route}", "REQUEST_URI"=>"#{env["rack.url_scheme"]}://#{env["HTTP_HOST"]}#{new_route}", "REQUEST_PATH"=>"#{new_route}"}
7
+ env.keys.each_with_index do |key,idx|
8
+ env.delete(key) if idx > 29
9
+ end
10
+ env.merge! new_paths
11
+ unlock_request
12
+ Rails.application.call(env)
13
+ @_response = env["action_controller.instance"].response
14
+ @_response_body = @_response.body
15
+ end
16
+
17
+ def unlock_request
18
+ Rails.application.app.instance_eval do
19
+ if @app.kind_of? Rack::Lock
20
+ @app.instance_eval do
21
+ @mutex.unlock
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rails_reroute"
3
+ s.version = "0.1"
4
+
5
+ s.authors = ["Nathaniel Barnes"]
6
+ s.email = ["Nathaniel.R.Barnes@gmail.com"]
7
+ s.homepage = "http://github.com/NateBarnes/rails_reroute"
8
+ s.summary = "Reroute rails requests fully"
9
+ s.description = s.summary
10
+ s.rubyforge_project = "rails_reroute"
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ s.require_paths = ["lib"]
15
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_reroute
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nathaniel Barnes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Reroute rails requests fully
15
+ email:
16
+ - Nathaniel.R.Barnes@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README
25
+ - Rakefile
26
+ - lib/rails_reroute.rb
27
+ - rails_reroute.gemspec
28
+ homepage: http://github.com/NateBarnes/rails_reroute
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ segments:
41
+ - 0
42
+ hash: -2367698615116766147
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ segments:
50
+ - 0
51
+ hash: -2367698615116766147
52
+ requirements: []
53
+ rubyforge_project: rails_reroute
54
+ rubygems_version: 1.8.24
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Reroute rails requests fully
58
+ test_files: []