Class: TuyaCIMonitor
- Inherits:
-
Object
show all
- Defined in:
- lib/tuya/ci/DSL/tuya_ci_monitor.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#ci(*args, &block) ⇒ Object
-
#dsl(process, args, &block) ⇒ Object
-
#exe ⇒ Object
-
#exe_action(action, options) ⇒ Object
-
#exe_error(process, error, position, options) ⇒ Object
-
#initialize ⇒ TuyaCIMonitor
constructor
A new instance of TuyaCIMonitor.
-
#method_missing(m, *args, &block) ⇒ Object
-
#tuya_sh(shell) ⇒ Object
-
#tuya_sh_from_git(shell, git) ⇒ Object
-
#tuya_stop_build(message) ⇒ Object
Constructor Details
Returns a new instance of TuyaCIMonitor.
3
4
5
6
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 3
def initialize
@methods = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
72
73
74
75
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 72
def method_missing(m, *args, &block)
dsl m, args, &block
end
|
Instance Attribute Details
#methods ⇒ Object
Returns the value of attribute methods.
2
3
4
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 2
def methods
@methods
end
|
#name ⇒ Object
Returns the value of attribute name.
2
3
4
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 2
def name
@name
end
|
Instance Method Details
#ci(*args, &block) ⇒ Object
53
54
55
56
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 53
def ci(*args, &block)
dsl 'root', args, &block
end
|
#dsl(process, args, &block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 58
def dsl(process, args, &block)
if block_given?
if process
if process == 'root'
instance_eval &block
else
@methods[process] = block
end
end
end
end
|
#exe ⇒ Object
46
47
48
49
50
51
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 46
def exe
@methods.each_key do |key|
l = @methods[key]
l.call
end
end
|
#exe_action(action, options) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 8
def exe_action(action, options)
method = @methods[action.to_sym]
begin
method.call options if method
rescue Exception => e
if e.class == TuyaCIMonitorStopError
puts "Trigger Exception cached, tuya_stop_build has been used. the build is end here".red
raise $!
else
puts "Trigger Exception cached, you can puts detail in your error method".red
exe_error action, $!, $@, options
end
ensure
end
end
|
#exe_error(process, error, position, options) ⇒ Object
40
41
42
43
44
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 40
def exe_error(process, error, position, options)
method = @methods['error'.to_sym]
method.call error, position, options, process
end
|
#tuya_sh(shell) ⇒ Object
29
30
31
32
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 29
def tuya_sh(shell)
dsl = TuyaCIDSL::DSLExecute.new shell
dsl.execute
end
|
#tuya_sh_from_git(shell, git) ⇒ Object
34
35
36
37
38
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 34
def tuya_sh_from_git(shell, git)
dsl = TuyaCIDSL::DSLExecute.new shell
dsl.download git
dsl.execute
end
|
#tuya_stop_build(message) ⇒ Object
25
26
27
|
# File 'lib/tuya/ci/DSL/tuya_ci_monitor.rb', line 25
def tuya_stop_build(message)
raise TuyaCIMonitorStopError, message
end
|