Class: Cult::BuildTask
Constant Summary collapse
- LEADING_ZEROS =
3
- BASENAME_RE =
/\A(\d{#{LEADING_ZEROS},})-([\w-]+)(\..+)?\z/i
Instance Attribute Summary collapse
-
#serial ⇒ Object
readonly
Returns the value of attribute serial.
Attributes inherited from Task
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(role, path) ⇒ BuildTask
constructor
A new instance of BuildTask.
Methods inherited from Task
all_for_role, collection_name, #file_mode, #relative_path, spawn
Methods included from SingletonInstances
Methods included from Transferable
#binary?, #collection_name, #contents, #file_mode, included, #name, #remote_path, #role_relative_path
Constructor Details
#initialize(role, path) ⇒ BuildTask
Returns a new instance of BuildTask.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cult/task.rb', line 66 def initialize(role, path) super if (m = BASENAME_RE.match(name)) @serial = m[1].to_i @name = m[2] else fail ArgumentError end end |
Instance Attribute Details
#serial ⇒ Object (readonly)
Returns the value of attribute serial.
64 65 66 |
# File 'lib/cult/task.rb', line 64 def serial @serial end |
Class Method Details
.from_serial_and_name(role, serial:, name:) ⇒ Object
78 79 80 81 |
# File 'lib/cult/task.rb', line 78 def self.from_serial_and_name(role, serial:, name:) basename = sprintf("%0#{LEADING_ZEROS}d-%s", serial, name) new(role, File.join(role.path, collection_name, basename)) end |
.valid_name?(basename) ⇒ Boolean
59 60 61 |
# File 'lib/cult/task.rb', line 59 def self.valid_name?(basename) !! basename.match(BASENAME_RE) end |