Class: Tasks
- Inherits:
-
Object
- Object
- Tasks
- Defined in:
- lib/tasks.rb
Constant Summary collapse
- @@default =
nil
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(value) ⇒ Object
- #execute_task(task) ⇒ Object
-
#initialize(env = nil) ⇒ Tasks
constructor
A new instance of Tasks.
Constructor Details
#initialize(env = nil) ⇒ Tasks
Returns a new instance of Tasks.
8 9 10 11 12 |
# File 'lib/tasks.rb', line 8 def initialize(env = nil) @@default = self @env = env @env = Environment.new if @env.nil? end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
4 5 6 |
# File 'lib/tasks.rb', line 4 def env @env end |
Class Method Details
Instance Method Details
#execute(value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tasks.rb', line 14 def execute(value) if value.respond_to?(:execute) value.update if value.respond_to?(:update) value.execute elsif value.is_a?(String) puts `#{value}` elsif value.is_a?(Array) value.each { |e| execute(e) } end end |
#execute_task(task) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tasks.rb', line 25 def execute_task(task) if defined?(COMMANDS) && COMMANDS.key?(task) puts DELIMITER if defined?(DEBUG) puts ":#{task}" unless @env.colorize? if @env.colorize? require "ansi/code" puts ANSI.white + ANSI.bold + ":#{task}" + ANSI.reset if @env.colorize? end execute(COMMANDS[task]) end end |