Class: RightDevelop::Commands::Server
- Inherits:
-
Object
- Object
- RightDevelop::Commands::Server
- Includes:
- RightSupport::Log::Mixin
- Defined in:
- lib/right_develop/commands/server.rb
Defined Under Namespace
Classes: PlainFormatter
Constant Summary collapse
- CONFIG_CLASS =
::RightDevelop::Testing::Server::MightApi::Config
- TASKS =
CONFIG_CLASS::VALID_MODES
Class Method Summary collapse
-
.create ⇒ Object
Parse command-line options and create a Command object.
Instance Method Summary collapse
-
#initialize(task, options) ⇒ Server
constructor
A new instance of Server.
-
#run ⇒ Object
Run the task that was specified when this object was instantiated.
Constructor Details
#initialize(task, options) ⇒ Server
Returns a new instance of Server.
84 85 86 87 88 89 90 91 92 |
# File 'lib/right_develop/commands/server.rb', line 84 def initialize(task, ) logger = ::Logger.new(STDOUT) logger.level = [:debug] ? ::Logger::DEBUG : ::Logger::WARN logger.formatter = PlainFormatter.new ::RightSupport::Log::Mixin.default_logger = logger @task = task @options = end |
Class Method Details
.create ⇒ Object
Parse command-line options and create a Command object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/right_develop/commands/server.rb', line 42 def self.create task_list = TASKS.sort.inject([]) do |a, (k, v)| a << ' * %s%s' % [k.to_s.ljust(10), v] end.join("\n") = Trollop. do <<-EOS The 'server' command starts a server in the foreground to assist in testing. The behavior of the server depends on the type specified. Usage: right_develop server <task> [options] Where <task> is one of: #{task_list} And [options] are selected from: EOS opt :root_dir, 'Root directory for config and fixtures', :default => ::Dir.pwd opt :port, 'Port on which server will listen', :default => 9292 opt :force, 'Force overwrite of any existing recording', :default => false opt :throttle, 'Playback delay as a percentage of recorded response time', :default => 0 opt :debug, 'Enable verbose debug output', :default => false end task = ARGV.shift.to_s if TASKS.keys.include?(task) self.new(task.to_sym, ) else ::Trollop.die "unknown task #{task}" end end |
Instance Method Details
#run ⇒ Object
Run the task that was specified when this object was instantiated. This method does no work; it just delegates to a task method.
96 97 98 |
# File 'lib/right_develop/commands/server.rb', line 96 def run run_might_api(@task, @options) end |