rack-app 7.1.0 → 7.2.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc53a0095f970a120176096db38a279192b19f3d
|
4
|
+
data.tar.gz: e894abc7b71c917fe40401ddd79ac0e84d67530a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0decc2be8a3ddba7e10337ff4b0bdca9746b2b0e61528eb1dca7d1beba4204b8d141ef05e9d38c957127afffbf763a4197584dbface538c973a765b8147af4
|
7
|
+
data.tar.gz: 80235c93758f0301785466aca16d50363d2b7aa31f87953c5035fa3021cc95268fc5a5b51cc6c1e0c5c834312fa4836cfab7723c3f7b5a5e588d3d796216c645
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.2.0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'irb'
|
2
|
+
require 'irb/completion'
|
3
|
+
class Rack::App::CLI::DefaultCommands::IRB < Rack::App::CLI::Command
|
4
|
+
|
5
|
+
description 'open an irb session with the application loaded in'
|
6
|
+
|
7
|
+
action do |*args|
|
8
|
+
Rack::App::CLI.rack_app
|
9
|
+
ARGV.clear
|
10
|
+
ARGV.push(*args)
|
11
|
+
::IRB.start
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -1,33 +1,58 @@
|
|
1
1
|
module Rack::App::CLI::DefaultCommands::ListCommands
|
2
|
-
|
3
2
|
extend self
|
4
3
|
|
5
|
-
PRESERVED_KEYWORDS = [
|
6
|
-
|
7
|
-
def get_message(known_commands)
|
8
|
-
puts_collection = []
|
4
|
+
PRESERVED_KEYWORDS = %w[commands help routes irb].freeze
|
9
5
|
|
10
|
-
|
6
|
+
DEFAULT_COMMANDS = {
|
7
|
+
'commands' => 'list all available command',
|
8
|
+
'routes' => Rack::App::CLI::DefaultCommands::ShowRoutes.description,
|
9
|
+
'irb' => Rack::App::CLI::DefaultCommands::IRB.description
|
10
|
+
}.freeze
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
class Formatter
|
13
|
+
def initialize(known_commands)
|
14
|
+
@rjust = known_commands.keys.push(*PRESERVED_KEYWORDS).map(&:to_s).map(&:length).max + 3
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
def command_suggestion_line_by(name, desc)
|
18
|
+
[name.to_s.rjust(@rjust), desc].join(' ')
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
21
|
+
def format(collection_hash)
|
22
|
+
collection_hash.to_a.sort_by{ |k, v| k.to_s }.map do |name, desc|
|
23
|
+
command_suggestion_line_by(name, desc)
|
24
|
+
end.join("\n")
|
20
25
|
end
|
26
|
+
end
|
21
27
|
|
22
|
-
|
28
|
+
def get_message(known_commands)
|
29
|
+
collection = {}
|
30
|
+
add_default_suggestions(collection)
|
31
|
+
add_user_defined_commands(known_commands, collection)
|
32
|
+
|
33
|
+
[
|
34
|
+
header,
|
35
|
+
Formatter.new(known_commands).format(collection)
|
36
|
+
].join("\n")
|
23
37
|
end
|
24
38
|
|
25
39
|
protected
|
26
40
|
|
27
|
-
def
|
28
|
-
cmd_file_name = File.basename($
|
29
|
-
|
30
|
-
|
41
|
+
def header
|
42
|
+
cmd_file_name = File.basename($PROGRAM_NAME)
|
43
|
+
[
|
44
|
+
"Usage: #{cmd_file_name} <command> [options] <args>\n\n",
|
45
|
+
"Some useful #{cmd_file_name} commands are:"
|
46
|
+
].join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_default_suggestions(collection)
|
50
|
+
collection.merge!(DEFAULT_COMMANDS)
|
31
51
|
end
|
32
52
|
|
33
|
-
|
53
|
+
def add_user_defined_commands(known_commands, collection)
|
54
|
+
known_commands.sort_by { |name, _| name.to_s }.each do |name, command|
|
55
|
+
collection[name] = command.class.description
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/rack/app/cli/runner.rb
CHANGED
@@ -36,6 +36,9 @@ class Rack::App::CLI::Runner
|
|
36
36
|
when 'routes'
|
37
37
|
Rack::App::CLI::DefaultCommands::ShowRoutes.new.start(argv)
|
38
38
|
|
39
|
+
when 'irb'
|
40
|
+
Rack::App::CLI::DefaultCommands::IRB.new.start(argv)
|
41
|
+
|
39
42
|
else
|
40
43
|
command = command_for(command_name)
|
41
44
|
run_command(argv, command, command_name)
|
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.
|
4
|
+
version: 7.2.0
|
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-07-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/rack/app/cli/command.rb
|
103
103
|
- lib/rack/app/cli/command/configurator.rb
|
104
104
|
- lib/rack/app/cli/default_commands.rb
|
105
|
+
- lib/rack/app/cli/default_commands/irb.rb
|
105
106
|
- lib/rack/app/cli/default_commands/list_commands.rb
|
106
107
|
- lib/rack/app/cli/default_commands/show_routes.rb
|
107
108
|
- lib/rack/app/cli/fetcher.rb
|