lib/gondola/converters/html_converter.rb
# Function: ruby
# This function parses the selenium
# HTML file and sends commands to the
# html_to_ruby helper function
ruby
This function parses the selenium
HTML file and sends commands to the
html_to_ruby helper function
ruby This function parses the selenium HTML file and sends commands to the html_to_ruby helper function
def ruby
      unless @ruby
        @ruby = ""
        cmd_body = @body.match(/<tbody>(.*)<\/tbody>/m)[1]
        block_rxp = Regexp.new(/<tr>(.*?)<\/tr>/m)
        cmd_rxp = Regexp.new(/<td>(.*?)<\/td>\s*<td>(.*?)<\/td>\s*<td>(.*?)<\/td>/m)
        cmd_body.scan(block_rxp) do |cmd_block|
          cmd_block[0].scan(cmd_rxp) do |cmd|
            if cmd[1] =~ /\$\{(.*)\}/
              cmd[1] = $1
            elsif cmd[1] != ""
              cmd[1] = cmd[1].inspect
            end
            if cmd[2] =~ /\$\{(.*)\}/
              cmd[2] = $1
            elsif cmd[2] != ""
              cmd[2] = cmd[2].inspect
            end
            args = [ cmd[1], cmd[2] ]
            selenese = "#{cmd[0]}(#{cmd[1]}"
            selenese = selenese + ", #{cmd[2]}" if cmd[2] != ""
            selenese = selenese + ")"
            ruby = html_to_ruby(cmd[0], args)
            @commands.push({ :selenese => selenese, :ruby => ruby })
            @ruby << ruby + "\n"
          end
        end         
      end  
      @ruby
    end
def ruby unless @ruby @ruby = "" cmd_body = @body . match ( / <tbody>(.*)< \/ tbody> /m ) [ 1 ] block_rxp = Regexp . new ( / <tr>(.*?)< \/ tr> /m ) cmd_rxp = Regexp . new ( / <td>(.*?)< \/ td> \s *<td>(.*?)< \/ td> \s *<td>(.*?)< \/ td> /m ) cmd_body . scan ( block_rxp ) do | cmd_block | cmd_block [ 0 ] . scan ( cmd_rxp ) do | cmd | if cmd [ 1 ] =~ / \$ \{ (.*) \} / cmd [ 1 ] = $1 elsif cmd [ 1 ] != "" cmd [ 1 ] = cmd [ 1 ] . inspect end if cmd [ 2 ] =~ / \$ \{ (.*) \} / cmd [ 2 ] = $1 elsif cmd [ 2 ] != "" cmd [ 2 ] = cmd [ 2 ] . inspect end args = [ cmd [ 1 ] , cmd [ 2 ] ] selenese = "#{cmd[0]}(#{cmd[1]}" selenese = selenese + ", #{cmd[2]}" if cmd [ 2 ] != "" selenese = selenese + ")" ruby = html_to_ruby ( cmd [ 0 ] , args ) @commands . push ( { :selenese => selenese , :ruby => ruby } ) @ruby << ruby + "\n" end end end @ruby end
Function: ruby
This function parses the selenium
HTML file and sends commands to the
html_to_ruby helper function
Function : ruby This function parses the selenium HTML file and sends commands to the html_to_ruby helper function
# Get body of commands from flattened html # Define some patterns for the individual commands # Loop over all commands # Need to make sure arguements are represented # correctly # Append commands to a result string and to # the internal list of commands