Class: HTTY::CLI::Commands::Config

Inherits:
HTTY::CLI::Command
  • Object
show all
Includes:
HTTY::CLI::CookieClearingCommand
Defined in:
lib/htty/rack/commands/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.categoryObject

Returns the name of a category under which help for the config command should appear.



7
8
9
# File 'lib/htty/rack/commands/config.rb', line 7

def self.category
  'Rack'
end

.command_line_argumentsObject

Returns the arguments for the command-line usage of the config command.



12
13
14
# File 'lib/htty/rack/commands/config.rb', line 12

def self.command_line_arguments
  'config'
end

.helpObject

Returns the help text for the config command.



17
18
19
# File 'lib/htty/rack/commands/config.rb', line 17

def self.help
  'Loads a new config'
end

.help_extendedObject

Returns the extended help text for the config command.



22
23
24
25
# File 'lib/htty/rack/commands/config.rb', line 22

def self.help_extended
  'Loads a config (.ru-File) and sets the built class as the' +
  'active application. This operation clears cookies.'
end

Instance Method Details

#performObject

Performs the config command.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/htty/rack/commands/config.rb', line 28

def perform
  unless arguments.length == 1
     raise ArgumentError,
           "wrong number of arguments (#{arguments.length} for 1)"
  end
  
  add_request_if_has_response do |request|
    request.app_file, request.app = HTTY::Rack::build_app arguments.first
    request
  end
end