rails_versioned_routing 1.3.1 → 1.4.0
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.
- checksums.yaml +4 -4
- data/lib/rails_versioned_routing.rb +21 -2
- data/test/dummy/app/controllers/beta/sample_controller.rb +11 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +2741 -0
- data/test/versioned_presentation_test.rb +1 -1
- data/test/versioned_routing_test.rb +16 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a6c823def2424d6e970bd71119a226a7c2411f0
|
4
|
+
data.tar.gz: f1f7ab31b4872bd0c28482fc443265b2e7afbb3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f09bceb0de1ce6ccef8d6e8e3d08a982755d50230ae59288da590bd8c65c45d4fc288c7945535d5b281904ff2485ac00bc5227d9d7c33818a3575190da58b517
|
7
|
+
data.tar.gz: 01302ea4a259af0a34f7260f73013f73d58c105ba861f8f277c6db009cd5a87299a48c4ea95dd0ee292b6ce79d43d11b089303a03f5f4a3c841a710d318ffcfd
|
@@ -1,9 +1,23 @@
|
|
1
1
|
require 'rails_versioned_routing/railtie' if defined?(Rails)
|
2
2
|
|
3
3
|
module RailsVersionedRouting
|
4
|
-
VERSION = "1.
|
4
|
+
VERSION = "1.4.0"
|
5
5
|
|
6
6
|
class VersionConstraint
|
7
|
+
end
|
8
|
+
|
9
|
+
class BetaVersionConstraint < VersionConstraint
|
10
|
+
def matches?(request)
|
11
|
+
accept = request.headers.fetch(:accept, '*/*')
|
12
|
+
accept.match(/version=beta/)
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
Float::INFINITY
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class NumberedVersionConstraint < VersionConstraint
|
7
21
|
attr_reader :version
|
8
22
|
|
9
23
|
def initialize(options)
|
@@ -191,8 +205,13 @@ module RailsVersionedRouting
|
|
191
205
|
end
|
192
206
|
end
|
193
207
|
|
208
|
+
def beta!(&routes)
|
209
|
+
api_constraint = BetaVersionConstraint.new
|
210
|
+
scope(module: 'beta', constraints: api_constraint, &routes)
|
211
|
+
end
|
212
|
+
|
194
213
|
def version(version_number, &routes)
|
195
|
-
api_constraint =
|
214
|
+
api_constraint = NumberedVersionConstraint.new(version: version_number)
|
196
215
|
scope(module: "v#{version_number}", constraints: api_constraint, &routes)
|
197
216
|
end
|
198
217
|
|
data/test/dummy/config/routes.rb
CHANGED
@@ -3,6 +3,11 @@ require 'rails_versioned_routing'
|
|
3
3
|
Dummy::Application.routes.draw do
|
4
4
|
extend RailsVersionedRouting
|
5
5
|
|
6
|
+
beta! do
|
7
|
+
get 'a_path_overridden_from_v1/:id/whats/:ok', controller: 'sample', action: 'a_path_overridden_from_v1'
|
8
|
+
get 'a_path_only_in_beta', controller: 'sample'
|
9
|
+
end
|
10
|
+
|
6
11
|
version(3) do
|
7
12
|
post 'a_path_only_in_v3', controller: 'sample', action: 'posted_a_path_only_in_v3'
|
8
13
|
get 'a_path_only_in_v3', controller: 'sample'
|
Binary file
|