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.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/lib/automation_object.rb +22 -11
  3. data/lib/automation_object/blue_print.rb +13 -12
  4. data/lib/automation_object/blue_print/composite/automatic_onload_modal.rb +9 -8
  5. data/lib/automation_object/blue_print/composite/base.rb +5 -4
  6. data/lib/automation_object/blue_print/composite/custom_method.rb +8 -7
  7. data/lib/automation_object/blue_print/composite/element.rb +6 -5
  8. data/lib/automation_object/blue_print/composite/element_array.rb +6 -5
  9. data/lib/automation_object/blue_print/composite/element_hash.rb +7 -6
  10. data/lib/automation_object/blue_print/composite/helpers/element_helper.rb +7 -7
  11. data/lib/automation_object/blue_print/composite/helpers/multiple_elements_helper.rb +5 -4
  12. data/lib/automation_object/blue_print/composite/hook.rb +9 -11
  13. data/lib/automation_object/blue_print/composite/hook_action.rb +25 -24
  14. data/lib/automation_object/blue_print/composite/hook_element_requirements.rb +14 -13
  15. data/lib/automation_object/blue_print/composite/modal.rb +11 -21
  16. data/lib/automation_object/blue_print/composite/screen.rb +22 -16
  17. data/lib/automation_object/blue_print/composite/top.rb +13 -12
  18. data/lib/automation_object/blue_print/composite/view.rb +27 -16
  19. data/lib/automation_object/blue_print/hash_adapter.rb +15 -11
  20. data/lib/automation_object/blue_print/hash_adapter/automatic_onload_modal.rb +12 -11
  21. data/lib/automation_object/blue_print/hash_adapter/composite.rb +28 -25
  22. data/lib/automation_object/blue_print/hash_adapter/custom_method.rb +11 -10
  23. data/lib/automation_object/blue_print/hash_adapter/element.rb +10 -9
  24. data/lib/automation_object/blue_print/hash_adapter/element_array.rb +10 -9
  25. data/lib/automation_object/blue_print/hash_adapter/element_hash.rb +11 -10
  26. data/lib/automation_object/blue_print/hash_adapter/helpers/element_helper.rb +20 -25
  27. data/lib/automation_object/blue_print/hash_adapter/helpers/multiple_elements_helper.rb +15 -14
  28. data/lib/automation_object/blue_print/hash_adapter/helpers/validation_error.rb +9 -8
  29. data/lib/automation_object/blue_print/hash_adapter/helpers/validation_helper.rb +19 -24
  30. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate.rb +8 -5
  31. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_allowed_keys.rb +7 -8
  32. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_element_presence_of.rb +28 -23
  33. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_instance_of.rb +12 -13
  34. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_modal_presence_of.rb +27 -23
  35. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_presence_of.rb +9 -8
  36. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_screen_presence_of.rb +27 -23
  37. data/lib/automation_object/blue_print/hash_adapter/helpers/validators/validate_view_presence_of.rb +25 -21
  38. data/lib/automation_object/blue_print/hash_adapter/hook.rb +14 -11
  39. data/lib/automation_object/blue_print/hash_adapter/hook_action.rb +45 -47
  40. data/lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb +24 -28
  41. data/lib/automation_object/blue_print/hash_adapter/modal.rb +14 -13
  42. data/lib/automation_object/blue_print/hash_adapter/screen.rb +23 -22
  43. data/lib/automation_object/blue_print/hash_adapter/top.rb +16 -15
  44. data/lib/automation_object/blue_print/hash_adapter/view.rb +58 -4
  45. data/lib/automation_object/blue_print/yaml_adapter.rb +33 -34
  46. data/lib/automation_object/driver.rb +15 -13
  47. data/lib/automation_object/driver/appium_adapter/driver.rb +47 -46
  48. data/lib/automation_object/driver/appium_adapter/element.rb +29 -96
  49. data/lib/automation_object/driver/base.rb +4 -2
  50. data/lib/automation_object/driver/common_selenium/driver.rb +60 -0
  51. data/lib/automation_object/driver/common_selenium/element.rb +107 -0
  52. data/lib/automation_object/driver/common_selenium/element_geometry.rb +86 -0
  53. data/lib/automation_object/driver/driver.rb +60 -30
  54. data/lib/automation_object/driver/element.rb +70 -15
  55. data/lib/automation_object/driver/nokogiri_adapter/driver.rb +88 -34
  56. data/lib/automation_object/driver/nokogiri_adapter/element.rb +94 -16
  57. data/lib/automation_object/driver/nokogiri_adapter/error.rb +29 -8
  58. data/lib/automation_object/driver/nokogiri_adapter/{backup/form.rb → form.rb} +19 -6
  59. data/lib/automation_object/driver/nokogiri_adapter/request.rb +17 -0
  60. data/lib/automation_object/driver/nokogiri_adapter/session.rb +94 -0
  61. data/lib/automation_object/driver/nokogiri_adapter/window.rb +86 -0
  62. data/lib/automation_object/driver/selenium_adapter/driver.rb +36 -45
  63. data/lib/automation_object/driver/selenium_adapter/element.rb +15 -85
  64. data/lib/automation_object/dsl.rb +11 -28
  65. data/lib/automation_object/dsl/_base.rb +70 -0
  66. data/lib/automation_object/dsl/_proxy.rb +24 -0
  67. data/lib/automation_object/dsl/element.rb +34 -0
  68. data/lib/automation_object/dsl/element_array.rb +34 -0
  69. data/lib/automation_object/dsl/element_hash.rb +34 -0
  70. data/lib/automation_object/dsl/modal.rb +43 -0
  71. data/lib/automation_object/dsl/screen.rb +45 -0
  72. data/lib/automation_object/dsl/top.rb +25 -0
  73. data/lib/automation_object/framework.rb +28 -38
  74. data/lib/automation_object/helpers/composite.rb +30 -27
  75. data/lib/automation_object/helpers/composite_hook.rb +16 -15
  76. data/lib/automation_object/{blue_print/helpers/file_helper.rb → helpers/file.rb} +12 -12
  77. data/lib/automation_object/helpers/hash.rb +6 -5
  78. data/lib/automation_object/helpers/kernel.rb +11 -0
  79. data/lib/automation_object/helpers/{reflection_helper.rb → reflection.rb} +9 -8
  80. data/lib/automation_object/helpers/string.rb +25 -15
  81. data/lib/automation_object/{proxies → proxy}/mutex_proxy.rb +18 -21
  82. data/lib/automation_object/proxy/proxy.rb +23 -0
  83. data/lib/automation_object/proxy/throttle_proxy.rb +52 -0
  84. data/lib/automation_object/state.rb +11 -29
  85. data/lib/automation_object/state/{blue_print_adapter/composite.rb → composite/_base.rb} +35 -25
  86. data/lib/automation_object/state/{blue_print_adapter/helpers/element_helper.rb → composite/_common_element.rb} +11 -11
  87. data/lib/automation_object/state/composite/element.rb +22 -0
  88. data/lib/automation_object/state/composite/element_array.rb +27 -0
  89. data/lib/automation_object/state/composite/element_hash.rb +33 -0
  90. data/lib/automation_object/state/composite/element_proxy.rb +33 -0
  91. data/lib/automation_object/state/composite/helpers/window.rb +61 -0
  92. data/lib/automation_object/state/composite/helpers/window_manager.rb +60 -0
  93. data/lib/automation_object/state/composite/hook.rb +56 -0
  94. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_action.rb +10 -8
  95. data/lib/automation_object/state/composite/hook_actions/action_loop.rb +36 -0
  96. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_screen.rb +7 -5
  97. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/change_to_previous_screen.rb +7 -5
  98. data/lib/automation_object/state/composite/hook_actions/close_modal.rb +29 -0
  99. data/lib/automation_object/state/composite/hook_actions/close_screen.rb +19 -0
  100. data/lib/automation_object/state/composite/hook_actions/element_requirement.rb +32 -0
  101. data/lib/automation_object/state/composite/hook_actions/new_screen.rb +35 -0
  102. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/possible_screen_changes.rb +8 -7
  103. data/lib/automation_object/state/composite/hook_actions/reset_screen.rb +14 -0
  104. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/show_modal.rb +7 -5
  105. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/sleep.rb +4 -2
  106. data/lib/automation_object/state/{blue_print_adapter → composite}/hook_actions/wait_for_elements.rb +7 -5
  107. data/lib/automation_object/state/composite/modal.rb +45 -0
  108. data/lib/automation_object/state/composite/screen.rb +58 -0
  109. data/lib/automation_object/state/composite/top.rb +51 -0
  110. data/lib/automation_object/state/error.rb +45 -6
  111. data/lib/automation_object/state/session.rb +25 -23
  112. data/lib/automation_object/step_definitions.rb +5 -3
  113. data/lib/automation_object/step_definitions/element.rb +77 -0
  114. data/lib/automation_object/step_definitions/element_array.rb +135 -0
  115. data/lib/automation_object/step_definitions/element_hash.rb +126 -0
  116. data/lib/automation_object/step_definitions/screen.rb +62 -0
  117. data/lib/automation_object/step_definitions/{cache.rb → support/cache.rb} +8 -6
  118. data/lib/automation_object/step_definitions/support/element_array.rb +40 -0
  119. data/lib/automation_object/step_definitions/support/element_hash.rb +41 -0
  120. data/lib/automation_object/step_definitions/{parse.rb → support/parse.rb} +8 -6
  121. data/lib/automation_object/version.rb +2 -1
  122. metadata +203 -103
  123. data/lib/automation_object/driver/helpers/selenium_driver_helper.rb +0 -41
  124. data/lib/automation_object/driver/helpers/selenium_element_helper.rb +0 -138
  125. data/lib/automation_object/driver/nokogiri_adapter/backup/driver.rb +0 -83
  126. data/lib/automation_object/driver/nokogiri_adapter/backup/element.rb +0 -66
  127. data/lib/automation_object/driver/nokogiri_adapter/backup/helpers/driver_element_helper.rb +0 -52
  128. data/lib/automation_object/driver/nokogiri_adapter/backup/session.rb +0 -115
  129. data/lib/automation_object/dsl/blue_print_adapter.rb +0 -16
  130. data/lib/automation_object/dsl/blue_print_adapter/composite.rb +0 -54
  131. data/lib/automation_object/dsl/blue_print_adapter/element.rb +0 -14
  132. data/lib/automation_object/dsl/blue_print_adapter/element_array.rb +0 -14
  133. data/lib/automation_object/dsl/blue_print_adapter/element_hash.rb +0 -14
  134. data/lib/automation_object/dsl/blue_print_adapter/modal.rb +0 -23
  135. data/lib/automation_object/dsl/blue_print_adapter/screen.rb +0 -26
  136. data/lib/automation_object/dsl/blue_print_adapter/top.rb +0 -19
  137. data/lib/automation_object/dsl/models.rb +0 -18
  138. data/lib/automation_object/dsl/proxies/element.rb +0 -16
  139. data/lib/automation_object/dsl/proxies/element_array.rb +0 -16
  140. data/lib/automation_object/dsl/proxies/element_hash.rb +0 -16
  141. data/lib/automation_object/dsl/proxies/helpers/composite_helper.rb +0 -74
  142. data/lib/automation_object/dsl/proxies/modal.rb +0 -17
  143. data/lib/automation_object/dsl/proxies/screen.rb +0 -17
  144. data/lib/automation_object/dsl/proxies/top.rb +0 -17
  145. data/lib/automation_object/proxies/proxy.rb +0 -20
  146. data/lib/automation_object/proxies/throttle_proxy.rb +0 -57
  147. data/lib/automation_object/state/blue_print_adapter.rb +0 -16
  148. data/lib/automation_object/state/blue_print_adapter/element.rb +0 -20
  149. data/lib/automation_object/state/blue_print_adapter/element_array.rb +0 -25
  150. data/lib/automation_object/state/blue_print_adapter/element_hash.rb +0 -31
  151. data/lib/automation_object/state/blue_print_adapter/element_proxy.rb +0 -28
  152. data/lib/automation_object/state/blue_print_adapter/helpers/screen_manager.rb +0 -137
  153. data/lib/automation_object/state/blue_print_adapter/helpers/window.rb +0 -39
  154. data/lib/automation_object/state/blue_print_adapter/hook.rb +0 -56
  155. data/lib/automation_object/state/blue_print_adapter/hook_actions/action_loop.rb +0 -35
  156. data/lib/automation_object/state/blue_print_adapter/hook_actions/close_modal.rb +0 -31
  157. data/lib/automation_object/state/blue_print_adapter/hook_actions/close_screen.rb +0 -19
  158. data/lib/automation_object/state/blue_print_adapter/hook_actions/element_requirement.rb +0 -34
  159. data/lib/automation_object/state/blue_print_adapter/hook_actions/new_screen.rb +0 -37
  160. data/lib/automation_object/state/blue_print_adapter/hook_actions/reset_screen.rb +0 -18
  161. data/lib/automation_object/state/blue_print_adapter/modal.rb +0 -26
  162. data/lib/automation_object/state/blue_print_adapter/screen.rb +0 -32
  163. data/lib/automation_object/state/blue_print_adapter/top.rb +0 -45
  164. data/lib/automation_object/step_definitions/action.rb +0 -21
  165. data/lib/automation_object/step_definitions/element/actions.rb +0 -87
  166. data/lib/automation_object/step_definitions/element/regex.rb +0 -24
  167. data/lib/automation_object/step_definitions/element/steps.rb +0 -67
