chusaku 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/chusaku/routes.rb +36 -10
- data/lib/chusaku/version.rb +1 -1
- data/lib/chusaku.rb +2 -2
- 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: cb896064bc711881c0b3efec1513838ec219d4a98f69643aa7a50214d092a942
|
4
|
+
data.tar.gz: b3409d3ce1b736b6290d8a122c4edeaceb88d9caa51c845fae0ad6d31d5401ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 759e9b4aaa8087e652248f349dc41fd340a117234d25be941c223a112e4a7080c122c268c77da37f098f7d53ec19e7e7a27c502abed0496fd758874a40366101
|
7
|
+
data.tar.gz: b527142c5b3e8dd08ea919ef8b90dfa3703c9580b2c9efcfd12cbedd56131975dd7473f0d5bfe612b007bb7f03ca07926f54ade8ae4ac58e12ce37de8c0db932
|
data/README.md
CHANGED
data/lib/chusaku/routes.rb
CHANGED
@@ -8,11 +8,23 @@ module Chusaku
|
|
8
8
|
#
|
9
9
|
# {
|
10
10
|
# 'users' => {
|
11
|
-
# 'edit'
|
12
|
-
#
|
11
|
+
# 'edit' => {
|
12
|
+
# verbs: ['GET'],
|
13
|
+
# path: '/users/:id',
|
14
|
+
# name: 'edit_user'
|
15
|
+
# },
|
16
|
+
# 'update' => {
|
17
|
+
# verbs: ['PUT', 'PATCH'],
|
18
|
+
# path: '/users',
|
19
|
+
# name: nil
|
20
|
+
# }
|
13
21
|
# },
|
14
22
|
# 'empanadas' => {
|
15
|
-
# 'create' => {
|
23
|
+
# 'create' => {
|
24
|
+
# verbs: ['POST'],
|
25
|
+
# path: '/empanadas',
|
26
|
+
# name: nil
|
27
|
+
# }
|
16
28
|
# }
|
17
29
|
# }
|
18
30
|
#
|
@@ -22,18 +34,32 @@ module Chusaku
|
|
22
34
|
|
23
35
|
Rails.application.routes.routes.each do |route|
|
24
36
|
defaults = route.defaults
|
37
|
+
controller = defaults[:controller]
|
25
38
|
action = defaults[:action]
|
26
39
|
|
27
|
-
routes[
|
28
|
-
routes[
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}
|
40
|
+
routes[controller] ||= {}
|
41
|
+
if routes[controller][action].nil?
|
42
|
+
routes[controller][action] = format_action(route)
|
43
|
+
else
|
44
|
+
routes[controller][action][:verbs].push(route.verb)
|
45
|
+
end
|
34
46
|
end
|
35
47
|
|
36
48
|
routes
|
37
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Extract information of a given route.
|
54
|
+
#
|
55
|
+
# @param {ActionDispatch::Journey::Route} route
|
56
|
+
# @return {Hash}
|
57
|
+
def self.format_action(route)
|
58
|
+
{
|
59
|
+
verbs: [route.verb],
|
60
|
+
path: route.path.spec.to_s.gsub('(.:format)', ''),
|
61
|
+
name: route.name
|
62
|
+
}
|
63
|
+
end
|
38
64
|
end
|
39
65
|
end
|
data/lib/chusaku/version.rb
CHANGED
data/lib/chusaku.rb
CHANGED
@@ -75,10 +75,10 @@ module Chusaku
|
|
75
75
|
# @param {Hash} action_info
|
76
76
|
# @return {String}
|
77
77
|
def self.annotate(action_info)
|
78
|
-
|
78
|
+
verbs = action_info[:verbs]
|
79
79
|
path = action_info[:path]
|
80
80
|
name = action_info[:name]
|
81
|
-
annotation = "@route #{
|
81
|
+
annotation = "@route [#{verbs.join(', ')}] #{path}"
|
82
82
|
annotation += " (#{name})" unless name.nil?
|
83
83
|
annotation
|
84
84
|
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.1.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2019-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|