rocket_docs 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_docs/router.rb +18 -3
- data/lib/rocket_docs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32c39440dae0113b812390a602c5da058815b478
|
4
|
+
data.tar.gz: e3ff07453b005d8a134b70a07e4893e25a72920a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58b04d62b3a5fd2498c5e5fbbe7b63f1231acc35c5751ee90ee19f7df33b930db39d35872726fdf71dce214c264efb6dd49c017fc640ce0809ecf14168a2e77
|
7
|
+
data.tar.gz: 64bbe547bcc27b02fa786f752daa759555c9a23adf54e8a99d638dddd630a675e6f38a4f0adb9294ec365b03138e9fc3101206a56333e622541d98c71e103ee5
|
data/lib/rocket_docs/router.rb
CHANGED
@@ -25,16 +25,22 @@ module RocketDocs
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def api_controller_names
|
28
|
-
ar = routes.named_routes.select
|
28
|
+
ar = routes.named_routes.select do |_k, route|
|
29
|
+
route && route.path && route.path.requirements[:version]
|
30
|
+
end
|
29
31
|
ar.values.map { |r| r.defaults[:controller] }.uniq
|
30
32
|
end
|
31
33
|
|
32
34
|
def routes_for_version(version)
|
33
|
-
routes.to_a.select
|
35
|
+
routes.to_a.select do |r|
|
36
|
+
versions = extract_versions_from_route(r)
|
37
|
+
versions && versions.include?(version)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
def versions
|
37
|
-
routes.to_a.map { |r| r
|
42
|
+
routes.to_a.map { |r| extract_versions_from_route(r) }
|
43
|
+
.flatten.uniq.compact
|
38
44
|
end
|
39
45
|
|
40
46
|
def routes
|
@@ -47,6 +53,15 @@ module RocketDocs
|
|
47
53
|
|
48
54
|
private
|
49
55
|
|
56
|
+
def extract_versions_from_route(route)
|
57
|
+
return unless route && route.path && route.path.requirements[:version]
|
58
|
+
route.path.requirements[:version].to_s.split('|').map do |v|
|
59
|
+
v.gsub!(/[^\?]*\?(?=\d+)/, '')
|
60
|
+
v.gsub!(/[^\d]*/, '')
|
61
|
+
v.to_i
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
50
65
|
def fill_controllers_hash_for_version(version, hash)
|
51
66
|
routes = routes_for_version(version)
|
52
67
|
routes.each do |r|
|
data/lib/rocket_docs/version.rb
CHANGED