no-www-rails 0.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,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 no-www-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011 Ivan Tkalin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ no-www-rails
2
+ ============
3
+
4
+ no-www-rails is a simple rails extension, that redirects `www.yoursite` to `yoursite` using middleware.
5
+
6
+ Install (Rails 3.1.x)
7
+ ---------------------
8
+
9
+ Add it to your `Gemfile`:
10
+
11
+ gem 'no-www-rails'
12
+
13
+ No configuration required.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ module NoWwwRails
2
+ class Middleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ request = Rack::Request.new(env)
9
+
10
+ if request.host.starts_with?("www.")
11
+ [301, {"Location" => request.url.sub("//www.", "//")}, self]
12
+ else
13
+ @app.call(env)
14
+ end
15
+ end
16
+
17
+ def each(&block)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module NoWwwRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "no-www-rails/version"
2
+ require "no-www-rails/middleware"
3
+
4
+ module NoWwwRails
5
+ class NoWwwRailtie < Rails::Railtie
6
+ initializer "no_www_railtie.add_middleware" do |app|
7
+ app.middleware.use NoWwwRails::Middleware
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "no-www-rails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "no-www-rails"
7
+ s.version = NoWwwRails::VERSION
8
+ s.authors = ["Ivan Tkalin"]
9
+ s.email = ["itkalin@gmail.com"]
10
+ s.homepage = "https://github.com/ivalkeen/no-www-rails"
11
+ s.summary = %q{no-www-rails is a simple rails extension, that redirects www.yoursite to yoursite using middleware.}
12
+ s.description = %q{no-www-rails is a simple rails extension, that redirects www.yoursite to yoursite using middleware.}
13
+
14
+ s.rubyforge_project = "no-www-rails"
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_dependency 'rails', '>= 3.1.0'
23
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: no-www-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ivan Tkalin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-31 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &12891060 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12891060
25
+ description: no-www-rails is a simple rails extension, that redirects www.yoursite
26
+ to yoursite using middleware.
27
+ email:
28
+ - itkalin@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/no-www-rails.rb
39
+ - lib/no-www-rails/middleware.rb
40
+ - lib/no-www-rails/version.rb
41
+ - no-www-rails.gemspec
42
+ homepage: https://github.com/ivalkeen/no-www-rails
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project: no-www-rails
62
+ rubygems_version: 1.8.10
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: no-www-rails is a simple rails extension, that redirects www.yoursite to
66
+ yoursite using middleware.
67
+ test_files: []