@@ -1,16 +0,0 @@
1
- require_relative 'blue_print_adapter/top'
2
-
3
- module AutomationObject
4
- module Dsl
5
- #BluePrint adapter for building DSL framework
6
- #Follows similar pattern to BluePrint::HashAdapter composite
7
- module BluePrintAdapter
8
- # @param args [Hash] expects :blue_prints, :state
9
- # @return [AutomationObject::Dsl::Models::Top]
10
- def self.build(args={})
11
- blue_print_adapter = Top.new(blue_prints: args.fetch(:blue_prints))
12
- return blue_print_adapter.build
13
- end
14
- end
15
- end
16
- end
@@ -1,54 +0,0 @@
1
- module AutomationObject
2
- module Dsl
3
- module BluePrintAdapter
4
- #Base class for the DSL BluePrint adapter composite
5
- #BluePrintAdapter uses the BluePrint composite to create the proxy/model composite in the DSL
6
- class Composite
7
- class << self;
8
- attr_accessor :implemented_proxy
9
- end
10
-
11
- # @param args [Hash] arguments, expects :blue_prints
12
- def initialize(args={})
13
- @blue_prints = args.fetch :blue_prints
14
- end
15
-
16
- # Build and return the DSL composite
17
- # @return [Object] composite for the given level
18
- def build
19
- proxy = self.class.implemented_proxy.new
20
-
21
- self.class.has_many_relationships.each { |name, composite_class|
22
- @blue_prints.send(name).each { |child_key, child_blue_prints|
23
- child_composite = composite_class.new(blue_prints: child_blue_prints)
24
- child_proxy = child_composite.build
25
-
26
- type = name.to_s.gsub(/e?s$/, '').to_sym #Unpluralize
27
- proxy.add(name: child_key, type: type, object: child_proxy)
28
- }
29
- }
30
-
31
- return proxy
32
- end
33
-
34
- #Declare which proxy is being used by the given BluePrint::Adapter composite class
35
- # @param proxy_class [Class] proxy class used by the given composite
36
- def self.implements_proxy(proxy_class)
37
- self.implemented_proxy = proxy_class
38
- end
39
-
40
- #Has many children relationship for the composite
41
- # @param children_name [Symbol] name of the children, should be a BluePrint method
42
- # @param args [Hash] additional arguments, expects interface
43
- def self.has_many(children_name, args)
44
- self.has_many_relationships[children_name] = args.fetch(:interface)
45
- end
46
-
47
- # @return [Hash] relationships for the composite
48
- def self.has_many_relationships
49
- @has_many_relationships ||= Hash.new
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,14 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/element'
3
-
4
- module AutomationObject
5
- module Dsl
6
- module BluePrintAdapter
7
- #Element BluePrint adapter composite
8
- class Element < Composite
9
- #Which proxy to create for this composite
10
- implements_proxy AutomationObject::Dsl::Proxies::Element
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/element_array'
3
-
4
- module AutomationObject
5
- module Dsl
6
- module BluePrintAdapter
7
- #ElementArray BluePrint adapter composite
8
- class ElementArray < Composite
9
- #Which proxy to create for this composite
10
- implements_proxy AutomationObject::Dsl::Proxies::ElementArray
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/element_hash'
3
-
4
- module AutomationObject
5
- module Dsl
6
- module BluePrintAdapter
7
- #ElementHash BluePrint adapter composite
8
- class ElementHash < Composite
9
- #Which proxy to create for this composite
10
- implements_proxy AutomationObject::Dsl::Proxies::ElementHash
11
- end
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/modal'
3
-
4
- require_relative 'element'
5
- require_relative 'element_array'
6
- require_relative 'element_hash'
7
-
8
- module AutomationObject
9
- module Dsl
10
- module BluePrintAdapter
11
- #Modal BluePrint adapter composite
12
- class Modal < Composite
13
- #Which proxy to create for this composite
14
- implements_proxy AutomationObject::Dsl::Proxies::Modal
15
-
16
- #Children for this composite
17
- has_many :elements, interface: Element
18
- has_many :element_arrays, interface: ElementArray
19
- has_many :element_hashes, interface: ElementHash
20
- end
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/screen'
3
-
4
- require_relative 'modal'
5
- require_relative 'element'
6
- require_relative 'element_array'
7
- require_relative 'element_hash'
8
-
9
- module AutomationObject
10
- module Dsl
11
- module BluePrintAdapter
12
- #Screen BluePrint adapter composite
13
- class Screen < Composite
14
- #Which proxy to create for this composite
15
- implements_proxy AutomationObject::Dsl::Proxies::Screen
16
-
17
- #Children for this composite
18
- has_many :modals, interface: Modal
19
-
20
- has_many :elements, interface: Element
21
- has_many :element_arrays, interface: ElementArray
22
- has_many :element_hashes, interface: ElementHash
23
- end
24
- end
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- require_relative 'composite'
2
- require_relative '../proxies/top'
3
-
4
- require_relative 'screen'
5
-
6
- module AutomationObject
7
- module Dsl
8
- module BluePrintAdapter
9
- #Top BluePrint adapter composite
10
- class Top < Composite
11
- #Which proxy to create for this composite
12
- implements_proxy AutomationObject::Dsl::Proxies::Top
13
-
14
- #Children for this composite
15
- has_many :screens, interface: Screen
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- module AutomationObject
2
- module Dsl
3
- module Models
4
- class Top < OpenStruct;
5
- end
6
- class Screen < OpenStruct;
7
- end
8
- class Modal < OpenStruct;
9
- end
10
- class Element < OpenStruct;
11
- end
12
- class ElementHash < OpenStruct;
13
- end
14
- class ElementArray < OpenStruct;
15
- end
16
- end
17
- end
18
- end
@@ -1,16 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
-
3
- require_relative 'helpers/composite_helper'
4
-
5
- module AutomationObject::Dsl
6
- module Proxies
7
- #Element proxy for model
8
- class Element < AutomationObject::Proxies::Proxy
9
- include CompositeHelper
10
-
11
- def initialize
12
- @subject = nil
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
-
3
- require_relative 'helpers/composite_helper'
4
-
5
- module AutomationObject::Dsl
6
- module Proxies
7
- #ElementArray proxy for model
8
- class ElementArray < AutomationObject::Proxies::Proxy
9
- include CompositeHelper
10
-
11
- def initialize
12
- @subject = nil
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
-
3
- require_relative 'helpers/composite_helper'
4
-
5
- module AutomationObject::Dsl
6
- module Proxies
7
- #ElementHash proxy for model
8
- class ElementHash < AutomationObject::Proxies::Proxy
9
- include CompositeHelper
10
-
11
- def initialize
12
- @subject = nil
13
- end
14
- end
15
- end
16
- end
@@ -1,74 +0,0 @@
1
- module AutomationObject::Dsl
2
- module Proxies
3
- #CompositeHelper for DSL Proxies
4
- #Proxies will deal with the State and wrap around the models
5
- module CompositeHelper
6
- attr_accessor :state
7
-
8
- # @param state [AutomationObject::State::Session]
9
- def state=(state)
10
- @state = state
11
- self.children.each { |child|
12
- @subject[child].state = @state
13
- }
14
- end
15
-
16
- # @return [Array] hooks array or empty array
17
- def hooks
18
- @hooks ||= Array.new
19
- end
20
-
21
- # @return [Hash] composite hooks or empty hash
22
- def composite_hooks
23
- @composite_hooks ||= Hash.new
24
- end
25
-
26
- # @return [Array] children array or empty array
27
- def children
28
- @children ||= Array.new
29
- end
30
-
31
- # Use this to add children to the DSL composite
32
- # @param args [Hash] arguments for adding a child to this composite
33
- def add(args={})
34
- name = args.fetch :name
35
- @subject[name] = args.fetch :object
36
- self.children.push(name)
37
-
38
- type = args.fetch(:type)
39
-
40
- case type
41
- when :screen, :modal
42
- #Just load
43
- self.composite_hooks[name] = lambda { self.request_load(type, name) }
44
- when :element, :element_array, :element_hash
45
- #Set return to subject
46
- self.composite_hooks[name] = lambda { @subject[name] = self.request_load(type, name) }
47
- end
48
-
49
- @subject[name].hooks.push(self.composite_hooks[name]) if self.composite_hooks.has_key?(name)
50
- return @subject[name]
51
- end
52
-
53
- # Request the state to load an object
54
- # @param type [Symbol] type of object (:screen, :modal, :element, :etc...)
55
- # @param name [Symbol] name of the object
56
- def request_load(type, name)
57
- @state.load(type, name)
58
- end
59
-
60
- #Override to allow for hooks to be run when using the DSL API
61
- def method_missing(method_symbol, *args, &block)
62
- return super unless self.children.include?(method_symbol)
63
-
64
- self.hooks.each { |hook| hook.call }
65
-
66
- if self.composite_hooks.has_key?(method_symbol)
67
- self.composite_hooks[method_symbol].call
68
- end
69
-
70
- super
71
- end
72
- end
73
- end
74
- end
@@ -1,17 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
- require_relative '../models.rb'
3
-
4
- require_relative 'helpers/composite_helper'
5
-
6
- module AutomationObject::Dsl
7
- module Proxies
8
- #Modal proxy for model
9
- class Modal < AutomationObject::Proxies::Proxy
10
- include CompositeHelper
11
-
12
- def initialize
13
- @subject = Models::Modal.new
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
- require_relative '../models.rb'
3
-
4
- require_relative 'helpers/composite_helper'
5
-
6
- module AutomationObject::Dsl
7
- module Proxies
8
- #Screen proxy for model
9
- class Screen < AutomationObject::Proxies::Proxy
10
- include CompositeHelper
11
-
12
- def initialize
13
- @subject = Models::Screen.new
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require_relative '../../proxies/proxy'
2
- require_relative '../models'
3
-
4
- require_relative 'helpers/composite_helper'
5
-
6
- module AutomationObject::Dsl
7
- module Proxies
8
- #Top proxy for model
9
- class Top < AutomationObject::Proxies::Proxy
10
- include CompositeHelper
11
-
12
- def initialize
13
- @subject = Models::Top.new
14
- end
15
- end
16
- end
17
- end
@@ -1,20 +0,0 @@
1
- module AutomationObject
2
- module Proxies
3
- #Base Proxy class for getting between another
4
- class Proxy
5
- instance_methods.each { |instance_method|
6
- unless instance_method =~ /(^__|^send$|^object_id)/
7
- undef_method instance_method
8
- end
9
- }
10
-
11
- def initialize(subject)
12
- @subject = subject
13
- end
14
-
15
- def method_missing(method_symbol, *args, &block)
16
- return @subject.send(method_symbol, *args, &block)
17
- end
18
- end
19
- end
20
- end
@@ -1,57 +0,0 @@
1
- require_relative 'proxy'
2
-
3
- module AutomationObject
4
- module Proxies
5
- #Proxy class to throttle methods on the subject
6
- class ThrottleProxy < Proxy
7
- def initialize(subject)
8
- super
9
- end
10
-
11
- def throttle_methods
12
- @throttle_methods ||= Hash.new
13
- end
14
-
15
- def method_missing(method_symbol, *args, &block)
16
- start_time = Time.new.to_f
17
- execution_return = @subject.send(method_symbol, *args, &block)
18
- self.throttle_speed(method_symbol, start_time)
19
- return execution_return
20
- end
21
-
22
- def add_method_throttle(method_symbol, time)
23
- unless method_symbol.is_a?(Symbol)
24
- raise ArgumentError, 'Expecting method_symbol argument to be a Symbol'
25
- end
26
-
27
- unless time.is_a?(Numeric)
28
- raise ArgumentError, 'Expecting time argument to be Numeric'
29
- end
30
-
31
- unless @subject.respond_to?(method_symbol)
32
- raise ArgumentError, "Expecting object to respond_to? #{method_symbol}"
33
- end
34
-
35
- self.throttle_methods[method_symbol] = time
36
- end
37
-
38
- #Delete throttle that exists
39
- # @param method_symbol [Symbol] method symbol to remove throttle from
40
- def delete_method_throttle(method_symbol)
41
- self.throttle_methods.delete(method_symbol)
42
- end
43
-
44
- #Method to sleep the difference between actual and throttle time
45
- # @param method_symbol [Symbol] method that is to be throttled
46
- # @param start_time [Float] start time as float
47
- # @return [nil]
48
- def throttle_speed(method_symbol, start_time)
49
- return unless self.throttle_methods.has_key?(method_symbol)
50
- total_time_taken = Time.new.to_f - start_time
51
-
52
- sleep_time = self.throttle_methods[method_symbol] - total_time_taken
53
- sleep(sleep_time) if sleep_time > 0
54
- end
55
- end
56
- end
57
- end