versioncake 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/Gemfile.lock +31 -29
- data/README.md +13 -10
- data/gemfiles/rails3.2.gemfile.lock +1 -1
- data/gemfiles/rails4.0.gemfile.lock +1 -1
- data/gemfiles/rails4.1.gemfile.lock +1 -1
- data/gemfiles/rails4.2.gemfile.lock +1 -1
- data/gemfiles/rails5.0.gemfile.lock +1 -1
- data/lib/versioncake/configuration.rb +0 -24
- data/lib/versioncake/version.rb +1 -1
- data/lib/versioncake/view_additions.rb +4 -1
- data/spec/unit/configuration_spec.rb +1 -58
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b123482ee49261b07fe0401505628dbeec8ac0d
|
4
|
+
data.tar.gz: 7328d725356e07f50637f42e142d8bfae143804f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52bdf13972f46c24260222d3030ada9d6e9debbb9caa04b4881711ae17b232d2a8c4b999339b9572d9e790e49a197c1955e73757eac8f6e7d0909d9d1979146
|
7
|
+
data.tar.gz: 3b67d99ef5758d3d116abb6f3dc67bdefd3d9aeed365378ebc65529b430e74913f093be3d6045764a2eceb7f71195e9cdf7bf2dd5b27649bb86cd6576f4c4f42
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Unreleased Changes
|
2
2
|
|
3
|
-
[Full Changelog](https://github.com/bwillis/versioncake/compare/v3.
|
3
|
+
[Full Changelog](https://github.com/bwillis/versioncake/compare/v3.4...master)
|
4
4
|
|
5
5
|
Bug Fixes:
|
6
6
|
|
@@ -14,6 +14,20 @@ Deprecations:
|
|
14
14
|
|
15
15
|
* None
|
16
16
|
|
17
|
+
## 3.4.0 (March 4, 2018)
|
18
|
+
|
19
|
+
Bug Fixes:
|
20
|
+
|
21
|
+
* don't replace frozen strings to support Rails v5.2 (#72) thanks [Bartosz Bonisławski](https://github.com/bbonislawski)
|
22
|
+
|
23
|
+
Enhancements:
|
24
|
+
|
25
|
+
* None
|
26
|
+
|
27
|
+
Deprecations:
|
28
|
+
|
29
|
+
* None
|
30
|
+
|
17
31
|
## 3.3.0 (May 7, 2017)
|
18
32
|
|
19
33
|
Bug Fixes:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
versioncake (3.
|
4
|
+
versioncake (3.4.0)
|
5
5
|
actionpack (>= 3.2)
|
6
6
|
activesupport (>= 3.2)
|
7
7
|
railties (>= 3.2)
|
@@ -10,20 +10,20 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionpack (5.1.
|
14
|
-
actionview (= 5.1.
|
15
|
-
activesupport (= 5.1.
|
13
|
+
actionpack (5.1.4)
|
14
|
+
actionview (= 5.1.4)
|
15
|
+
activesupport (= 5.1.4)
|
16
16
|
rack (~> 2.0)
|
17
|
-
rack-test (
|
17
|
+
rack-test (>= 0.6.3)
|
18
18
|
rails-dom-testing (~> 2.0)
|
19
19
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
20
|
-
actionview (5.1.
|
21
|
-
activesupport (= 5.1.
|
20
|
+
actionview (5.1.4)
|
21
|
+
activesupport (= 5.1.4)
|
22
22
|
builder (~> 3.1)
|
23
23
|
erubi (~> 1.4)
|
24
24
|
rails-dom-testing (~> 2.0)
|
25
25
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
26
|
-
activesupport (5.1.
|
26
|
+
activesupport (5.1.4)
|
27
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
28
|
i18n (~> 0.7)
|
29
29
|
minitest (~> 5.1)
|
@@ -40,33 +40,35 @@ GEM
|
|
40
40
|
term-ansicolor (~> 1.3)
|
41
41
|
thor (~> 0.19.4)
|
42
42
|
tins (~> 1.6)
|
43
|
+
crass (1.0.2)
|
43
44
|
diff-lcs (1.3)
|
44
45
|
docile (1.1.5)
|
45
|
-
erubi (1.
|
46
|
-
i18n (0.8.
|
46
|
+
erubi (1.7.0)
|
47
|
+
i18n (0.8.6)
|
47
48
|
json (2.1.0)
|
48
|
-
loofah (2.
|
49
|
+
loofah (2.1.1)
|
50
|
+
crass (~> 1.0.2)
|
49
51
|
nokogiri (>= 1.5.9)
|
50
|
-
method_source (0.
|
51
|
-
mini_portile2 (2.
|
52
|
-
minitest (5.10.
|
53
|
-
nokogiri (1.
|
54
|
-
mini_portile2 (~> 2.
|
55
|
-
rack (2.0.
|
56
|
-
rack-test (0.
|
57
|
-
rack (>= 1.0)
|
58
|
-
rails-dom-testing (2.0.
|
59
|
-
activesupport (>= 4.2.0
|
60
|
-
nokogiri (
|
52
|
+
method_source (0.9.0)
|
53
|
+
mini_portile2 (2.3.0)
|
54
|
+
minitest (5.10.3)
|
55
|
+
nokogiri (1.8.1)
|
56
|
+
mini_portile2 (~> 2.3.0)
|
57
|
+
rack (2.0.3)
|
58
|
+
rack-test (0.7.0)
|
59
|
+
rack (>= 1.0, < 3)
|
60
|
+
rails-dom-testing (2.0.3)
|
61
|
+
activesupport (>= 4.2.0)
|
62
|
+
nokogiri (>= 1.6)
|
61
63
|
rails-html-sanitizer (1.0.3)
|
62
64
|
loofah (~> 2.0)
|
63
|
-
railties (5.1.
|
64
|
-
actionpack (= 5.1.
|
65
|
-
activesupport (= 5.1.
|
65
|
+
railties (5.1.4)
|
66
|
+
actionpack (= 5.1.4)
|
67
|
+
activesupport (= 5.1.4)
|
66
68
|
method_source
|
67
69
|
rake (>= 0.8.7)
|
68
70
|
thor (>= 0.18.1, < 2.0)
|
69
|
-
rake (12.
|
71
|
+
rake (12.1.0)
|
70
72
|
rspec (3.6.0)
|
71
73
|
rspec-core (~> 3.6.0)
|
72
74
|
rspec-expectations (~> 3.6.0)
|
@@ -79,7 +81,7 @@ GEM
|
|
79
81
|
rspec-mocks (3.6.0)
|
80
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
83
|
rspec-support (~> 3.6.0)
|
82
|
-
rspec-rails (3.6.
|
84
|
+
rspec-rails (3.6.1)
|
83
85
|
actionpack (>= 3.0)
|
84
86
|
activesupport (>= 3.0)
|
85
87
|
railties (>= 3.0)
|
@@ -92,12 +94,12 @@ GEM
|
|
92
94
|
docile (~> 1.1.0)
|
93
95
|
json (>= 1.8, < 3)
|
94
96
|
simplecov-html (~> 0.10.0)
|
95
|
-
simplecov-html (0.10.
|
97
|
+
simplecov-html (0.10.2)
|
96
98
|
term-ansicolor (1.6.0)
|
97
99
|
tins (~> 1.0)
|
98
100
|
thor (0.19.4)
|
99
101
|
thread_safe (0.3.6)
|
100
|
-
tins (1.
|
102
|
+
tins (1.15.0)
|
101
103
|
tzinfo (1.2.3)
|
102
104
|
thread_safe (~> 0.1)
|
103
105
|
|
data/README.md
CHANGED
@@ -34,15 +34,16 @@ rails g versioncake:install
|
|
34
34
|
|
35
35
|
### Requirements
|
36
36
|
|
37
|
-
| Version | Rails 3.2 Support? | Rails 4 Support? | Rails >4.1 Support? | Rails >5 Support? | [Rails API](https://github.com/rails-api/rails-api) 0.2 Support? |
|
38
|
-
| -------:|:---------:| -------:| -------:| -------:| -------:|
|
39
|
-
| [1.0](CHANGELOG.md#100-march-14-2013) | Yes | No | No | No | No |
|
40
|
-
| [1.1](CHANGELOG.md#110-may-18-2013) | Yes | No | No | No | No |
|
41
|
-
| [1.2](CHANGELOG.md#120-may-26-2013) | Yes | Yes | No | No | No |
|
42
|
-
| [1.3](CHANGELOG.md#130-sept-26-2013) | Yes | Yes | No | No | No |
|
43
|
-
| [>2.0](CHANGELOG.md#200-feb-6-2014) | Yes | Yes | Yes | No | No |
|
44
|
-
| [>2.4](CHANGELOG.md#200-feb-6-2014) | Yes | Yes | Yes | No | Yes |
|
45
|
-
| [>3.0](CHANGELOG.md) | Yes | Yes | Yes | Yes | Yes |
|
37
|
+
| Version | Rails 3.2 Support? | Rails 4 Support? | Rails >4.1 Support? | Rails >5 Support? | Rails >5.2 Support? | [Rails API](https://github.com/rails-api/rails-api) 0.2 Support? |
|
38
|
+
| -------:|:---------:| -------:| -------:| -------:| -------:| -------:|
|
39
|
+
| [1.0](CHANGELOG.md#100-march-14-2013) | Yes | No | No | No | No | No |
|
40
|
+
| [1.1](CHANGELOG.md#110-may-18-2013) | Yes | No | No | No | No | No |
|
41
|
+
| [1.2](CHANGELOG.md#120-may-26-2013) | Yes | Yes | No | No | No | No |
|
42
|
+
| [1.3](CHANGELOG.md#130-sept-26-2013) | Yes | Yes | No | No | No | No |
|
43
|
+
| [>2.0](CHANGELOG.md#200-feb-6-2014) | Yes | Yes | Yes | No | No | No |
|
44
|
+
| [>2.4](CHANGELOG.md#200-feb-6-2014) | Yes | Yes | Yes | No | No | Yes |
|
45
|
+
| [>3.0](CHANGELOG.md) | Yes | Yes | Yes | Yes | No | Yes |
|
46
|
+
| [>3.3](CHANGELOG.md) | Yes | Yes | Yes | Yes | Yes | Yes |
|
46
47
|
|
47
48
|
## Upgrade v2.0 -> v3.0
|
48
49
|
|
@@ -252,7 +253,7 @@ Strategy | Description | Example
|
|
252
253
|
:path_parameter | version in the url path parameter | `api/v:api_version/`
|
253
254
|
:request_parameter | version that is sent in the body of the request | Good for testing.
|
254
255
|
:http_header | Api version HTTP header | `API-Version: 1`
|
255
|
-
:http_accept_parameter | HTTP Accept header | `Accept: application/xml;
|
256
|
+
:http_accept_parameter | HTTP Accept header | `Accept: application/xml; api_version=1` [why do this?](http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned)
|
256
257
|
custom | takes the request object and must return an integer | lambda {|request| request.headers["HTTP_X_MY_VERSION"].to_i } or class ExtractorStrategy; def execute(request);end;end
|
257
258
|
|
258
259
|
If you use the path_parameter strategy with resources routes, you will want to setup your routes.rb config file to capture the api version. You can do that in a few ways. If you have just a few api routes you might specify the path directly like this:
|
@@ -433,6 +434,8 @@ Thanks to all those who have helped make Version Cake really sweet:
|
|
433
434
|
* [Jeroen K.](https://github.com/jrnkntl)
|
434
435
|
* [Masaya Myojin](https://github.com/mmyoji)
|
435
436
|
* [John Hawthorn](https://github.com/jhawthorn)
|
437
|
+
* [Ersin Akinci](https://github.com/earksiinni)
|
438
|
+
* [Bartosz Bonisławski](https://github.com/bbonislawski)
|
436
439
|
|
437
440
|
# Related Material
|
438
441
|
|
@@ -3,8 +3,6 @@ require 'active_support/core_ext/array/wrap.rb'
|
|
3
3
|
|
4
4
|
module VersionCake
|
5
5
|
class Configuration
|
6
|
-
|
7
|
-
SUPPORTED_VERSIONS_DEFAULT = (1..10)
|
8
6
|
VERSION_KEY_DEFAULT = 'api_version'
|
9
7
|
|
10
8
|
attr_reader :extraction_strategies, :response_strategies, :supported_version_numbers,
|
@@ -17,7 +15,6 @@ module VersionCake
|
|
17
15
|
@rails_view_versioning = true
|
18
16
|
@missing_version_use_unversioned_template = true
|
19
17
|
@default_version = nil
|
20
|
-
self.supported_version_numbers = SUPPORTED_VERSIONS_DEFAULT
|
21
18
|
self.extraction_strategy = [
|
22
19
|
:http_accept_parameter,
|
23
20
|
:http_header,
|
@@ -53,27 +50,6 @@ module VersionCake
|
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
56
|
-
def supported_version_numbers=(val)
|
57
|
-
@supported_version_numbers = val.respond_to?(:to_a) ? val.to_a : Array.wrap(val)
|
58
|
-
@supported_version_numbers.sort!.reverse!
|
59
|
-
end
|
60
|
-
|
61
|
-
def supported_versions(requested_version_number=nil)
|
62
|
-
@supported_version_numbers.collect do |supported_version_number|
|
63
|
-
if requested_version_number.nil? || supported_version_number <= requested_version_number
|
64
|
-
:"v#{supported_version_number}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def supports_version?(version)
|
70
|
-
@supported_version_numbers.include? version
|
71
|
-
end
|
72
|
-
|
73
|
-
def latest_version
|
74
|
-
@supported_version_numbers.first
|
75
|
-
end
|
76
|
-
|
77
53
|
def resources
|
78
54
|
builder = ResourceBuilder.new
|
79
55
|
yield builder
|
data/lib/versioncake/version.rb
CHANGED
@@ -16,7 +16,10 @@ ActionView::PathResolver.class_eval do
|
|
16
16
|
handlers: "."
|
17
17
|
})
|
18
18
|
|
19
|
-
|
19
|
+
def initialize(pattern = nil)
|
20
|
+
@pattern = pattern || ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:versions,}{.:handlers,}"
|
21
|
+
super()
|
22
|
+
end
|
20
23
|
else
|
21
24
|
ActionView::PathResolver::EXTENSIONS.replace [:locale, :formats, :versions, :handlers]
|
22
25
|
|
@@ -1,64 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe VersionCake::Configuration do
|
4
|
-
|
5
|
-
subject(:config) do
|
6
|
-
config = described_class.new
|
7
|
-
if supported_versions
|
8
|
-
config.supported_version_numbers = supported_versions
|
9
|
-
end
|
10
|
-
config
|
11
|
-
end
|
12
|
-
|
13
|
-
context '#supported_version_numbers' do
|
14
|
-
context 'by default' do
|
15
|
-
let(:supported_versions) { nil }
|
16
|
-
|
17
|
-
it 'is a logical set of version numbers' do
|
18
|
-
expect(config.supported_version_numbers).to eq (1..10).to_a.reverse
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when set with a range' do
|
23
|
-
let(:supported_versions) { (1..7) }
|
24
|
-
|
25
|
-
it { expect(config.supported_version_numbers).to eq [7,6,5,4,3,2,1] }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when set with an unordered array' do
|
29
|
-
let(:supported_versions) { [2,4,1,5,3,6,7] }
|
30
|
-
|
31
|
-
it { expect(config.supported_version_numbers).to eq [7,6,5,4,3,2,1] }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when set with a single value' do
|
35
|
-
let(:supported_versions) { 19 }
|
36
|
-
|
37
|
-
it { expect(config.supported_version_numbers).to eq [19] }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context '#supports_version?' do
|
42
|
-
let(:supported_versions) { (1..7) }
|
43
|
-
|
44
|
-
it 'is true for all supported versions' do
|
45
|
-
config.supported_version_numbers.each do |supported_version|
|
46
|
-
expect(config.supports_version?(supported_version)).to be_truthy
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'is false for other versions' do
|
51
|
-
[-2,-1,0,8,9,10].each do |unsupported_version|
|
52
|
-
expect(config.supports_version?(unsupported_version)).to be_falsey
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context '#latest_version' do
|
58
|
-
let(:supported_versions) { [4,1,3,9,2,54] }
|
59
|
-
|
60
|
-
it { expect(config.latest_version).to eq 54 }
|
61
|
-
end
|
4
|
+
subject(:config) { described_class.new }
|
62
5
|
|
63
6
|
context '#missing_version' do
|
64
7
|
before { config.missing_version = 5 }
|
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: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Jones
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
requirements: []
|
274
274
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.4.8
|
276
276
|
signing_key:
|
277
277
|
specification_version: 4
|
278
278
|
summary: Easily render versions of your rails views.
|