versioncake 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9d665c399a348be606cceacc98e2ee0e1258b1bb
4
- data.tar.gz: c174aae7c97ffed8e747790ec7adabe8991c1b2c
5
- SHA512:
6
- metadata.gz: 4f6b4d84def066ac15cdc11aff3b889926b2a5407aa1691731590c9be8cb326490449ed20484b98fd09f13f54c1cbda7dc32c7364d4933e3bed6b8fc2a302ce5
7
- data.tar.gz: dbdb751791239e414980bc39face0c7b9c8ce928d98da9be5c684b9cb8a45b3378c667bd1e3ebe3addf1dc9f32100ac1552937d5d951ab6241433ec99263b509
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ N2VhZjA2ZWU5ODU0MWVhYTQ4Nzk1NmM1OTFjNmIzYzJjZGUwZGQ5OQ==
5
+ data.tar.gz: !binary |-
6
+ M2RhOTQ5YzNiODAzY2JkMzg2NjMzM2UwMDllNjdjMjBiNjVjNDgzNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NmJiMzc5YTk5MjcwODU2MTI0M2YzOGIxYTlhM2EwOWJjZDRjYzJiOWJjMDIz
10
+ MzJmOTA0NjFhMzlhM2I5ODMyMzE4YWYzNzc5ZTMzMWNkMGJjZDdjY2RjNzE4
11
+ ODc4NDE0MmU1ZmY2ZjM1ZDc1ZmJiMTg4ZWVhODViMGU3MjkxOGE=
12
+ data.tar.gz: !binary |-
13
+ MWExYWQ1ZmI5ZThlN2Q4N2QwNTg5NDU4NzM5MzdlODQ5NzFiODczNjIxMTM1
14
+ MzUzYjQ1OGRlMTVhNDM1MmRlMWRmMDY4NzYyNTRjYzIxZDFjZTM1YTkyYjhm
15
+ ZTkxMWM2YTNkZmEyYTdhOTEzNzZlOTk5MjI3NDJlZjZmYjJjMmM=
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Unreleased Changes
2
2
 
