subrails 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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in subrails.gemspec
4
+ gemspec
@@ -0,0 +1,26 @@
1
+ # Subrails
2
+
3
+ Adding better subdomain support to raisl
4
+
5
+
6
+ # Routing
7
+
8
+ ## Methods:
9
+
10
+ ### subdomain
11
+
12
+ # An alias for constraints :subdomain => 'www' do…
13
+ subdomain :www do
14
+
15
+ end
16
+
17
+ # An alias for constraints :subdomain => /things|stuff|radsauce/ do…
18
+ subdomain :things, :stuff, :radsauce do
19
+
20
+ end
21
+
22
+
23
+ ### redirect\_to_subdomain
24
+
25
+
26
+ match 'posts(/:id)' => redirect_to_subdomain(:www, 'blog/posts/%{id}')
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ require "subrails/version"
2
+
3
+ module Subrails
4
+ end
5
+
6
+ require 'subrails/action_dispatch/routing/mapper/subdomains'
@@ -0,0 +1,26 @@
1
+ require 'action_dispatch/routing/mapper'
2
+
3
+ module ActionDispatch::Routing::Mapper::Subdomains
4
+
5
+ def subdomain *subdomains, &block
6
+ subdomain = subdomains.length == 1 ? subdomains.first.to_s : /#{subdomains.join('|')}/
7
+ constraints(:subdomain => subdomain, &block)
8
+ end
9
+
10
+ def redirect_to_subdomain subdomain, path='/', &block
11
+ redirect{ |params, req|
12
+ path = block.call(params, req) if block
13
+ path = path % params
14
+ uri = URI.parse(path)
15
+ uri.scheme = req.scheme
16
+ uri.host = req.host
17
+ uri.subdomain = subdomain
18
+ uri.port = req.port unless req.standard_port?
19
+ uri.to_s
20
+ }
21
+ end
22
+
23
+ ActionDispatch::Routing::Mapper.send :include, self
24
+
25
+ end
26
+
@@ -0,0 +1,3 @@
1
+ module Subrails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "subrails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "subrails"
7
+ s.version = Subrails::VERSION
8
+ s.authors = ["Jared Grippe"]
9
+ s.email = ["jared@change.org"]
10
+ s.homepage = "http://github.com/change/subrails"
11
+ s.summary = %q{Adding better subdomain support to rails}
12
+ s.description = %q{Adding better subdomain support to rails}
13
+
14
+ s.rubyforge_project = "subrails"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "rake"
23
+ s.add_runtime_dependency "rails", "~> 3.0.0"
24
+ s.add_runtime_dependency "uri-subdomain"
25
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subrails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jared Grippe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-18 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake
23
+ type: :development
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ prerelease: false
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rails
37
+ type: :runtime
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 3
46
+ - 0
47
+ - 0
48
+ version: 3.0.0
49
+ prerelease: false
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: uri-subdomain
53
+ type: :runtime
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ prerelease: false
64
+ requirement: *id003
65
+ description: Adding better subdomain support to rails
66
+ email:
67
+ - jared@change.org
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - Gemfile
77
+ - README.markdown
78
+ - Rakefile
79
+ - lib/subrails.rb
80
+ - lib/subrails/action_dispatch/routing/mapper/subdomains.rb
81
+ - lib/subrails/version.rb
82
+ - subrails.gemspec
83
+ has_rdoc: true
84
+ homepage: http://github.com/change/subrails
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project: subrails
113
+ rubygems_version: 1.5.3
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Adding better subdomain support to rails
117
+ test_files: []
118
+