Class: Cult::Task
- Inherits:
-
Object
- Object
- Cult::Task
- Includes:
- SingletonInstances, Transferable
- Defined in:
- lib/cult/task.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
-
#file_mode ⇒ Object
Task files are executable by anyone: this makes re-exec’ing tasks as another user trivial.
-
#initialize(role, path) ⇒ Task
constructor
A new instance of Task.
- #relative_path ⇒ Object
Methods included from SingletonInstances
Methods included from Transferable
#binary?, #collection_name, #contents, included, #remote_path, #role_relative_path
Constructor Details
#initialize(role, path) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 |
# File 'lib/cult/task.rb', line 10 def initialize(role, path) @role = role @path = path @name = File.basename(path) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cult/task.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/cult/task.rb', line 7 def path @path end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/cult/task.rb', line 6 def role @role end |
Class Method Details
.all_for_role(project, role) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/cult/task.rb', line 44 def self.all_for_role(project, role) fail ArgumentError if block_given? Dir.glob(File.join(role.path, "tasks", "*")).sort.map do |path| spawn(role, path) end.compact.to_named_array end |
.collection_name ⇒ Object
17 18 19 |
# File 'lib/cult/task.rb', line 17 def self.collection_name "tasks" end |
Instance Method Details
#file_mode ⇒ Object
Task files are executable by anyone: this makes re-exec’ing tasks as another user trivial.
29 30 31 |
# File 'lib/cult/task.rb', line 29 def file_mode super | 0111 end |
#relative_path ⇒ Object
22 23 24 |
# File 'lib/cult/task.rb', line 22 def relative_path File.basename(path) end |