foreign-fqdn-routing 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/foreign-fqdn-routing.gemspec +2 -2
- data/lib/foreign_fqdn_routing/routing_extensions.rb +28 -22
- data/rails/init.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "foreign-fqdn-routing"
|
8
|
-
gem.summary = %Q{
|
8
|
+
gem.summary = %Q{Adds domain, subdomain and fqdn routing support to Rails}
|
9
9
|
gem.email = "william@kyakia.com"
|
10
10
|
gem.homepage = "http://github.com/autodata/foreign-fqdn-routing"
|
11
11
|
gem.authors = ["Brian Mulloy", "Joe Scharf", "William Melody"]
|
data/VERSION.yml
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{foreign-fqdn-routing}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Mulloy", "Joe Scharf", "William Melody"]
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.rdoc_options = ["--charset=UTF-8"]
|
33
33
|
s.require_paths = ["lib"]
|
34
34
|
s.rubygems_version = %q{1.3.5}
|
35
|
-
s.summary = %q{
|
35
|
+
s.summary = %q{Adds domain, subdomain and fqdn routing support to Rails}
|
36
36
|
s.test_files = [
|
37
37
|
"test/foreign_fqdn_routing_test.rb",
|
38
38
|
"test/test_helper.rb"
|
@@ -1,19 +1,28 @@
|
|
1
1
|
module ForeignFQDNRouting
|
2
2
|
module RouteExtensions
|
3
3
|
|
4
|
-
TESTABLE_REQUEST_METHODS = [
|
5
|
-
|
4
|
+
TESTABLE_REQUEST_METHODS = [
|
5
|
+
:subdomain,
|
6
|
+
:domain,
|
7
|
+
:method,
|
8
|
+
:port,
|
9
|
+
:remote_ip,
|
10
|
+
:content_type,
|
11
|
+
:accepts,
|
12
|
+
:request_uri,
|
13
|
+
:protocol
|
14
|
+
]
|
6
15
|
|
7
16
|
def self.included(base)
|
8
17
|
base.alias_method_chain :recognition_conditions, :foreign_domain
|
9
18
|
end
|
10
19
|
|
11
|
-
def recognition_conditions_with_foreign_domain
|
20
|
+
def recognition_conditions_with_foreign_domain
|
12
21
|
result = recognition_conditions_without_foreign_domain
|
13
|
-
result << "ForeignFQDNRouting.foreign_domain?(env[:host])"
|
14
|
-
result << "!ForeignFQDNRouting.foreign_domain?(env[:host])" if conditions[:foreign_domain]
|
15
|
-
result << "ForeignFQDNRouting.foreign_fqdn?(env[:host])"
|
16
|
-
result << "!ForeignFQDNRouting.foreign_fqdn?(env[:host])"
|
22
|
+
result << "ForeignFQDNRouting.foreign_domain?(env[:host])" if conditions[:foreign_domain] == true
|
23
|
+
result << "!ForeignFQDNRouting.foreign_domain?(env[:host])" if conditions[:foreign_domain] == false
|
24
|
+
result << "ForeignFQDNRouting.foreign_fqdn?(env[:host])" if conditions[:foreign_fqdn] == true
|
25
|
+
result << "!ForeignFQDNRouting.foreign_fqdn?(env[:host])" if conditions[:foreign_fqdn] == false
|
17
26
|
|
18
27
|
conditions.each do |method, value|
|
19
28
|
if TESTABLE_REQUEST_METHODS.include? method
|
@@ -22,14 +31,11 @@ module ForeignFQDNRouting
|
|
22
31
|
else
|
23
32
|
"conditions[#{method.inspect}] === env[#{method.inspect}]"
|
24
33
|
end
|
25
|
-
else
|
26
34
|
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
35
|
+
end # conditions
|
30
36
|
result
|
31
|
-
end
|
32
|
-
end
|
37
|
+
end # def
|
38
|
+
end # RouteExtensions
|
33
39
|
|
34
40
|
module RouteSetExtensions
|
35
41
|
def self.included(base)
|
@@ -38,16 +44,16 @@ module ForeignFQDNRouting
|
|
38
44
|
|
39
45
|
def extract_request_environment_with_foreign_domain(request)
|
40
46
|
extract_request_environment_without_foreign_domain(request).merge({
|
41
|
-
:host
|
42
|
-
:method
|
43
|
-
:subdomain
|
44
|
-
:domain
|
45
|
-
:port
|
46
|
-
:remote_ip
|
47
|
+
:host => request.host,
|
48
|
+
:method => request.method,
|
49
|
+
:subdomain => request.subdomains.first.to_s,
|
50
|
+
:domain => request.domain,
|
51
|
+
:port => request.port,
|
52
|
+
:remote_ip => request.remote_ip,
|
47
53
|
:content_type => request.content_type,
|
48
|
-
:accepts
|
49
|
-
:request_uri
|
50
|
-
:protocol
|
54
|
+
:accepts => request.accepts.map(&:to_s).join(','),
|
55
|
+
:request_uri => request.request_uri,
|
56
|
+
:protocol => request.protocol
|
51
57
|
})
|
52
58
|
end
|
53
59
|
end
|
data/rails/init.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreign-fqdn-routing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Mulloy
|
@@ -63,7 +63,7 @@ rubyforge_project:
|
|
63
63
|
rubygems_version: 1.3.5
|
64
64
|
signing_key:
|
65
65
|
specification_version: 3
|
66
|
-
summary:
|
66
|
+
summary: Adds domain, subdomain and fqdn routing support to Rails
|
67
67
|
test_files:
|
68
68
|
- test/foreign_fqdn_routing_test.rb
|
69
69
|
- test/test_helper.rb
|