Class: Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks.rb

Constant Summary collapse

@@default =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ Tasks

Returns a new instance of Tasks.



5
6
7
8
9
# File 'lib/tasks.rb', line 5

def initialize env=nil
	@@default=self
	@env=env
	@env=Environment.new if @env.nil?
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



2
3
4
# File 'lib/tasks.rb', line 2

def env
  @env
end

Class Method Details

.execute_task(task) ⇒ Object



39
40
41
42
# File 'lib/tasks.rb', line 39

def self.execute_task task
	@@default=Tasks.new if @@default.nil?
	@@default.execute_task task
end

Instance Method Details

#execute(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tasks.rb', line 11

def execute value
  if(value.respond_to?(:execute))
    value.update if value.respond_to?(:update)
    value.execute
  else
    if(value.is_a?(String))
      puts `#{value}`
    else
      if(value.is_a?(Array))
        value.each{|e| execute(e)}
      end
    end
    end
end

#execute_task(task) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tasks.rb', line 26

def execute_task task
	if(defined?(COMMANDS))
		if(COMMANDS.has_key?(task))
			puts ":#{task}" if !@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
end