Class: Rake::Task
Constant Summary
collapse
- ALLOWED_FLOW_RULES =
i[run enabled revert].freeze
Instance Method Summary
collapse
#applied?, #apply, #flush_history, #reset, #revert, #reverted?, #task_history
Instance Method Details
#add_flow_rule(rule, val) ⇒ Object
116
117
118
119
|
# File 'lib/bow/rake.rb', line 116
def add_flow_rule(rule, val)
return unless ALLOWED_FLOW_RULES.include? rule
flow[rule.to_sym] = val
end
|
#apply_revert_task ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/bow/rake.rb', line 69
def apply_revert_task
revert_task = find_revert_task
return if reverted? || !revert_task || revert_task.applied?
result = revert_task.execute
revert_task.apply if revert_task.run_once?
revert
flush_history
result
end
|
#clear ⇒ Object
79
80
81
82
|
# File 'lib/bow/rake.rb', line 79
def clear
clear_flow
orig__clear
end
|
#clear_flow ⇒ Object
84
85
86
87
|
# File 'lib/bow/rake.rb', line 84
def clear_flow
@flow = {}
self
end
|
#disabled? ⇒ Boolean
89
90
91
|
# File 'lib/bow/rake.rb', line 89
def disabled?
!enabled?
end
|
#enabled? ⇒ Boolean
97
98
99
|
# File 'lib/bow/rake.rb', line 97
def enabled?
!!flow[:enabled]
end
|
#find_revert_task ⇒ Object
105
106
107
108
|
# File 'lib/bow/rake.rb', line 105
def find_revert_task
return unless flow[:revert]
application.lookup(flow[:revert], @scope)
end
|
#flow ⇒ Object
101
102
103
|
# File 'lib/bow/rake.rb', line 101
def flow
@flow ||= { enabled: true, run: :always, revert: nil }
end
|
#invoke_with_call_chain(task_args, invocation_chain) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/bow/rake.rb', line 57
def invoke_with_call_chain(task_args, invocation_chain)
if disabled?
return unless applied?
return apply_revert_task
end
return if run_once? && applied?
result = orig__invoke_with_call_chain(task_args, invocation_chain)
apply
flush_history
result
end
|
#orig__clear ⇒ Object
54
|
# File 'lib/bow/rake.rb', line 54
alias orig__clear clear
|
#orig__invoke_with_call_chain ⇒ Object
55
|
# File 'lib/bow/rake.rb', line 55
alias orig__invoke_with_call_chain invoke_with_call_chain
|
#run_once? ⇒ Boolean
93
94
95
|
# File 'lib/bow/rake.rb', line 93
def run_once?
flow[:run] == :once
end
|
#unpack_flow(init_flow) ⇒ Object
111
112
113
114
|
# File 'lib/bow/rake.rb', line 111
def unpack_flow(init_flow)
return unless init_flow
init_flow.each { |rule, val| add_flow_rule(rule, val) }
end
|