class PageObjectStubs::ProcessPageObjects
Attributes
name_type_pairs[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/page_object_stubs/ast_processor.rb, line 6 def initialize @name_type_pairs = [] super end
Public Instance Methods
_print_children(children_array)
click to toggle source
# File lib/page_object_stubs/ast_processor.rb, line 21 def _print_children children_array # `def on_send` receives AST::Node send # the children array of that node is sent to _print_children # -> symbol :page_url # inside print children, the element type is found (page_url) # -> AST::Node str/symbol # once we know the type, we look for an AST::Node that contains the element name pair = [] find_element_name = false element_name = nil # symbol or string children_array.each do |child| if find_element_name && child.is_a?(AST::Node) first = child.children.first if first.class == Symbol || first.class == String element_name = first.to_s # puts "element_name: #{element_name}" pair << element_name break end end if is_valid child # puts "element_type: #{child}" pair << child.to_s # element_type find_element_name = true end unless find_element_name end @name_type_pairs << pair if pair.length == 2 end
generate_send(node)
click to toggle source
# File lib/page_object_stubs/ast_processor.rb, line 54 def generate_send node c = node.children return unless c _print_children c # node.type is send # the rest of the data is in the children. end
is_valid(child)
click to toggle source
# File lib/page_object_stubs/ast_processor.rb, line 16 def is_valid child # child may be a symbol or a string @@valid_elements.include?(child.to_s) end
on_def(node)
click to toggle source
# File lib/page_object_stubs/ast_processor.rb, line 63 def on_def node if node.is_a?(AST::Node) c = node.children return unless c method_name = c.first @name_type_pairs << [method_name] if method_name.class == Symbol end end
on_send(node)
click to toggle source
Calls superclass method
# File lib/page_object_stubs/ast_processor.rb, line 72 def on_send node generate_send node super end