rack-app 3.3.0 → 3.4.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: 66b57de8ba87782de7ea0b68c7daa6e7581071cf
4
- data.tar.gz: 41db5aef1bc376e061ca7b7299156417b5b8fc30
3
+ metadata.gz: c7d43893840f6f431d6de3d315663c8b3b218efe
4
+ data.tar.gz: 3ee8f9c6590d842ab89bb32f1703c344d28b229b
5
5
  SHA512:
6
- metadata.gz: 1217911ce39dd6e590f4b9939b6ef7a1ea124401341eefab33992ef3c5ee875db8971f9108052fab8ab912fbc04763a4a9fe580f92f908761d1d3adbdbfaaf58
7
- data.tar.gz: cc560b180786f192a3a7d60f99c925da377d23326cacaf3ec97182067e81916da17c77bacb6d55f808e13a8d2e41a17e603311ab7040b9a78efa9e813a12243f
6
+ metadata.gz: 463db659b98c7c6c523e6a1262e1a4d90352593e77d640474889ec231a3f12bbf074ef7f962935724e157e05cc8d72fbeb0added3f3479217df28482defc9fb7
7
+ data.tar.gz: 9752ef90b016d737795873ccf79ee631a5ef3acf46533f8ef0462a70191d0a9b2b8e90a2de590afc99ec97f3d92562757518aff1e1352f98bdc9df68d941fcb1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.0
@@ -1,3 +1,4 @@
1
1
  module Rack::App::CLI::DefaultCommands
2
2
  require 'rack/app/cli/default_commands/list_commands'
3
+ require 'rack/app/cli/default_commands/show_routes'
3
4
  end
@@ -2,15 +2,19 @@ module Rack::App::CLI::DefaultCommands::ListCommands
2
2
 
3
3
  extend self
4
4
 
5
+ PRESERVED_KEYWORDS = ['commands', 'help', 'routes']
6
+
5
7
  def get_message(known_commands)
6
8
  puts_collection = []
7
9
 
8
10
  add_header(puts_collection)
9
11
 
10
12
  list_command_name = 'commands'
11
- rjust = known_commands.keys.push(list_command_name).map(&:to_s).map(&:length).max + 3
13
+ rjust = known_commands.keys.push(*PRESERVED_KEYWORDS).map(&:to_s).map(&:length).max + 3
12
14
 
13
15
  puts_collection << [list_command_name.to_s.rjust(rjust), 'list all available command'].join(' ')
16
+ puts_collection << ['routes'.to_s.rjust(rjust), 'list all available endpoint'].join(' ')
17
+
14
18
  known_commands.sort_by { |name, _| name.to_s }.each do |name, command|
15
19
  puts_collection << [name.to_s.rjust(rjust), command.class.description].join(' ')
16
20
  end
@@ -0,0 +1,13 @@
1
+ class Rack::App::CLI::DefaultCommands::ShowRoutes < Rack::App::CLI::Command
2
+
3
+ description 'list the routes for the application'
4
+
5
+ action do
6
+ $stdout.puts(app.router.show_endpoints)
7
+ end
8
+
9
+ def app
10
+ Rack::App::CLI.rack_app
11
+ end
12
+
13
+ end
@@ -21,26 +21,28 @@ class Rack::App::CLI::Runner
21
21
  command_name = argv.shift
22
22
  command = command_for(command_name)
23
23
  options_parser = configure_command(command,command_name)
24
-
25
24
  $stdout.puts(options_parser.help)
26
- rescue CommandNotFound
27
- show_commands
28
25
  end
29
26
 
30
27
  def start_command_for(command_name, argv)
31
28
  case command_name.to_s
32
29
 
33
30
  when 'commands'
34
- return show_commands
31
+ show_commands
35
32
 
36
33
  when 'help'
37
- return show_help_message(argv)
34
+ show_help_message(argv)
35
+
36
+ when 'routes'
37
+ Rack::App::CLI::DefaultCommands::ShowRoutes.new.start(argv)
38
38
 
39
39
  else
40
40
  command = command_for(command_name)
41
- return run_command(argv, command, command_name)
41
+ run_command(argv, command, command_name)
42
42
 
43
43
  end
44
+ rescue CommandNotFound
45
+ show_commands
44
46
  end
45
47
 
46
48
  def run_command(argv, command, command_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
@@ -95,6 +95,7 @@ files:
95
95
  - lib/rack/app/cli/command/configurator.rb
96
96
  - lib/rack/app/cli/default_commands.rb
97
97
  - lib/rack/app/cli/default_commands/list_commands.rb
98
+ - lib/rack/app/cli/default_commands/show_routes.rb
98
99
  - lib/rack/app/cli/runner.rb
99
100
  - lib/rack/app/constants.rb
100
101
  - lib/rack/app/endpoint.rb