Class: DeployPin::Task

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

Overview

Task wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Task

Returns a new instance of Task.



10
11
12
13
14
15
# File 'lib/deploy_pin/task.rb', line 10

def initialize(file)
  @file = file
  @uuid = nil
  @group = nil
  @script = ""
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/deploy_pin/task.rb', line 5

def file
  @file
end

#groupObject (readonly)

Returns the value of attribute group.



5
6
7
# File 'lib/deploy_pin/task.rb', line 5

def group
  @group
end

#scriptObject (readonly)

Returns the value of attribute script.



5
6
7
# File 'lib/deploy_pin/task.rb', line 5

def script
  @script
end

#uuidObject (readonly)

Returns the value of attribute uuid.



5
6
7
# File 'lib/deploy_pin/task.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#<=>(task_b) ⇒ Object

for sorting



33
34
35
# File 'lib/deploy_pin/task.rb', line 33

def <=>(task_b)
  group_index <=> task_b.group_index
end

#detailsObject



28
29
30
# File 'lib/deploy_pin/task.rb', line 28

def details
  puts @uuid, @group, @script
end

#group_indexObject



37
38
39
# File 'lib/deploy_pin/task.rb', line 37

def group_index
  DeployPin.groups.index(group)
end

#parse_fileObject



21
22
23
24
25
26
# File 'lib/deploy_pin/task.rb', line 21

def parse_file
  @script = File.read(file)
  @script.lines[0] =~ /\A# (\d+):(\w+)/
  @uuid = $1
  @group = $2
end

#runObject



17
18
19
# File 'lib/deploy_pin/task.rb', line 17

def run
  eval(@script)
end