route-deprecations 0.2.0.beta
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/route-deprecations.rb +4 -0
- data/lib/route-deprecations/route.rb +35 -0
- data/lib/route-deprecations/version.rb +3 -0
- data/route-deprecations.gemspec +20 -0
- metadata +66 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Elia Schito
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Route::Deprecations
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'route-deprecations'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install route-deprecations
|
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
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module RouteDeprecations
|
2
|
+
module Route
|
3
|
+
def self.included base
|
4
|
+
base.class_eval do
|
5
|
+
alias_method_chain :initialize, :route_deprecations
|
6
|
+
alias_method_chain :write_recognition!, :route_deprecations
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize_with_route_deprecations(segments = [], requirements = {}, conditions = {})
|
11
|
+
@deprecated = requirements.delete(:deprecated)
|
12
|
+
@definition_line = caller.find { |l| l.to_s.include? 'config/routes.rb:' }
|
13
|
+
initialize_without_deprecation_support(segments, requirements, conditions)
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_recognition_with_route_deprecations!
|
17
|
+
# Create an if structure to extract the params from a match if it occurs.
|
18
|
+
body = ''
|
19
|
+
if deprecated?
|
20
|
+
deprecation_message = "This route is deprecated: #{to_s.gsub(/ +/, ' ')}"
|
21
|
+
body += "\n::ActiveSupport::Deprecation.warn(#{deprecation_message.inspect}, [@definition_line])\n"
|
22
|
+
end
|
23
|
+
body += "params = parameter_shell.dup\n#{recognition_extraction * "\n"}\nparams"
|
24
|
+
body = "if #{recognition_conditions.join(" && ")}\n#{body}\nend"
|
25
|
+
|
26
|
+
# Build the method declaration and compile it
|
27
|
+
method_decl = "def recognize(path, env = {})\n#{body}\nend"
|
28
|
+
instance_eval method_decl, "generated code (#{__FILE__}:#{__LINE__})"
|
29
|
+
method_decl
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_reader :deprecated
|
33
|
+
alias deprecated? deprecated
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'route-deprecations/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ['Elia Schito']
|
7
|
+
gem.email = ['elia@schito.me']
|
8
|
+
gem.description = %q{Adds ability to deprecate routes from config routes}
|
9
|
+
gem.summary = %q{Deprecate `map.connect ':controller/:action'` with ease!}
|
10
|
+
gem.homepage = 'http://elia.github.com/route-deprecations'
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = "route-deprecations"
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
gem.version = RouteDeprecations::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'rails', '~> 2.3.8'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: route-deprecations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0.beta
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Elia Schito
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70326823773260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70326823773260
|
25
|
+
description: Adds ability to deprecate routes from config routes
|
26
|
+
email:
|
27
|
+
- elia@schito.me
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/route-deprecations.rb
|
38
|
+
- lib/route-deprecations/route.rb
|
39
|
+
- lib/route-deprecations/version.rb
|
40
|
+
- route-deprecations.gemspec
|
41
|
+
homepage: http://elia.github.com/route-deprecations
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>'
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.3.1
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.17
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Deprecate `map.connect ':controller/:action'` with ease!
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|