Class: Cassie::Tasks::TaskRunner
- Defined in:
- lib/cassie/tasks/task_runner.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#raw_args ⇒ Object
readonly
Returns the value of attribute raw_args.
Instance Method Summary collapse
- #display_info ⇒ Object
-
#initialize(args) ⇒ TaskRunner
constructor
A new instance of TaskRunner.
- #run ⇒ Object
- #task ⇒ Object
Constructor Details
#initialize(args) ⇒ TaskRunner
Returns a new instance of TaskRunner.
9 10 11 12 13 14 |
# File 'lib/cassie/tasks/task_runner.rb', line 9 def initialize(args) @args = args @command = nil @command = args.delete_at(0) if args.first =~ /\A[^-]/ @options = {} end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/cassie/tasks/task_runner.rb', line 5 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/cassie/tasks/task_runner.rb', line 6 def command @command end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/cassie/tasks/task_runner.rb', line 7 def @options end |
#raw_args ⇒ Object (readonly)
Returns the value of attribute raw_args.
4 5 6 |
# File 'lib/cassie/tasks/task_runner.rb', line 4 def raw_args @raw_args end |
Instance Method Details
#display_info ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cassie/tasks/task_runner.rb', line 34 def display_info case when command && !task puts "'#{command}' is not a supported command.\n\n" print_documentation when [:show_help] print_documentation when [:show_version] puts Cassie::VERSION else print_documentation end end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cassie/tasks/task_runner.rb', line 16 def run Cassie.logger.level = ::Logger::WARN unless [:debug] Cassie.env = [:environment] if [:environment] Cassie::Tasks::IO.trace! if [:trace] run_command || display_info rescue OptionParser::InvalidOption => e puts("#{e.}\n\n") display_info end |
#task ⇒ Object
29 30 31 32 |
# File 'lib/cassie/tasks/task_runner.rb', line 29 def task task_name = "cassie:#{command}" Rake::Task[task_name] if Rake::Task.task_defined?(task_name) end |