Class: DeployPin::TaskCriteria
- Inherits:
-
Object
- Object
- DeployPin::TaskCriteria
- Defined in:
- lib/deploy_pin/task_criteria.rb
Constant Summary collapse
- SKIP_REGEXEP =
/\A!(.+[^!])\z/
- FORCE_REGEXP =
/\A([^!].+)!\z/
- COMMON_REGEXP =
/(^[^!]?.+[^!]?$)/
Instance Attribute Summary collapse
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
Instance Method Summary collapse
-
#initialize(identifiers:) ⇒ TaskCriteria
constructor
A new instance of TaskCriteria.
- #suitable?(task) ⇒ Boolean
Constructor Details
#initialize(identifiers:) ⇒ TaskCriteria
Returns a new instance of TaskCriteria.
12 13 14 |
# File 'lib/deploy_pin/task_criteria.rb', line 12 def initialize(identifiers:) @identifiers = identifiers end |
Instance Attribute Details
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
10 11 12 |
# File 'lib/deploy_pin/task_criteria.rb', line 10 def identifiers @identifiers end |
Instance Method Details
#suitable?(task) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/deploy_pin/task_criteria.rb', line 16 def suitable?(task) task_cover = lambda { |task, regexp| items = identifiers.flat_map { |x| x.to_s.scan(regexp) }.flatten items & [task.group, task.identifier.to_s] } return false if task_cover.call(task, SKIP_REGEXEP).any? return true if task_cover.call(task, FORCE_REGEXP).any? task_cover.call(task, COMMON_REGEXP).any? && !task.done? end |