rack-app 7.3.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app/cli/default_commands/show_routes.rb +21 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79271c60c490af09f3db3df4e6907210529bf0d0
|
4
|
+
data.tar.gz: b14fc9c9169e980aee20a59c1384dadc27166df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02bcb5f6aba359290b0231bd22a0b4cdab6def0b885f7ee05383024027d5044308453d9c1a8df35b654f08b96283546330fd7032603ee8a35ed339f87a83f7c
|
7
|
+
data.tar.gz: 135399af68864242bb24bd985a07e8b83b8767c8e484715d99a2f3c21acfb0d0448ade94f5a5072f5ef6612a2fc4ee6ac10d88bddce108f45e0f11c827e47173
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.3.
|
1
|
+
7.3.1
|
@@ -17,26 +17,12 @@ class Rack::App::CLI::DefaultCommands::ShowRoutes < Rack::App::CLI::Command
|
|
17
17
|
@middlewares = true
|
18
18
|
end
|
19
19
|
|
20
|
-
FIELD_FETCHERS = {
|
21
|
-
:request_method => proc { |endpoint| endpoint.request_method },
|
22
|
-
:request_path => proc { |endpoint| endpoint.request_path },
|
23
|
-
:description => proc { |endpoint| endpoint.description },
|
24
|
-
:source_location => proc do |endpoint|
|
25
|
-
callable = endpoint.properties[:callable]
|
26
|
-
callable = callable.method(:call) unless callable.is_a?(::Proc)
|
27
|
-
callable.source_location.join(':')
|
28
|
-
end
|
29
|
-
}.freeze
|
30
|
-
|
31
|
-
SORT_FIELDS = [:request_method, :request_path].freeze
|
32
|
-
|
33
20
|
action do
|
34
21
|
STDOUT.puts(format(sort(Rack::App::CLI.rack_app.router.endpoints)))
|
35
22
|
end
|
36
23
|
|
37
24
|
private
|
38
25
|
|
39
|
-
|
40
26
|
def get_fields
|
41
27
|
if @verbose
|
42
28
|
return FIELD_FETCHERS.keys
|
@@ -50,14 +36,32 @@ class Rack::App::CLI::DefaultCommands::ShowRoutes < Rack::App::CLI::Command
|
|
50
36
|
|
51
37
|
def width_by(endpoints, fields)
|
52
38
|
fields.reduce({}) do |widths, property|
|
53
|
-
widths[property] = endpoints.map { |endpoint|
|
39
|
+
widths[property] = endpoints.map { |endpoint| fetch_field(endpoint, property).to_s.length }.max
|
54
40
|
widths
|
55
41
|
end
|
56
42
|
end
|
57
43
|
|
44
|
+
SORT_FIELDS = [:request_method, :request_path].freeze
|
58
45
|
|
59
46
|
def sort(endpoints)
|
60
|
-
endpoints.sort_by { |endpoint| SORT_FIELDS.map { |sf|
|
47
|
+
endpoints.sort_by { |endpoint| SORT_FIELDS.map { |sf| fetch_field(endpoint, sf) } }
|
48
|
+
end
|
49
|
+
|
50
|
+
FIELD_FETCHERS = {
|
51
|
+
:request_method => proc { |endpoint| endpoint.request_method },
|
52
|
+
:request_path => proc { |endpoint| endpoint.request_path },
|
53
|
+
:description => proc { |endpoint| endpoint.description },
|
54
|
+
:source_location => proc do |endpoint|
|
55
|
+
callable = endpoint.properties[:callable]
|
56
|
+
callable = callable.method(:call) unless callable.is_a?(::Proc)
|
57
|
+
path = callable.source_location.join(':')
|
58
|
+
relative_path_rgx = Regexp.new(sprintf('^%s', Regexp.escape(Rack::App::Utils.pwd('/'))))
|
59
|
+
path.sub(relative_path_rgx, '')
|
60
|
+
end
|
61
|
+
}.freeze
|
62
|
+
|
63
|
+
def fetch_field(endpoint, field)
|
64
|
+
instance_exec(endpoint, &FIELD_FETCHERS[field])
|
61
65
|
end
|
62
66
|
|
63
67
|
def format(endpoints)
|
@@ -68,7 +72,7 @@ class Rack::App::CLI::DefaultCommands::ShowRoutes < Rack::App::CLI::Command
|
|
68
72
|
outputs = []
|
69
73
|
|
70
74
|
outputs << fields.map do |field|
|
71
|
-
|
75
|
+
fetch_field(endpoint, field).to_s.ljust(widths[field])
|
72
76
|
end.join(' ')
|
73
77
|
|
74
78
|
if @middlewares
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.3.
|
4
|
+
version: 7.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|