chusaku 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chusaku/routes.rb +23 -4
- data/lib/chusaku/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88faa9125ecbb5875cc388b83c814cea0894450765bb0f4167bd0ae0f0992b99
|
4
|
+
data.tar.gz: 1088a35aa6485279ac86964013c3435dcbc62741ed94cf9482802959ceea7955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d723c66b5c1d2ed5ab25531aa10502c820295f2203755159b6ca7591a9f6f7f9d40e34ce62888cc1c68ef73903a7ebd8d11fe9f0a028c2d26a48de8348f0a6a7
|
7
|
+
data.tar.gz: c80b6e22679e966f994d5be4be3c47bd32190141071d9c6dea2ce7ae6c714cd9fdb9ddcb3c30a85516f3ec9c16c666dfd4694b39be398cb4b1d184fab541cd45
|
data/lib/chusaku/routes.rb
CHANGED
@@ -31,7 +31,11 @@ module Chusaku
|
|
31
31
|
controller, action = extract_controller_and_action_from(route)
|
32
32
|
routes[controller] ||= {}
|
33
33
|
routes[controller][action] ||= []
|
34
|
-
|
34
|
+
|
35
|
+
verbs_for(route).each do |verb|
|
36
|
+
routes[controller][action].push(format(route: route, verb: verb))
|
37
|
+
routes[controller][action].uniq!
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
backfill_routes(routes)
|
@@ -39,13 +43,28 @@ module Chusaku
|
|
39
43
|
|
40
44
|
private
|
41
45
|
|
42
|
-
# Extract
|
46
|
+
# Extract the HTTP verbs for a Rails route. Required for older versions of
|
47
|
+
# Rails that return regular expressions for a route verb which sometimes
|
48
|
+
# contains multiple verbs.
|
49
|
+
#
|
50
|
+
# @param {ActionDispatch::Journey::Route} route - Route given by Rails
|
51
|
+
# @return {Array<String>} - List of HTTP verbs for the given route
|
52
|
+
def verbs_for(route)
|
53
|
+
route_verb = route.verb.to_s
|
54
|
+
|
55
|
+
['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].select do |verb|
|
56
|
+
route_verb.include?(verb)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Formats information for a given route.
|
43
61
|
#
|
44
62
|
# @param {ActionDispatch::Journey::Route} route - Route given by Rails
|
63
|
+
# @param {String} verb - HTTP verb
|
45
64
|
# @return {Hash} - { verb: String, path: String, name: String }
|
46
|
-
def
|
65
|
+
def format(route:, verb:)
|
47
66
|
{
|
48
|
-
verb:
|
67
|
+
verb: verb,
|
49
68
|
path: route.path.spec.to_s.gsub('(.:format)', ''),
|
50
69
|
name: route.name
|
51
70
|
}
|
data/lib/chusaku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chusaku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nishiki Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|