mholling-subdomain_routes 0.2.0 → 0.2.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/README.textile +2 -2
- data/Rakefile +3 -2
- data/VERSION.yml +1 -1
- data/rails/init.rb +1 -0
- data/spec/extraction_spec.rb +1 -11
- data/spec/recognition_spec.rb +0 -2
- data/spec/resources_spec.rb +0 -5
- data/spec/routes_spec.rb +0 -7
- data/spec/spec_helper.rb +5 -0
- data/spec/url_writing_spec.rb +0 -5
- data/spec/validations_spec.rb +0 -2
- metadata +4 -3
data/README.textile
CHANGED
@@ -12,7 +12,7 @@ The gem is called <code>SubdomainRoutes</code>, and is easy to install from GitH
|
|
12
12
|
|
13
13
|
<pre>
|
14
14
|
gem sources -a http://gems.github.com
|
15
|
-
sudo gem install mholling-
|
15
|
+
sudo gem install mholling-subdomain_routes
|
16
16
|
</pre>
|
17
17
|
|
18
18
|
In your Rails app, make sure to specify the gem dependency in environment.rb:
|
@@ -21,7 +21,7 @@ In your Rails app, make sure to specify the gem dependency in environment.rb:
|
|
21
21
|
config.gem "mholling-subdomain_routes", :lib => "subdomain_routes", :source => "http://gems.github.com"
|
22
22
|
</pre>
|
23
23
|
|
24
|
-
(Note that the SubdomainRoutes gem requires Rails 2.2 or later to run since it
|
24
|
+
(Note that the SubdomainRoutes gem requires Rails 2.2 or later to run since it changes <code>ActionController::Resources::INHERITABLE_OPTIONS</code>. If you're on an older version of Rails, you need to get with the program. ;)
|
25
25
|
|
26
26
|
Finally, you'll probably want to configure your session to work across all your subdomains. You can do this in your environment files:
|
27
27
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
begin
|
5
6
|
require 'jeweler'
|
@@ -11,12 +12,12 @@ begin
|
|
11
12
|
one or many specified subdomains. An URL will be recognised only if the host subdomain matches the
|
12
13
|
subdomain specified in the route. Route generation is also enhanced, so that the subdomain of a
|
13
14
|
generated URL (or path) will be changed if the requested route has a different subdomain to that of
|
14
|
-
the current request.
|
15
|
+
the current request. Model-based subdomain routes can also be defined.
|
15
16
|
EOF
|
16
17
|
gem.email = "mdholling@gmail.com"
|
17
18
|
gem.homepage = "http://github.com/mholling/subdomain_routes"
|
18
19
|
gem.authors = ["Matthew Hollingworth"]
|
19
|
-
gem.add_dependency 'actionpack', ">= 2.2.1"
|
20
|
+
gem.add_dependency 'actionpack', ">= 2.2.1"
|
20
21
|
gem.has_rdoc = false
|
21
22
|
|
22
23
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION.yml
CHANGED
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'subdomain_routes'
|
data/spec/extraction_spec.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "subdomain extraction" do
|
4
|
-
before(:each) do
|
5
|
-
ActionController::Routing::Routes.clear!
|
6
|
-
end
|
7
|
-
|
8
4
|
include SubdomainRoutes::SplitHost
|
9
5
|
|
10
6
|
it "should add a subdomain method to requests" do
|
@@ -12,12 +8,6 @@ describe "subdomain extraction" do
|
|
12
8
|
request.host = "admin.example.com"
|
13
9
|
request.subdomain.should == "admin"
|
14
10
|
end
|
15
|
-
|
16
|
-
describe "configuration" do
|
17
|
-
it "should have a default domain length of nil" do
|
18
|
-
SubdomainRoutes::Config.domain_length.should be_nil
|
19
|
-
end
|
20
|
-
end
|
21
11
|
|
22
12
|
it "should raise an error if no host is supplied" do
|
23
13
|
lambda { split_host(nil) }.should raise_error(SubdomainRoutes::HostNotSupplied)
|
@@ -44,7 +34,7 @@ describe "subdomain extraction" do
|
|
44
34
|
before(:each) do
|
45
35
|
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
46
36
|
end
|
47
|
-
|
37
|
+
|
48
38
|
it "should find the domain" do
|
49
39
|
domain_for_host("www.example.com").should == "example.com"
|
50
40
|
end
|
data/spec/recognition_spec.rb
CHANGED
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "subdomain route recognition" do
|
4
4
|
before(:each) do
|
5
|
-
ActionController::Routing::Routes.clear!
|
6
|
-
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
7
5
|
@request = ActionController::TestRequest.new
|
8
6
|
@request.host = "www.example.com"
|
9
7
|
@request.request_uri = "/items/2"
|
data/spec/resources_spec.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "resource" do
|
4
|
-
before(:each) do
|
5
|
-
ActionController::Routing::Routes.clear!
|
6
|
-
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
7
|
-
end
|
8
|
-
|
9
4
|
describe "mappings" do
|
10
5
|
it "should pass the specified subdomains to any nested routes" do
|
11
6
|
map_subdomain(:admin) do |admin|
|
data/spec/routes_spec.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "subdomain routes" do
|
4
|
-
before(:each) do
|
5
|
-
ActionController::Routing::Routes.clear!
|
6
|
-
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
7
|
-
end
|
8
|
-
|
9
4
|
it "should check the validity of each subdomain" do
|
10
5
|
SubdomainRoutes.should_receive(:valid_subdomain?).twice.and_return(true, true)
|
11
6
|
lambda { map_subdomain(:www, :www1) { } }.should_not raise_error
|
@@ -158,8 +153,6 @@ end
|
|
158
153
|
|
159
154
|
describe "ActionController::Routing::Routes" do
|
160
155
|
before(:each) do
|
161
|
-
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
162
|
-
ActionController::Routing::Routes.clear!
|
163
156
|
map_subdomain(:www, nil) { |www| www.root :controller => "homes", :action => "show" }
|
164
157
|
end
|
165
158
|
|
data/spec/spec_helper.rb
CHANGED
@@ -10,7 +10,12 @@ require 'action_mailer' # only required for testing optional features, not requi
|
|
10
10
|
require 'subdomain_routes'
|
11
11
|
|
12
12
|
Spec::Runner.configure do |config|
|
13
|
+
config.before(:each) do
|
14
|
+
ActionController::Routing::Routes.clear!
|
15
|
+
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
16
|
+
end
|
13
17
|
end
|
18
|
+
|
14
19
|
require 'action_controller/test_process'
|
15
20
|
require 'action_view/test_case'
|
16
21
|
|
data/spec/url_writing_spec.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "URL writing" do
|
4
|
-
before(:each) do
|
5
|
-
ActionController::Routing::Routes.clear!
|
6
|
-
SubdomainRoutes::Config.stub!(:domain_length).and_return(2)
|
7
|
-
end
|
8
|
-
|
9
4
|
{ "nil" => nil, "an IP address" => "207.192.69.152" }.each do |host_type, host|
|
10
5
|
context "when the host is #{host_type}" do
|
11
6
|
it "should raise an error when a subdomain route is requested" do
|
data/spec/validations_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mholling-subdomain_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Hollingworth
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 2.2.1
|
24
24
|
version:
|
25
|
-
description: SubdomainRoutes add subdomain conditions to the Rails routing system. Routes may be restricted to one or many specified subdomains. An URL will be recognised only if the host subdomain matches the subdomain specified in the route. Route generation is also enhanced, so that the subdomain of a generated URL (or path) will be changed if the requested route has a different subdomain to that of the current request.
|
25
|
+
description: SubdomainRoutes add subdomain conditions to the Rails routing system. Routes may be restricted to one or many specified subdomains. An URL will be recognised only if the host subdomain matches the subdomain specified in the route. Route generation is also enhanced, so that the subdomain of a generated URL (or path) will be changed if the requested route has a different subdomain to that of the current request. Model-based subdomain routes can also be defined.
|
26
26
|
email: mdholling@gmail.com
|
27
27
|
executables: []
|
28
28
|
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/subdomain_routes/split_host.rb
|
46
46
|
- lib/subdomain_routes/url_writer.rb
|
47
47
|
- lib/subdomain_routes/validations.rb
|
48
|
+
- rails/init.rb
|
48
49
|
- spec/extraction_spec.rb
|
49
50
|
- spec/recognition_spec.rb
|
50
51
|
- spec/resources_spec.rb
|