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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf3fc6d454cdeaf9c8c31019c1b0ec6dc4c676203a8c44cd40e24dee49ace832
4
- data.tar.gz: ba06bb7b2868c6c2d53ac93504eb00fe0ef5527b1224f04c6c862fd27e7734fe
3
+ metadata.gz: 88faa9125ecbb5875cc388b83c814cea0894450765bb0f4167bd0ae0f0992b99
4
+ data.tar.gz: 1088a35aa6485279ac86964013c3435dcbc62741ed94cf9482802959ceea7955
5
5
  SHA512:
6
- metadata.gz: b932a1b72743a06701d7fa3d7a80068baf0e31df76d78a0dea7b892a46bb663c3dcd9e444599b3942a9a5eb3289b5b90b962ef39216e8f15ff04bde5bff0946b
7
- data.tar.gz: c609bb26e27dc4018766e84d55aa38715385bff1fc444468481ff781649f9af3037e2078ada729814f9d92963e9b3752f48b1bb6cbdbe05a00000eae5ea169b4
6
+ metadata.gz: d723c66b5c1d2ed5ab25531aa10502c820295f2203755159b6ca7591a9f6f7f9d40e34ce62888cc1c68ef73903a7ebd8d11fe9f0a028c2d26a48de8348f0a6a7
7
+ data.tar.gz: c80b6e22679e966f994d5be4be3c47bd32190141071d9c6dea2ce7ae6c714cd9fdb9ddcb3c30a85516f3ec9c16c666dfd4694b39be398cb4b1d184fab541cd45
@@ -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
- routes[controller][action].push(format_route(route))
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 information of a given route.
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 format_route(route)
65
+ def format(route:, verb:)
47
66
  {
48
- verb: route.verb,
67
+ verb: verb,
49
68
  path: route.path.spec.to_s.gsub('(.:format)', ''),
50
69
  name: route.name
51
70
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chusaku
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
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.0
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: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2020-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler