rails-subdomain 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-subdomain.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Samuel Cochran
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Rails::Subdomain
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails-subdomain'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails-subdomain
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require "rails/subdomain"
@@ -0,0 +1,12 @@
1
+ require 'active_support/lazy_load_hooks'
2
+
3
+ module Rails::Subdomain
4
+ end
5
+
6
+ require 'rails/subdomain/version'
7
+ require 'rails/subdomain/cucumber' if defined? Cucumber
8
+
9
+ ActiveSupport.on_load :action_controller do
10
+ require 'rails/subdomain/mapper'
11
+ require 'rails/subdomain/url_for'
12
+ end
File without changes
@@ -0,0 +1,16 @@
1
+ class ActionDispatch::Routing::Mapper
2
+ class InvalidSubdomain < RuntimeError; end
3
+
4
+ # Some sugar to specify subdomain constraints and defaults
5
+ def subdomain subdomain, options={}, &block
6
+ subdomain = subdomain.to_s if subdomain.is_a? Symbol
7
+
8
+ default = options.delete :default
9
+ default ||= subdomain
10
+
11
+ raise InvalidSubdomain, %{Default subdomain must be a string, try `subdomain #{subdomain.inspect}, default: "blah"`} unless default.is_a? String
12
+ raise InvalidSubdomain, %{Default subdomain must match subdomain constraint} unless subdomain === default
13
+
14
+ scope options.reverse_merge(:constraints => {:subdomain => subdomain}, :defaults => {:subdomain => default}), &block
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class ActionDispatch::Routing::RouteSet
2
+ # There's no nicer way to insert this behaviour that I could find. :-(
3
+
4
+ # Rails constructs subdomain-based routes correctly, but sometimes
5
+ # need a kick in the pants when generating a path and the route
6
+ # subdomain doesn't match the current subdomain
7
+ def url_for_with_subdomain options=nil
8
+ if options.kind_of? Hash and options.has_key? :subdomain and options[:_path_segments] and options[:_path_segments][:subdomain] != options[:subdomain]
9
+ options[:only_path] = false
10
+ end
11
+
12
+ url_for_without_subdomain options
13
+ end
14
+
15
+ alias_method_chain :url_for, :subdomain
16
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module Subdomain
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rails/subdomain/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "rails-subdomain"
6
+ gem.author = "Samuel Cochran"
7
+ gem.email = "sj26@sj26.com"
8
+ gem.description = %q{Some convenience methods making subdomains in Rails a whole lot easier.}
9
+ gem.summary = %q{Rails subdomain helpers.}
10
+ gem.homepage = "https://github.com/sj26/rails-subdomain"
11
+
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {spec,features}/*`.split("\n")
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Rails::Subdomain::VERSION
16
+
17
+ gem.add_dependency 'rails', '~> 3.2.0'
18
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-subdomain
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Samuel Cochran
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70325238263920 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70325238263920
25
+ description: Some convenience methods making subdomains in Rails a whole lot easier.
26
+ email: sj26@sj26.com
27
+ executables: []
28
+ extensions: []
29
+ extra_rdoc_files: []
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - lib/rails-subdomain.rb
37
+ - lib/rails/subdomain.rb
38
+ - lib/rails/subdomain/cucumber.rb
39
+ - lib/rails/subdomain/mapper.rb
40
+ - lib/rails/subdomain/url_for.rb
41
+ - lib/rails/subdomain/version.rb
42
+ - rails-subdomain.gemspec
43
+ homepage: https://github.com/sj26/rails-subdomain
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.11
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Rails subdomain helpers.
67
+ test_files: []
68
+ has_rdoc: