doc_my_routes 0.10.0 → 0.11.0

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: c573d2ed3d69b19c86e42facf512dceae2c25c15
4
- data.tar.gz: 8e2b17bd3e31ed83c44b589661f73fb863c3432b
3
+ metadata.gz: 54f18694c17c44df5a459dbd06eff87d4bd90bad
4
+ data.tar.gz: 6e6800ca18c370bfd7c8f468798b0982c52bf44d
5
5
  SHA512:
6
- metadata.gz: 59ecabbfa6abf47254ae0222a717c51c2a043651c623cf86974e41ff8d9ee0424d0e7937ce941a8a7824ce34e76ecfc3aebe3110e69ccf36e023212f9378b4d2
7
- data.tar.gz: 118fc92f38f447ebcffe0db371e77bf920badf4c3601c66c00843e0f157670a95f6fbd71b9c0592fc69820c4e77c7d44ff592159d8a280a00407667bbc030460
6
+ metadata.gz: 6ba99e20fdd9c3b31a0cd16414d557bfcb10bb0e3433b906676904a42aa3b935006bfb13d63502b40a32e6a606340549a1ede5888881bf58f79691e2e025aab6
7
+ data.tar.gz: 9595e10d9a9acd1d56ec57892553e9b5803c7efcad735e34f4c1579dc9cb17c708d62b6de5a2108dddeebb5e845535ec79917374aee277d37963f027c6596078
@@ -3,4 +3,5 @@ module DocMyRoutes
3
3
  class ExampleMissing < StandardError; end
4
4
  class UnsupportedError < StandardError; end
5
5
  class MultipleMappingDetected < UnsupportedError; end
6
+ class NoMappingDetected < UnsupportedError; end
6
7
  end
@@ -36,6 +36,10 @@ module DocMyRoutes
36
36
  Object.const_defined?('Rack::URLMap')
37
37
  end
38
38
 
39
+ def inherit_mapping(child_class, super_class)
40
+ (@inherited_mappings ||= {})[child_class.to_s] = super_class.to_s
41
+ end
42
+
39
43
  # This method associates to each route its namespace, if detected.
40
44
  #
41
45
  # Note: when application A is inherited by B and only B is mapped, from
@@ -100,15 +104,19 @@ module DocMyRoutes
100
104
  class_name = remapped_applications[class_name].first if \
101
105
  remapped_applications.key?(class_name)
102
106
 
103
- locations = route_mapping[class_name]
107
+ validate_locations(class_name, extract_locations(class_name))
108
+ end
104
109
 
105
- validate_locations(class_name, locations)
110
+ def extract_locations(class_name)
111
+ route_mapping[class_name] || route_mapping[(@inherited_mappings || {})[class_name]]
106
112
  end
107
113
 
108
114
  # Detects if multiple locations are available and for now fail
109
115
  def validate_locations(resource, locations)
110
- fail "Resource #{resource} has multiple mappings, but that's not " \
111
- "supported yet: #{locations}" if locations.size > 1
116
+ fail NoMappingDetected, "Resource #{resource} has no mapping, so we can't tell where " \
117
+ 'it is mounted!' if locations.nil?
118
+ fail MultipleMappingDetected, "Resource #{resource} has multiple mappings, but that's " \
119
+ "not supported yet: #{locations}" if locations.size > 1
112
120
 
113
121
  return locations.first if locations.size == 1
114
122
 
@@ -20,7 +20,7 @@ module DocMyRoutes
20
20
  namespace = format('%-50s', app_routes.first.namespace)
21
21
  DocMyRoutes.logger.debug "Adding route to #{namespace} - #{app_name}"
22
22
 
23
- app_routes.each { |rte| logger.debug " - #{rte}" }
23
+ app_routes.each { |rte| DocMyRoutes.logger.debug " - #{rte}" }
24
24
  end
25
25
  end
26
26
  end
@@ -1,4 +1,4 @@
1
1
  # DocMyRoutes version
2
2
  module DocMyRoutes
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doc_my_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Workday, Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler