Class: Bolt::Task
- Inherits:
-
Struct
- Object
- Struct
- Bolt::Task
- Defined in:
- lib/bolt/task.rb
Overview
Represents a Task.
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#files ⇒ Object
Returns the value of attribute files.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(task) ⇒ Task
constructor
A new instance of Task.
- #parameters ⇒ Object
-
#select_implementation(target, additional_features = []) ⇒ Object
Returns a hash of implementation name, path to executable, input method (if defined), and any additional files (name and path).
- #supports_noop ⇒ Object
Constructor Details
#initialize(task) ⇒ Task
Returns a new instance of Task.
17 18 19 20 21 |
# File 'lib/bolt/task.rb', line 17 def initialize(task) super(nil, nil, [], {}) task.reject { |k, _| k == 'parameters' }.each { |k, v| self[k] = v } end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file
10 11 12 |
# File 'lib/bolt/task.rb', line 10 def file @file end |
#files ⇒ Object
Returns the value of attribute files
10 11 12 |
# File 'lib/bolt/task.rb', line 10 def files @files end |
#metadata ⇒ Object
Returns the value of attribute metadata
10 11 12 |
# File 'lib/bolt/task.rb', line 10 def @metadata end |
#name ⇒ Object
Returns the value of attribute name
10 11 12 |
# File 'lib/bolt/task.rb', line 10 def name @name end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/bolt/task.rb', line 23 def description ['description'] end |
#parameters ⇒ Object
27 28 29 |
# File 'lib/bolt/task.rb', line 27 def parameters ['parameters'] end |
#select_implementation(target, additional_features = []) ⇒ Object
Returns a hash of implementation name, path to executable, input method (if defined), and any additional files (name and path)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/bolt/task.rb', line 42 def select_implementation(target, additional_features = []) raise 'select_implementation only supported with multiple files' if files.nil? || files.empty? impl = if (impls = ['implementations']) available_features = target.features + additional_features impl = impls.find { |imp| Set.new(imp['requirements']).subset?(available_features) } raise "No suitable implementation of #{name} for #{target.name}" unless impl impl = impl.dup impl['path'] = file_map[impl['name']] impl.delete('requirements') impl else files.first.dup end inmethod = impl['input_method'] || ['input_method'] impl['input_method'] = inmethod unless inmethod.nil? mfiles = impl.fetch('files', []) + .fetch('files', []) impl['files'] = mfiles.map { |file| { 'name' => file, 'path' => file_map[file] } } unless mfiles.empty? impl end |
#supports_noop ⇒ Object
31 32 33 |
# File 'lib/bolt/task.rb', line 31 def supports_noop ['supports_noop'] end |