automation_object 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/automation_object.rb +22 -11
- data/lib/automation_object/blue_print.rb +13 -12
- data/lib/automation_object/blue_print/composite/automatic_onload_modal.rb +9 -8
- data/lib/automation_object/blue_print/composite/base.rb +5 -4
- data/lib/automation_object/blue_print/composite/custom_method.rb +8 -7
- data/lib/automation_object/blue_print/composite/element.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_array.rb +6 -5
- data/lib/automation_object/blue_print/composite/element_hash.rb +7 -6
- data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +7 -7
- data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +5 -4
- data/lib/automation_object/blue_print/composite/hook.rb +9 -11
- data/lib/automation_object/blue_print/composite/hook_action.rb +25 -24
- data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +14 -13
- data/lib/automation_object/blue_print/composite/modal.rb +11 -21
- data/lib/automation_object/blue_print/composite/screen.rb +22 -16
- data/lib/automation_object/blue_print/composite/top.rb +13 -12
- data/lib/automation_object/blue_print/composite/view.rb +27 -16
- data/lib/automation_object/blue_print/hash_adapter.rb +15 -11
- data/lib/automation_object/blue_print/hash_adapter/automatic_onload_modal.rb +12 -11
- data/lib/automation_object/blue_print/hash_adapter/composite.rb +28 -25
- data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/element.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_array.rb +10 -9
- data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +11 -10
- data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +20 -25
- data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +15 -14
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +19 -24
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +8 -5
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +7 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +28 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +12 -13
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +9 -8
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +27 -23
- data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +25 -21
- data/lib/automation_object/blue_print/hash_adapter/hook.rb +14 -11
- data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +45 -47
- data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +24 -28
- data/lib/automation_object/blue_print/hash_adapter/modal.rb +14 -13
- data/lib/automation_object/blue_print/hash_adapter/screen.rb +23 -22
- data/lib/automation_object/blue_print/hash_adapter/top.rb +16 -15
- data/lib/automation_object/blue_print/hash_adapter/view.rb +58 -4
- data/lib/automation_object/blue_print/yaml_adapter.rb +33 -34
- data/lib/automation_object/driver.rb +15 -13
- data/lib/automation_object/driver/appium_adapter/driver.rb +47 -46
- data/lib/automation_object/driver/appium_adapter/element.rb +29 -96
- data/lib/automation_object/driver/base.rb +4 -2
- data/lib/automation_object/driver/common_selenium/driver.rb +60 -0
- data/lib/automation_object/driver/common_selenium/element.rb +107 -0
- data/lib/automation_object/driver/common_selenium/element_geometry.rb +86 -0
- data/lib/automation_object/driver/driver.rb +60 -30
- data/lib/automation_object/driver/element.rb +70 -15
- data/lib/automation_object/driver/nokogiri_adapter/driver.rb +88 -34
- data/lib/automation_object/driver/nokogiri_adapter/element.rb +94 -16
- data/lib/automation_object/driver/nokogiri_adapter/error.rb +29 -8
- data/lib/automation_object/driver/nokogiri_adapter/{backup/form.rb → form.rb} +19 -6
- data/lib/automation_object/driver/nokogiri_adapter/request.rb +17 -0
- data/lib/automation_object/driver/nokogiri_adapter/session.rb +94 -0
- data/lib/automation_object/driver/nokogiri_adapter/window.rb +86 -0
- data/lib/automation_object/driver/selenium_adapter/driver.rb +36 -45
- data/lib/automation_object/driver/selenium_adapter/element.rb +15 -85
- data/lib/automation_object/dsl.rb +11 -28
- data/lib/automation_object/dsl/_base.rb +70 -0
- data/lib/automation_object/dsl/_proxy.rb +24 -0
- data/lib/automation_object/dsl/element.rb +34 -0
- data/lib/automation_object/dsl/element_array.rb +34 -0
- data/lib/automation_object/dsl/element_hash.rb +34 -0
- data/lib/automation_object/dsl/modal.rb +43 -0
- data/lib/automation_object/dsl/screen.rb +45 -0
- data/lib/automation_object/dsl/top.rb +25 -0
- data/lib/automation_object/framework.rb +28 -38
- data/lib/automation_object/helpers/composite.rb +30 -27
- data/lib/automation_object/helpers/composite_hook.rb +16 -15
- data/lib/automation_object/{blue_print/helpers/file_helper.rb → helpers/file.rb} +12 -12
- data/lib/automation_object/helpers/hash.rb +6 -5
- data/lib/automation_object/helpers/kernel.rb +11 -0
- data/lib/automation_object/helpers/{reflection_helper.rb → reflection.rb} +9 -8
- data/lib/automation_object/helpers/string.rb +25 -15
- data/lib/automation_object/{proxies → proxy}/mutex_proxy.rb +18 -21
- data/lib/automation_object/proxy/proxy.rb +23 -0
- data/lib/automation_object/proxy/throttle_proxy.rb +52 -0
- data/lib/automation_object/state.rb +11 -29
- data/lib/automation_object/state/{blue_print_adapter/composite.rb → composite/_base.rb} +35 -25
- data/lib/automation_object/state/{blue_print_adapter/helpers/element_helper.rb → composite/_common_element.rb} +11 -11
- data/lib/automation_object/state/composite/element.rb +22 -0
- data/lib/automation_object/state/composite/element_array.rb +27 -0
- data/lib/automation_object/state/composite/element_hash.rb +33 -0
- data/lib/automation_object/state/composite/element_proxy.rb +33 -0
- data/lib/automation_object/state/composite/helpers/window.rb +61 -0
- data/lib/automation_object/state/composite/helpers/window_manager.rb +60 -0
- data/lib/automation_object/state/composite/hook.rb +56 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_action.rb +10 -8
- data/lib/automation_object/state/composite/hook_actions/action_loop.rb +36 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_screen.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_to_previous_screen.rb +7 -5
- data/lib/automation_object/state/composite/hook_actions/close_modal.rb +29 -0
- data/lib/automation_object/state/composite/hook_actions/close_screen.rb +19 -0
- data/lib/automation_object/state/composite/hook_actions/element_requirement.rb +32 -0
- data/lib/automation_object/state/composite/hook_actions/new_screen.rb +35 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/possible_screen_changes.rb +8 -7
- data/lib/automation_object/state/composite/hook_actions/reset_screen.rb +14 -0
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/show_modal.rb +7 -5
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/sleep.rb +4 -2
- data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/wait_for_elements.rb +7 -5
- data/lib/automation_object/state/composite/modal.rb +45 -0
- data/lib/automation_object/state/composite/screen.rb +58 -0
- data/lib/automation_object/state/composite/top.rb +51 -0
- data/lib/automation_object/state/error.rb +45 -6
- data/lib/automation_object/state/session.rb +25 -23
- data/lib/automation_object/step_definitions.rb +5 -3
- data/lib/automation_object/step_definitions/element.rb +77 -0
- data/lib/automation_object/step_definitions/element_array.rb +135 -0
- data/lib/automation_object/step_definitions/element_hash.rb +126 -0
- data/lib/automation_object/step_definitions/screen.rb +62 -0
- data/lib/automation_object/step_definitions/{cache.rb → support/cache.rb} +8 -6
- data/lib/automation_object/step_definitions/support/element_array.rb +40 -0
- data/lib/automation_object/step_definitions/support/element_hash.rb +41 -0
- data/lib/automation_object/step_definitions/{parse.rb → support/parse.rb} +8 -6
- data/lib/automation_object/version.rb +2 -1
- metadata +203 -103
- data/lib/automation_object/driver/helpers/selenium_driver_helper.rb +0 -41
- data/lib/automation_object/driver/helpers/selenium_element_helper.rb +0 -138
- data/lib/automation_object/driver/nokogiri_adapter/backup/driver.rb +0 -83
- data/lib/automation_object/driver/nokogiri_adapter/backup/element.rb +0 -66
- data/lib/automation_object/driver/nokogiri_adapter/backup/helpers/driver_element_helper.rb +0 -52
- data/lib/automation_object/driver/nokogiri_adapter/backup/session.rb +0 -115
- data/lib/automation_object/dsl/blue_print_adapter.rb +0 -16
- data/lib/automation_object/dsl/blue_print_adapter/composite.rb +0 -54
- data/lib/automation_object/dsl/blue_print_adapter/element.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_array.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/element_hash.rb +0 -14
- data/lib/automation_object/dsl/blue_print_adapter/modal.rb +0 -23
- data/lib/automation_object/dsl/blue_print_adapter/screen.rb +0 -26
- data/lib/automation_object/dsl/blue_print_adapter/top.rb +0 -19
- data/lib/automation_object/dsl/models.rb +0 -18
- data/lib/automation_object/dsl/proxies/element.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_array.rb +0 -16
- data/lib/automation_object/dsl/proxies/element_hash.rb +0 -16
- data/lib/automation_object/dsl/proxies/helpers/composite_helper.rb +0 -74
- data/lib/automation_object/dsl/proxies/modal.rb +0 -17
- data/lib/automation_object/dsl/proxies/screen.rb +0 -17
- data/lib/automation_object/dsl/proxies/top.rb +0 -17
- data/lib/automation_object/proxies/proxy.rb +0 -20
- data/lib/automation_object/proxies/throttle_proxy.rb +0 -57
- data/lib/automation_object/state/blue_print_adapter.rb +0 -16
- data/lib/automation_object/state/blue_print_adapter/element.rb +0 -20
- data/lib/automation_object/state/blue_print_adapter/element_array.rb +0 -25
- data/lib/automation_object/state/blue_print_adapter/element_hash.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/element_proxy.rb +0 -28
- data/lib/automation_object/state/blue_print_adapter/helpers/screen_manager.rb +0 -137
- data/lib/automation_object/state/blue_print_adapter/helpers/window.rb +0 -39
- data/lib/automation_object/state/blue_print_adapter/hook.rb +0 -56
- data/lib/automation_object/state/blue_print_adapter/hook_actions/action_loop.rb +0 -35
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_modal.rb +0 -31
- data/lib/automation_object/state/blue_print_adapter/hook_actions/close_screen.rb +0 -19
- data/lib/automation_object/state/blue_print_adapter/hook_actions/element_requirement.rb +0 -34
- data/lib/automation_object/state/blue_print_adapter/hook_actions/new_screen.rb +0 -37
- data/lib/automation_object/state/blue_print_adapter/hook_actions/reset_screen.rb +0 -18
- data/lib/automation_object/state/blue_print_adapter/modal.rb +0 -26
- data/lib/automation_object/state/blue_print_adapter/screen.rb +0 -32
- data/lib/automation_object/state/blue_print_adapter/top.rb +0 -45
- data/lib/automation_object/step_definitions/action.rb +0 -21
- data/lib/automation_object/step_definitions/element/actions.rb +0 -87
- data/lib/automation_object/step_definitions/element/regex.rb +0 -24
- data/lib/automation_object/step_definitions/element/steps.rb +0 -67
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Require parent class
|
2
3
|
require_relative 'composite'
|
3
4
|
|
4
5
|
require_relative 'hook_action'
|
@@ -7,29 +8,31 @@ require_relative 'hook_element_requirements'
|
|
7
8
|
module AutomationObject
|
8
9
|
module BluePrint
|
9
10
|
module HashAdapter
|
10
|
-
#Hook composite
|
11
|
+
# Hook composite
|
11
12
|
class Hook < Composite
|
12
|
-
#Call the live? method so that it creates the needed Array of ElementRequirement interfaces
|
13
|
+
# Call the live? method so that it creates the needed Array of ElementRequirement interfaces
|
13
14
|
before_create :live?
|
14
15
|
|
15
|
-
#Relationships
|
16
|
+
# Relationships
|
16
17
|
has_one :before, interface: HookAction
|
17
18
|
has_one :after, interface: HookAction
|
18
19
|
|
19
|
-
#Validations
|
20
|
+
# Validations
|
20
21
|
validates_keys allowed_keys: [:before, :live?, :after]
|
21
22
|
|
22
23
|
# @return [Array<HookElementRequirements>] array of element requirements
|
23
24
|
def live?
|
24
|
-
return @live if @live
|
25
|
+
return @live if defined? @live
|
25
26
|
|
26
|
-
children =
|
27
|
-
children =
|
27
|
+
children = hash[:live?]
|
28
|
+
children = children.is_a?(Array) ? children : []
|
28
29
|
|
29
|
-
@live =
|
30
|
-
|
30
|
+
@live = create_array_children(:live, children,
|
31
|
+
interface: HookElementRequirements,
|
32
|
+
location: location + '[live?]')
|
33
|
+
@live
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
35
|
-
end
|
38
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Require parent class
|
2
3
|
require_relative 'composite'
|
3
4
|
require_relative 'hook_element_requirements'
|
4
5
|
|
5
6
|
module AutomationObject
|
6
7
|
module BluePrint
|
7
8
|
module HashAdapter
|
8
|
-
#Hook action composite
|
9
|
+
# Hook action composite
|
9
10
|
class HookAction < Composite
|
10
|
-
#Call the wait_for_elements method to generate the children
|
11
|
+
# Call the wait_for_elements method to generate the children
|
11
12
|
before_create :wait_for_elements
|
12
13
|
|
13
|
-
#Validations
|
14
|
+
# Validations
|
14
15
|
validates_keys allowed_keys: [:new_screen, :show_modal, :close_screen, :change_screen,
|
15
16
|
:sleep, :wait_for_elements, :change_to_previous_screen, :close_modal, :reset_screen,
|
16
17
|
:possible_screen_changes]
|
@@ -26,109 +27,106 @@ module AutomationObject
|
|
26
27
|
validates :sleep, instance_of: Numeric
|
27
28
|
validates :wait_for_elements, instance_of: Array
|
28
29
|
|
29
|
-
#Get the order to run the hook in
|
30
|
+
# Get the order to run the hook in
|
30
31
|
# @return [Array<Symbol>] list of hook methods to run in given order
|
31
32
|
def hook_order
|
32
|
-
|
33
|
+
hash.keys
|
33
34
|
end
|
34
35
|
|
35
|
-
#Get length of hook actions
|
36
|
+
# Get length of hook actions
|
36
37
|
# @return [Integer] length of hook actions
|
37
38
|
def length
|
38
|
-
|
39
|
+
hash.keys.length
|
39
40
|
end
|
40
41
|
|
41
|
-
#See if hook actions are empty
|
42
|
+
# See if hook actions are empty
|
42
43
|
# @return [Boolean] if hook actions are empty
|
43
44
|
def empty?
|
44
|
-
|
45
|
+
hash.keys.empty?
|
45
46
|
end
|
46
47
|
|
47
48
|
# @return [Symbol, nil] screen to change to
|
48
49
|
def change_screen
|
49
|
-
change_screen =
|
50
|
+
change_screen = hash[:change_screen]
|
50
51
|
|
51
52
|
case change_screen
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
when Symbol, String
|
54
|
+
return change_screen.to_sym
|
55
|
+
else
|
56
|
+
return nil
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
60
|
# @return [Symbol, nil] new screen
|
60
61
|
def new_screen
|
61
|
-
new_screen =
|
62
|
+
new_screen = hash[:new_screen]
|
62
63
|
|
63
64
|
case new_screen
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
when Symbol, String
|
66
|
+
return new_screen.to_sym
|
67
|
+
else
|
68
|
+
return nil
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
72
|
# @return [Boolean]
|
72
73
|
def close_screen
|
73
|
-
|
74
|
+
hash[:close_screen] ||= false
|
74
75
|
end
|
75
76
|
|
76
77
|
# @return [Boolean]
|
77
78
|
def close_modal
|
78
|
-
|
79
|
+
hash[:close_modal] ||= false
|
79
80
|
end
|
80
81
|
|
81
82
|
# @return [Boolean]
|
82
83
|
def change_to_previous_screen
|
83
|
-
|
84
|
+
hash[:change_to_previous_screen] ||= false
|
84
85
|
end
|
85
86
|
|
86
87
|
# @return [Symbol, nil]
|
87
88
|
def show_modal
|
88
|
-
show_modal =
|
89
|
+
show_modal = hash[:show_modal]
|
89
90
|
|
90
91
|
case show_modal
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
when Symbol, String
|
93
|
+
return show_modal.to_sym
|
94
|
+
else
|
95
|
+
return nil
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
98
99
|
# @return [Array]
|
99
100
|
def possible_screen_changes
|
100
|
-
if
|
101
|
-
|
102
|
-
|
103
|
-
return Array.new
|
104
|
-
end
|
101
|
+
return hash[:possible_screen_changes].map(&:to_sym) if hash[:possible_screen_changes].is_a?(Array)
|
102
|
+
|
103
|
+
[]
|
105
104
|
end
|
106
105
|
|
107
|
-
|
106
|
+
# @return [Boolean] reset the screen?
|
108
107
|
def reset_screen
|
109
|
-
|
108
|
+
hash[:reset_screen] ||= false
|
110
109
|
end
|
111
110
|
|
112
|
-
|
111
|
+
# @return [Numeric] amount of time to sleep
|
113
112
|
def sleep
|
114
|
-
|
113
|
+
hash[:sleep] ||= 0
|
115
114
|
end
|
116
115
|
|
117
|
-
#Custom method for array of children instead of Hash
|
116
|
+
# Custom method for array of children instead of Hash
|
118
117
|
# @return [Array<HookElementRequirements>] array of wait for element children
|
119
118
|
def wait_for_elements
|
120
|
-
return @wait_for_elements if @wait_for_elements
|
121
|
-
wait_for_elements =
|
119
|
+
return @wait_for_elements if defined? @wait_for_elements
|
120
|
+
wait_for_elements = hash[:wait_for_elements]
|
122
121
|
|
123
|
-
children =
|
124
|
-
@wait_for_elements =
|
125
|
-
|
126
|
-
|
127
|
-
})
|
122
|
+
children = wait_for_elements.is_a?(Array) ? wait_for_elements : []
|
123
|
+
@wait_for_elements = create_array_children(:wait_for_elements, children,
|
124
|
+
interface: HookElementRequirements,
|
125
|
+
location: location + '[wait_for_elements]')
|
128
126
|
|
129
|
-
|
127
|
+
@wait_for_elements
|
130
128
|
end
|
131
129
|
end
|
132
130
|
end
|
133
131
|
end
|
134
|
-
end
|
132
|
+
end
|
@@ -1,64 +1,60 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Require parent class
|
2
3
|
require_relative 'composite'
|
3
4
|
|
4
5
|
module AutomationObject
|
5
6
|
module BluePrint
|
6
7
|
module HashAdapter
|
7
|
-
#Hook Element Requirements-level composite
|
8
|
+
# Hook Element Requirements-level composite
|
8
9
|
class HookElementRequirements < Composite
|
9
|
-
#Valdiations
|
10
|
+
# Valdiations
|
10
11
|
validates :element_name, presence_of: true, instance_of: [String, Symbol], element_presence_of: true
|
11
12
|
validates :exists?, presence_of: true, instance_of: [FalseClass, TrueClass]
|
12
13
|
|
13
|
-
#Get the order to run the hook in
|
14
|
+
# Get the order to run the hook in
|
14
15
|
# @return [Array<Symbol>] list of hook methods to run in given order
|
15
16
|
def hook_order
|
16
|
-
hook_order = [:exists?] #Always put exists? first
|
17
|
+
hook_order = [:exists?] # Always put exists? first
|
17
18
|
|
18
|
-
|
19
|
+
hash.each_key do |hook_name|
|
19
20
|
hook_order.push(hook_name) unless [:element_name, :exists?].include?(hook_name)
|
20
|
-
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
+
hook_order
|
23
24
|
end
|
24
25
|
|
25
|
-
#Get element requirement
|
26
|
+
# Get element requirement
|
26
27
|
# @param name [Symbol] name of requested requirement
|
27
28
|
def requirement(name)
|
28
|
-
|
29
|
+
hash[name] ||= nil
|
29
30
|
end
|
30
31
|
|
31
|
-
#Get name of the element
|
32
|
+
# Get name of the element
|
32
33
|
# @return [Symbol] name of element
|
33
34
|
def element_name
|
34
|
-
element_name =
|
35
|
+
element_name = hash[:element_name]
|
35
36
|
|
36
37
|
case element_name
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
when Symbol, String
|
39
|
+
return element_name.to_sym
|
40
|
+
else
|
41
|
+
return nil
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
#Convience for getting element blueprints
|
45
|
+
# Convience for getting element blueprints
|
45
46
|
# @return [AutomationObject::BluePrint::HashAdapter::Element]
|
46
47
|
def element_blueprints(composite_object = nil)
|
47
|
-
unless composite_object
|
48
|
-
composite_object = self
|
49
|
-
end
|
48
|
+
composite_object = self unless composite_object
|
50
49
|
|
51
|
-
#Traverse!
|
52
|
-
if composite_object.hash[:elements].is_a?(Hash)
|
50
|
+
# Traverse!
|
51
|
+
return composite_object.elements[element_name] if composite_object.hash[:elements].is_a?(Hash)
|
53
52
|
|
54
|
-
|
55
|
-
elsif composite_object.parent
|
56
|
-
return self.element_blueprints(composite_object.parent)
|
57
|
-
end
|
53
|
+
return element_blueprints(composite_object.parent) if composite_object.parent
|
58
54
|
|
59
|
-
|
55
|
+
nil
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
63
59
|
end
|
64
|
-
end
|
60
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Require parent class
|
2
3
|
require_relative 'composite'
|
3
4
|
|
4
|
-
#Require child classes
|
5
|
+
# Require child classes
|
5
6
|
require_relative 'element'
|
6
7
|
require_relative 'element_array'
|
7
8
|
require_relative 'element_hash'
|
@@ -10,16 +11,16 @@ require_relative 'hook'
|
|
10
11
|
module AutomationObject
|
11
12
|
module BluePrint
|
12
13
|
module HashAdapter
|
13
|
-
#Modal-level composite, ActiveRecord style composite implementation inheriting from Composite
|
14
|
+
# Modal-level composite, ActiveRecord style composite implementation inheriting from Composite
|
14
15
|
class Modal < Composite
|
15
|
-
#Relationships
|
16
|
+
# Relationships
|
16
17
|
has_one :load, interface: Hook
|
17
18
|
|
18
19
|
has_many :elements, interface: Element
|
19
20
|
has_many :element_arrays, interface: ElementArray
|
20
21
|
has_many :element_hashes, interface: ElementHash
|
21
22
|
|
22
|
-
#Validations
|
23
|
+
# Validations
|
23
24
|
validates_keys allowed_keys: [:load, :elements, :element_arrays, :element_hashes]
|
24
25
|
|
25
26
|
validates :load, instance_of: Hash
|
@@ -29,24 +30,24 @@ module AutomationObject
|
|
29
30
|
|
30
31
|
# @return [Array<Symbol>] array of views this can has
|
31
32
|
def included_views
|
32
|
-
included_views_array =
|
33
|
-
included_views_array.map
|
33
|
+
included_views_array = hash[:included_views] ||= []
|
34
|
+
included_views_array.map(&:to_sym)
|
34
35
|
end
|
35
36
|
|
36
|
-
#Method to take views and merge into this composite
|
37
|
+
# Method to take views and merge into this composite
|
37
38
|
def merge_views
|
38
|
-
top_hash =
|
39
|
+
top_hash = top.hash
|
39
40
|
|
40
41
|
return unless top_hash.is_a?(Hash)
|
41
42
|
return unless top_hash[:views].is_a?(Hash)
|
42
43
|
top_view_hash = top_hash[:views]
|
43
44
|
|
44
|
-
|
45
|
+
included_views.each do |included_view|
|
45
46
|
next unless top_view_hash[included_view].is_a?(Hash)
|
46
|
-
self.hash =
|
47
|
-
|
47
|
+
self.hash = hash.deep_merge(top_view_hash[included_view])
|
48
|
+
end
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
52
|
-
end
|
53
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Require parent class
|
2
3
|
require_relative 'composite'
|
3
4
|
|
4
|
-
#Require child classes
|
5
|
+
# Require child classes
|
5
6
|
require_relative 'automatic_onload_modal'
|
6
7
|
require_relative 'element'
|
7
8
|
require_relative 'element_array'
|
@@ -12,13 +13,13 @@ require_relative 'modal'
|
|
12
13
|
module AutomationObject
|
13
14
|
module BluePrint
|
14
15
|
module HashAdapter
|
15
|
-
#Screen-level composite, ActiveRecord style composite implementation inheriting from Composite
|
16
|
+
# Screen-level composite, ActiveRecord style composite implementation inheriting from Composite
|
16
17
|
class Screen < Composite
|
17
|
-
#Creation hooks
|
18
|
+
# Creation hooks
|
18
19
|
before_create :merge_views
|
19
20
|
before_create :automatic_onload_modals
|
20
21
|
|
21
|
-
#Relationships
|
22
|
+
# Relationships
|
22
23
|
has_one :load, interface: Hook
|
23
24
|
has_one :accept, interface: Hook
|
24
25
|
has_one :dismiss, interface: Hook
|
@@ -28,7 +29,7 @@ module AutomationObject
|
|
28
29
|
has_many :element_arrays, interface: ElementArray
|
29
30
|
has_many :element_hashes, interface: ElementHash
|
30
31
|
|
31
|
-
#Validations
|
32
|
+
# Validations
|
32
33
|
validates_keys allowed_keys: [:automatic_onload_modals, :automatic_screen_changes, :elements,
|
33
34
|
:element_arrays, :element_hashes, :included_views, :load, :modals]
|
34
35
|
|
@@ -49,41 +50,41 @@ module AutomationObject
|
|
49
50
|
|
50
51
|
# @return [Array<AutomaticOnloadModal>] array of AutomaticOnloadModal that are defined under the screen
|
51
52
|
def automatic_onload_modals
|
52
|
-
return @automatic_onload_modals if @automatic_onload_modals
|
53
|
+
return @automatic_onload_modals if defined? @automatic_onload_modals
|
53
54
|
|
54
|
-
children =
|
55
|
-
children =
|
56
|
-
@automatic_onload_modals =
|
57
|
-
|
58
|
-
|
55
|
+
children = hash[:automatic_onload_modals]
|
56
|
+
children = children.is_a?(Array) ? children : []
|
57
|
+
@automatic_onload_modals = create_array_children(:automatic_onload_modals, children,
|
58
|
+
interface: AutomaticOnloadModal,
|
59
|
+
location: location + '[automatic_onload_modals]')
|
59
60
|
|
60
|
-
|
61
|
+
@automatic_onload_modals
|
61
62
|
end
|
62
63
|
|
63
64
|
# @return [Array<Symbol>] array of screens where screen can automatically change to
|
64
65
|
def automatic_screen_changes
|
65
|
-
screen_array =
|
66
|
-
screen_array.map
|
66
|
+
screen_array = hash[:automatic_screen_changes] ||= []
|
67
|
+
screen_array.map(&:to_sym)
|
67
68
|
end
|
68
69
|
|
69
70
|
# @return [Array<Symbol>] array of views this can has
|
70
71
|
def included_views
|
71
|
-
included_views_array =
|
72
|
-
included_views_array.map
|
72
|
+
included_views_array = hash[:included_views] ||= []
|
73
|
+
included_views_array.map(&:to_sym)
|
73
74
|
end
|
74
75
|
|
75
|
-
#Method to take views and merge into this composite
|
76
|
+
# Method to take views and merge into this composite
|
76
77
|
def merge_views
|
77
|
-
top_hash =
|
78
|
+
top_hash = top.hash
|
78
79
|
|
79
80
|
return unless top_hash.is_a?(Hash)
|
80
81
|
return unless top_hash[:views].is_a?(Hash)
|
81
82
|
top_view_hash = top_hash[:views]
|
82
83
|
|
83
|
-
|
84
|
+
included_views.each do |included_view|
|
84
85
|
next unless top_view_hash[included_view].is_a?(Hash)
|
85
|
-
self.hash =
|
86
|
-
|
86
|
+
self.hash = hash.deep_merge(top_view_hash[included_view])
|
87
|
+
end
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|