restful_route_version 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "3.0.7"
3
+ gem "rails", "~> 3.0.7"
4
4
  gem "rake"
5
5
 
6
6
  group :test do
data/README.md CHANGED
@@ -5,38 +5,38 @@
5
5
  Features
6
6
  ----------
7
7
 
8
- 1. It extends routing API of rails, letting us inherit routes between versions:
9
-
10
- ```ruby
11
- version_namespace :api do
12
- version_namespace(:v10,:cache_route => true) do
13
- resources :articles
14
- resources :comments
15
- resources :notes
16
- end
17
-
18
- version_namespace(:v11, :cache_route => true) do
19
- inherit_routes("/api/v10", :except => %w(articles))
20
- resources :articles
21
- resources :tags
22
- end
23
-
24
- version_namespace(:v12) do
25
- inherit_routes("/api/v11",:except => %w(notes))
26
- resources :lessons
27
- end
28
- end
29
- ```
8
+ * It extends routing API of rails by leting us inherit routes between versions:
9
+
10
+ ```ruby
11
+ version_namespace :api do
12
+ version_namespace(:v10,:cache_route => true) do
13
+ resources :articles
14
+ resources :comments
15
+ resources :notes
16
+ end
17
+
18
+ version_namespace(:v11, :cache_route => true) do
19
+ inherit_routes("/api/v10", :except => %w(articles))
20
+ resources :articles
21
+ resources :tags
22
+ end
23
+
24
+ version_namespace(:v12) do
25
+ inherit_routes("/api/v11",:except => %w(notes))
26
+ resources :lessons
27
+ end
28
+ end
29
+ ```
30
30
 
31
31
  Important thing to remember is only routes which were cached via `cache_route => true` can be
32
32
  reused for inheritance. Normal namespace blocks aren't cached.
33
33
 
34
- 2. Dynamically defines controllers between versions. In other words if v11 inherits 'notes' route
34
+ * Dynamically defines controllers between versions. In other words if v11 inherits 'notes' route
35
35
  from v10, and v11 doesn't have its own NotesController defined the, plugin will
36
36
  automatically define `Api::V11::NotesController` which will inherit from `Api::V10::NotesController`.
37
37
 
38
38
 
39
- 3. Inherits view files (such as index.xml.builder) between versions. For example if `V11::ArticlesController`
39
+ * Inherits view files (such as index.xml.builder) between versions. For example if `V11::ArticlesController`
40
40
  inherits `V10::ArticlesController` it will as well inherit all the view files of `v10/articles/`
41
41
  and hence there won't be any need to copy the view files around when creating new version of the API.
42
42
 
@@ -44,10 +44,11 @@ end
44
44
  Template inheritance will work out of box on Rails 3.1, but if you are still on 3.0.x series,
45
45
  you can use it now :
46
46
 
47
- ```ruby
48
- class Api::V10::BaseController < ActionController::Base
49
- restful_route_version
50
- end
51
- ```
47
+ ```ruby
48
+ class Api::V10::BaseController < ActionController::Base
49
+ restful_route_version
50
+ end
51
+ ```
52
+
53
+ * Works with Ruby 1.9.2 and Ruby 1.8.7
52
54
 
53
- 4. Works with Ruby 1.9.2 and Ruby 1.8.7
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+
3
4
  desc "Run tests"
4
5
  task :test do
5
6
  test_files = Dir["test/*_test.rb"]
@@ -18,7 +19,7 @@ begin
18
19
  gem.summary = 'Versioning your routes in Rails3'
19
20
  gem.description = 'Versioning your routes in Rails3'
20
21
  gem.email = 'gethemant@gmail.com'
21
-
22
+
22
23
  gem.homepage = 'http://github.com/gnufied/%s' % gem.name
23
24
 
24
25
  gem.authors = [ 'Hemant Kumar']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,7 +5,7 @@ require "restful_route_version/version_mapper"
5
5
  require "restful_route_version/inherited_view_resolver"
6
6
 
7
7
  module RestfulRouteVersion
8
- VERSION = '0.0.2'
8
+ VERSION = '0.0.3'
9
9
  class Railtie < Rails::Railtie
10
10
 
11
11
  initializer "restful_route_version.configure_rails_initialization" do
@@ -2,7 +2,6 @@ module RestfulRouteVersion
2
2
  module VersionMapper
3
3
  attr_accessor :cached_namespace_blocks
4
4
  def version_namespace(path, options = {}, &block)
5
- #puts "Calling version_namespace"
6
5
  path = path.to_s
7
6
  options = { :path => path, :as => path, :module => path,
8
7
  :shallow_path => path, :shallow_prefix => path }.merge!(options)
@@ -30,17 +29,14 @@ module RestfulRouteVersion
30
29
  end
31
30
 
32
31
  def skip_resource?(resources, except_options)
33
- #puts "********** incoming #{resources.inspect} and except_options #{except_options.inspect} and path #{@scope[:path]} **********"
34
32
  return false if(resources.length > 1 || except_options.blank?)
35
33
  return true if except_options.include?(resources.first.to_s)