3
- [Full Changelog](https://github.com/bwillis/versioncake/compare/v2.4...master)
3
+ [Full Changelog](https://github.com/bwillis/versioncake/compare/v2.5...master)
4
4
 
5
5
  Bug Fixes:
6
6
 
@@ -14,6 +14,14 @@ Deprecations:
14
14
 
15
15
  * None
16
16
 
17
+ ## 2.5.0 (Apr 18, 2014)
18
+
19
+ [Full Changelog](https://github.com/bwillis/versioncake/compare/v2.4...v2.5)
20
+
21
+ Bug Fixes:
22
+
23
+ * Fix issue where calling helper methods can return nil in prepended before_filters (#32)
24
+
17
25
  ## 2.4.0 (Apr 14, 2014)
18
26
 
19
27
  [Full Changelog](https://github.com/bwillis/versioncake/compare/v2.3...v2.4)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- versioncake (2.4.0)
4
+ versioncake (2.5.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
data/README.md CHANGED
@@ -34,7 +34,7 @@ gem install versioncake
34
34
  ### Requirements
35
35
 
36
36
  | Version | Rails 3.2 Support? | Rails 4 Support? | Rails 4.1 Support? | [Rails API](https://github.com/rails-api/rails-api) 0.2 Support? |
37
- | ------- |:---------:| -------:| -------:|
37
+ | ------- |:---------:| -------:| -------:| -------:|
38
38
  | [1.0](CHANGELOG.md#100-march-14-2013) | Yes | No | No | No |
39
39
  | [1.1](CHANGELOG.md#110-may-18-2013) | Yes | No | No | No |
40
40
  | [1.2](CHANGELOG.md#120-may-26-2013) | Yes | Yes | No | No |
@@ -51,7 +51,7 @@ The major breaking change to require a bump to v2.0 was the order of the extensi
51
51
 
52
52
  To make it easier to upgrade, run the following command to automatically rename these files:
53
53
 
54
- `verisoncake migrate` or `verisoncake migrate path/to/views`
54
+ `versioncake migrate` or `versioncake migrate path/to/views`
55
55
 
56
56
  ### Configuration changes
57
57
 
@@ -373,6 +373,7 @@ Thanks to all those who have helped make Version Cake really sweet:
373
373
  * [Andres Camacho](https://github.com/andresfcamacho)
374
374
  * [Yukio Mizuta](https://github.com/untidy-hair)
375
375
  * [David Butler](https://github.com/dwbutler)
376
+ * [Jeroen K.](https://github.com/jrnkntl)
376
377
 
377
378
  # Related Material
378
379
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.4.0)
4
+ versioncake (2.5.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.4.0)
4
+ versioncake (2.5.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- versioncake (2.4.0)
4
+ versioncake (2.5.0)
5
5
  actionpack (>= 3.2)
6
6
  activesupport (>= 3.2)
7
7
  railties (>= 3.2)
@@ -4,25 +4,39 @@ module VersionCake
4
4
  module ControllerAdditions
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ attr_accessor :versioned_request
8
+
9
+ # set_version is the prepend filter that will determine the version of the
10
+ # requests.
11
+ included do
12
+ prepend_before_filter :set_version
13
+ end
14
+
7
15
  # The explicit version requested by a client, this may not
8
16
  # be the rendered version and may also be nil.
9
- attr_accessor :requested_version
10
-
11
- # A boolean check to determine if the latest version is requested.
12
- attr_accessor :is_latest_version
17
+ def requested_version
18
+ versioned_request.extracted_version
19
+ end
13
20
 
14
21
  # The requested version by a client or if it's nil the latest or default
15
22
  # version configured.
16
- attr_accessor :derived_version
23
+ def derived_version
24
+ versioned_request.version
25
+ end
17
26
 
18
- # set_version is the prepend filter that will determine the version of the
19
- # requests.
20
- included do
21
- prepend_before_filter :set_version
27
+ # A boolean check to determine if the latest version is requested.
28
+ def is_latest_version
29
+ versioned_request.is_latest_version?
22
30
  end
23
31
 
24
32
  protected
25
33
 
34
+ # The current requests version information.
35
+ def versioned_request
36
+ set_version
37
+ @versioned_request
38
+ end
39
+
26
40
  # Sets the version of the request as well as several accessor variables.
27
41
  #
28
42
  # @param override_version a version number to use instead of the one extracted
@@ -30,14 +44,12 @@ module VersionCake
30
44
  #
31
45
  # @return No explicit return, but several attributes are exposed
32
46
  def set_version(override_version=nil)
33
- versioned_request = VersionCake::VersionedRequest.new(request, override_version)
34
- @requested_version = versioned_request.extracted_version
35
- @derived_version = versioned_request.version
36
- @is_latest_version = versioned_request.is_latest_version?
37
- if !versioned_request.is_version_supported?
47
+ return if @versioned_request.present? && override_version.blank?
48
+ @versioned_request = VersionCake::VersionedRequest.new(request, override_version)
49
+ if !@versioned_request.is_version_supported?
38
50
  raise UnsupportedVersionError.new('Unsupported version error')
39
51
  end
40
- @_lookup_context.versions = versioned_request.supported_versions
52
+ @_lookup_context.versions = @versioned_request.supported_versions
41
53
  end
42
54
  end
43
55
  end
@@ -1,3 +1,3 @@
1
1
  module VersionCake
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -62,4 +62,10 @@ class RendersControllerTest < ActionController::TestCase
62
62
  get :index, "api_version" => "abc"
63
63
  assert_equal "template v1", @response.body
64
64
  end
65
+
66
+ test "derived_version can be called before the before_filter and it returns the request version" do
67
+ @controller.instance_variable_set("@_lookup_context", mock(:versions= => nil))
68
+ @controller.request.stubs(:query_parameters => {:api_version => "2"})
69
+ assert_equal 2, @controller.derived_version
70
+ end
65
71
  end
@@ -18,6 +18,7 @@ class StrategyControllerTest < ActionController::TestCase
18
18
  method = (request['method'] || "get").to_sym
19
19
  response = test_case['response']
20
20
  @controller.request.stubs(:headers).returns(headers || {})
21
+ @controller.versioned_request = nil # clear out the versioned request so it's not cached
21
22
  begin
22
23
  send(method, :index, params || {})
23
24
  assert_equal(response, @response.body, custom_message(headers, params, method, response))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versioncake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones
@@ -9,132 +9,132 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-15 00:00:00.000000000 Z
12
+ date: 2014-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activesupport
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '3.2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ! '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.2'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: railties
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.2'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.2'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: tzinfo
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: test-unit
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ! '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: mocha
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ! '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ! '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: appraisal
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ! '>='
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: coveralls
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ! '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rake
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ! '>='
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ! '>='
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  description: Render versioned views automagically based on the clients requested version.
@@ -229,17 +229,17 @@ require_paths:
229
229
  - lib
230
230
  required_ruby_version: !ruby/object:Gem::Requirement
231
231
  requirements:
232
- - - '>='
232
+ - - ! '>='
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  requirements:
237
- - - '>='
237
+ - - ! '>='
238
238
  - !ruby/object:Gem::Version
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubyforge_project:
242
- rubygems_version: 2.2.2
242
+ rubygems_version: 2.0.6
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Easily render versions of your rails views.