Class: Siding::CLI
- Inherits:
-
Object
- Object
- Siding::CLI
- Defined in:
- lib/siding/cli.rb
Constant Summary collapse
- MANAGEMENT_COMMANDS =
%w[start status stop restart doctor init version help --help -h].freeze
- ACCELERATED_EXECUTABLES =
%w[rails rake rspec test].freeze
- OUT_OF_SCOPE_RAILS_COMMANDS =
%w[dev:cache].freeze
- SERVER_COMMANDS =
%w[server s].freeze
- DAEMON_FLAGS =
%w[-d --daemon].freeze
- REQUEST_TIMEOUT =
5- BOOT_LOG_LINES =
20- BINSTUBS =
%w[rails rake rspec].freeze
- BINSTUB_MARKER =
"generated by siding"
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, client) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, client) ⇒ CLI
Returns a new instance of CLI.
48 49 50 51 |
# File 'lib/siding/cli.rb', line 48 def initialize(argv, client) @argv = argv @client = client end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
46 47 48 |
# File 'lib/siding/cli.rb', line 46 def argv @argv end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
46 47 48 |
# File 'lib/siding/cli.rb', line 46 def client @client end |
Class Method Details
.accelerated?(argv) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/siding/cli.rb', line 29 def accelerated?(argv) executable = argv.first return false unless ACCELERATED_EXECUTABLES.include?(executable) return rails_accelerated?(argv) if executable == "rails" true end |
.management?(name) ⇒ Boolean
27 |
# File 'lib/siding/cli.rb', line 27 def management?(name) = MANAGEMENT_COMMANDS.include?(name) |
.rails_accelerated?(argv) ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/siding/cli.rb', line 37 def rails_accelerated?(argv) command = argv[1] return false if OUT_OF_SCOPE_RAILS_COMMANDS.include?(command) return false if SERVER_COMMANDS.include?(command) && argv.any? { DAEMON_FLAGS.include?(_1) } true end |
Instance Method Details
#run ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/siding/cli.rb', line 53 def run command = argv.first ret = if ["help", "--help", "-h", nil].include?(command) help elsif MANAGEMENT_COMMANDS.include?(command) send(command) else unimplemented(command) end ret.is_a?(Integer) ? ret : 0 end |