36
34
  false
37
35
  end
38
36
 
39
37
  def inherit_routes(*entities)
40
- #puts "Current path #{@scope[:path]} and old one #{entities.first}"
41
38
  options = entities.extract_options!
42
39
  new_options = merge_except_options(options)
43
- #puts "New options are #{new_options.inspect}"
44
40
  new_options[:old_namespace] = @scope[:options][:old_namespace] || entities.dup.shift
45
41
 
46
42
 
@@ -72,12 +68,9 @@ module RestfulRouteVersion
72
68
  exclude_constants = options[:except].blank? ? [] : options[:except]
73
69
 
74
70
  controllers_to_exclude = exclude_constants.map { |x| (old_namespace + "/#{x}Controller").camelize }
75
- #puts "Old namespace is #{old_namespace}"
76
71
  old_namespace.camelize.constantize.constants.each do |constant_name|
77
- #puts "Incoming constant #{constant_name}"
78
72
  full_constant_name = old_namespace.camelize + "::" + constant_name.to_s
79
73
  new_controller_name = "#{current_namespace.camelize}::#{constant_name}"
80
- #puts "Defining constant #{new_controller_name} with parent #{full_constant_name}"
81
74
  if create_controller_dynamically?(controllers_to_exclude, full_constant_name, new_controller_name)
82
75
  create_controller_class(new_controller_name,Class.new(full_constant_name.constantize))
83
76
  end
@@ -92,7 +85,6 @@ module RestfulRouteVersion
92
85
 
93
86
 
94
87
  def create_controller_class(full_constant_name, klass_constant)
95
- #puts "Full constant_name is #{full_constant_name}"
96
88
  names = full_constant_name.split('::')
97
89
  ActiveSupport::Dependencies.dynamically_defined_constants << full_constant_name
98
90
  names.shift if names.empty? || names.first.empty?
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{restful_route_version}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Hemant Kumar"]
12
- s.date = %q{2011-06-12}
12
+ s.date = %q{2011-07-17}
13
13
  s.description = %q{Versioning your routes in Rails3}
