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
113
114
115
116
|
# File 'lib/bow/rake.rb', line 113
def add_flow_rule(rule, val)
return unless ALLOWED_FLOW_RULES.include? rule
flow[rule.to_sym] = val
end
|
#apply_revert_task ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/bow/rake.rb', line 66
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
76
77
78
79
|
# File 'lib/bow/rake.rb', line 76
def clear
clear_flow
orig__clear
end
|
#clear_flow ⇒ Object
81
82
83
84
|
# File 'lib/bow/rake.rb', line 81
def clear_flow
@flow = {}
self
end
|
#disabled? ⇒ Boolean
86
87
88
|
# File 'lib/bow/rake.rb', line 86
def disabled?
!enabled?
end
|
#enabled? ⇒ Boolean
94
95
96
|
# File 'lib/bow/rake.rb', line 94
def enabled?
!!flow[:enabled]
end
|
#find_revert_task ⇒ Object
102
103
104
105
|
# File 'lib/bow/rake.rb', line 102
def find_revert_task
return unless flow[:revert]
application.lookup(flow[:revert])
end
|
#flow ⇒ Object
98
99
100
|
# File 'lib/bow/rake.rb', line 98
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
|
# File 'lib/bow/rake.rb', line 57
def invoke_with_call_chain(task_args, invocation_chain) return apply_revert_task if disabled?
return if run_once? && applied?
result = orig__invoke_with_call_chain(task_args, invocation_chain)
apply if run_once?
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
90
91
92
|
# File 'lib/bow/rake.rb', line 90
def run_once?
flow[:run] == :once
end
|
#unpack_flow(init_flow) ⇒ Object
108
109
110
111
|
# File 'lib/bow/rake.rb', line 108
def unpack_flow(init_flow)
return unless init_flow
init_flow.each { |rule, val| add_flow_rule(rule, val) }
end
|