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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca694c200a042cf3a7b37678b80c4034c6e906bc
4
- data.tar.gz: f9a06170a97d6ae93b60b4a59293c676bc97a879
3
+ metadata.gz: 32c39440dae0113b812390a602c5da058815b478
4
+ data.tar.gz: e3ff07453b005d8a134b70a07e4893e25a72920a
5
5
  SHA512:
6
- metadata.gz: 016cefb9b8c9237fe6573bdaae13a2622289425dd9f0e504c725f2fa3834ba3d8917612edfa1254dc271129f180d2751b9d685b2d0d20f3962f5598a69cfd028
7
- data.tar.gz: 2d36eced14eaae0c0b4ed572824ba2c04cd6b4ec036e82a5459709f4e51f0b880d8c7cf96941bd9bc60d11b7806bed5e0f4fff9564a8a99e0b16d94084025028
6
+ metadata.gz: d58b04d62b3a5fd2498c5e5fbbe7b63f1231acc35c5751ee90ee19f7df33b930db39d35872726fdf71dce214c264efb6dd49c017fc640ce0809ecf14168a2e77
7
+ data.tar.gz: 64bbe547bcc27b02fa786f752daa759555c9a23adf54e8a99d638dddd630a675e6f38a4f0adb9294ec365b03138e9fc3101206a56333e622541d98c71e103ee5
@@ -25,16 +25,22 @@ module RocketDocs
25
25
  end
26
26
 
27
27
  def api_controller_names
28
- ar = routes.named_routes.select { |_k, v| v.defaults[:rp_prefix] }
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 { |v| v && v.defaults[:version] == version }
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 && r.defaults[:version] }.uniq.compact
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|
@@ -1,3 +1,3 @@
1
1
  module RocketDocs
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanko Krtalić Rusendić