14
14
  s.email = %q{gethemant@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  "Gemfile",
21
- "Gemfile.lock",
22
21
  "LICENSE",
23
22
  "MIT-LICENSE",
24
23
  "README.md",
@@ -76,20 +75,20 @@ Gem::Specification.new do |s|
76
75
  s.specification_version = 3
77
76
 
78
77
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
79
- s.add_runtime_dependency(%q<rails>, ["= 3.0.7"])
78
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.7"])
80
79
  s.add_runtime_dependency(%q<rake>, [">= 0"])
81
80
  s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0"])
82
81
  s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0"])
83
82
  s.add_runtime_dependency(%q<railties>, ["~> 3.0.0"])
84
83
  else
85
- s.add_dependency(%q<rails>, ["= 3.0.7"])
84
+ s.add_dependency(%q<rails>, ["~> 3.0.7"])
86
85
  s.add_dependency(%q<rake>, [">= 0"])
87
86
  s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
88
87
  s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
89
88
  s.add_dependency(%q<railties>, ["~> 3.0.0"])
90
89
  end
91
90
  else
92
- s.add_dependency(%q<rails>, ["= 3.0.7"])
91
+ s.add_dependency(%q<rails>, ["~> 3.0.7"])
93
92
  s.add_dependency(%q<rake>, [">= 0"])
94
93
  s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
95
94
  s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
@@ -1,4 +1,4 @@
1
- require_relative "test_helper"
1
+ require File.join(File.dirname(__FILE__),"test_helper")
2
2
 
3
3
  class RestfulRouteVersionDependenciesTest < Test::Unit::TestCase
4
4
  context "For RestfulRouteVersionDependencies" do
@@ -1,4 +1,4 @@
1
- require_relative "test_helper"
1
+ require File.join(File.dirname(__FILE__),"test_helper")
2
2
 
3
3
  class VersionMapperTest < Test::Unit::TestCase
4
4
  context "Versioned routing extension" do
metadata CHANGED
@@ -1,85 +1,81 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: restful_route_version
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
4
5
  prerelease:
5
- version: 0.0.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Hemant Kumar
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-12 00:00:00 +05:30
12
+ date: 2011-07-17 00:00:00.000000000 +05:30
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: rails
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2153301080 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - "="
22
- - !ruby/object:Gem::Version
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
23
22
  version: 3.0.7
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *2153301080
26
+ - !ruby/object:Gem::Dependency
28
27
  name: rake
29
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &2153298860 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *2153298860
37
+ - !ruby/object:Gem::Dependency
39
38
  name: activesupport
40
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &2153296740 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
41
+ requirements:
43
42
  - - ~>
44
- - !ruby/object:Gem::Version
43
+ - !ruby/object:Gem::Version
45
44
  version: 3.0.0
46
45
  type: :runtime
47
46
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *2153296740
48
+ - !ruby/object:Gem::Dependency
50
49
  name: actionpack
51
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &2153294880 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
52
+ requirements:
54
53
  - - ~>
55
- - !ruby/object:Gem::Version
54
+ - !ruby/object:Gem::Version
56
55
  version: 3.0.0
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *2153294880
59
+ - !ruby/object:Gem::Dependency
61
60
  name: railties
62
- requirement: &id005 !ruby/object:Gem::Requirement
61
+ requirement: &2153293420 !ruby/object:Gem::Requirement
63
62
  none: false
64
- requirements:
63
+ requirements:
65
64
  - - ~>
66
- - !ruby/object:Gem::Version
65
+ - !ruby/object:Gem::Version
67
66
  version: 3.0.0
68
67
  type: :runtime
69
68
  prerelease: false
70
- version_requirements: *id005
69
+ version_requirements: *2153293420
71
70
  description: Versioning your routes in Rails3
72
71
  email: gethemant@gmail.com
73
72
  executables: []
74
-
75
73
  extensions: []
76
-
77
- extra_rdoc_files:
74
+ extra_rdoc_files:
78
75
  - LICENSE
79
76
  - README.md
80
- files:
77
+ files:
81
78
  - Gemfile
82
- - Gemfile.lock
83
79
  - LICENSE
84
80
  - MIT-LICENSE
85
81
  - README.md
@@ -115,35 +111,32 @@ files:
115
111
  has_rdoc: true
116
112
  homepage: http://github.com/gnufied/restful_route_version
117
113
  licenses: []
118
-
119
114
  post_install_message:
120
115
  rdoc_options: []
121
-
122
- require_paths:
116
+ require_paths:
123
117
  - lib
124
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
125
119
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: -2262431187530772954
130
- segments:
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
131
125
  - 0
132
- version: "0"
133
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ hash: 4215361702864018338
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
128
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
139
133
  requirements: []
140
-
141
134
  rubyforge_project: restful_route_version
142
135
  rubygems_version: 1.6.2
143
136
  signing_key:
144
137
  specification_version: 3
145
138
  summary: Versioning your routes in Rails3
146
- test_files:
139
+ test_files:
147
140
  - test/dependency_ext_test.rb
148
141
  - test/fixture_files/a.rb
149
142
  - test/fixture_files/b.rb
@@ -1,81 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- abstract (1.0.0)
5
- actionmailer (3.0.7)
6
- actionpack (= 3.0.7)
7
- mail (~> 2.2.15)
8
- actionpack (3.0.7)
9
- activemodel (= 3.0.7)
10
- activesupport (= 3.0.7)
11
- builder (~> 2.1.2)
12
- erubis (~> 2.6.6)
13
- i18n (~> 0.5.0)
14
- rack (~> 1.2.1)
15
- rack-mount (~> 0.6.14)
16
- rack-test (~> 0.5.7)
17
- tzinfo (~> 0.3.23)
18
- activemodel (3.0.7)
19
- activesupport (= 3.0.7)
20
- builder (~> 2.1.2)
21
- i18n (~> 0.5.0)
22
- activerecord (3.0.7)
23
- activemodel (= 3.0.7)
24
- activesupport (= 3.0.7)
25
- arel (~> 2.0.2)
26
- tzinfo (~> 0.3.23)
27
- activeresource (3.0.7)
28
- activemodel (= 3.0.7)
29
- activesupport (= 3.0.7)
30
- activesupport (3.0.7)
31
- arel (2.0.10)
32
- builder (2.1.2)
33
- erubis (2.6.6)
34
- abstract (>= 1.0.0)
35
- git (1.2.5)
36
- i18n (0.5.0)
37
- jeweler (1.5.2)
38
- bundler (~> 1.0.0)
39
- git (>= 1.2.5)
40
- rake
41
- mail (2.2.19)
42
- activesupport (>= 2.3.6)
43
- i18n (>= 0.4.0)
44
- mime-types (~> 1.16)
45
- treetop (~> 1.4.8)
46
- mime-types (1.16)
47
- polyglot (0.3.1)
48
- rack (1.2.3)
49
- rack-mount (0.6.14)
50
- rack (>= 1.0.0)
51
- rack-test (0.5.7)
52
- rack (>= 1.0)
53
- rails (3.0.7)
54
- actionmailer (= 3.0.7)
55
- actionpack (= 3.0.7)
56
- activerecord (= 3.0.7)
57
- activeresource (= 3.0.7)
58
- activesupport (= 3.0.7)
59
- bundler (~> 1.0)
60
- railties (= 3.0.7)
61
- railties (3.0.7)
62
- actionpack (= 3.0.7)
63
- activesupport (= 3.0.7)
64
- rake (>= 0.8.7)
65
- thor (~> 0.14.4)
66
- rake (0.8.7)
67
- shoulda (2.11.3)
68
- thor (0.14.6)
69
- treetop (1.4.9)
70
- polyglot (>= 0.3.1)
71
- tzinfo (0.3.27)
72
-
73
- PLATFORMS
74
- ruby
75
-
76
- DEPENDENCIES
77
- bundler (~> 1.0.0)
78
- jeweler (~> 1.5.2)
79
- rails (= 3.0.7)
80
- rake
81
- shoulda