Module: SeleniumDsl::Modules

Included in:
SeleniumDsl
Defined in:
lib/selenium_dsl/modules.rb

Instance Method Summary collapse

Instance Method Details

#in_modules?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/selenium_dsl/modules.rb', line 10

def in_modules?(cmd)
  modules.index(cmd) ? cmd : nil
end

#modulesObject



4
5
6
7
8
# File 'lib/selenium_dsl/modules.rb', line 4

def modules
  SeleniumDsl::Modules.private_instance_methods.collect do |x|
    "#{x[1,99]}"
  end
end

#parse_fnc(line) ⇒ Object

the regex @r_fnc will return with value in the first array, so it need to split for prm



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/selenium_dsl/modules.rb', line 27

def parse_fnc(line)
  arr = match_line(@r_fnc,line.strip,'mod')
  return false if arr[0]==[] #[/^ *\w+.*/] - :code=123 - [[], ":code=123"]
  cmd,prm = arr[0][0].split(/ +/,2)
  npath = "#{@path}/#{cmd}"
  if @code.keys.index("~/#{cmd}")
    puts "#{@path}>mod: #{arr.inspect}" if opt_v
    prm   = prm.to_s.split(',')
    @path = npath

    @code[@path] = @code["~/#{cmd}"] if !@code[@path]
    @code[@path][:line] = 0

    p = []
    parm = @code[@path][:parm] 
    if parm && parm!=[]
      parm.each_with_index do |v,i|
        var    = v.clone
        var[1] = prm[i] if prm[i]
        p << var
      end
    end
    vars = Hash[p]
    @code[@path][:vars] = vars
    puts ">>vars: #{vars}" if opt_v
    true
  else
    false
  end
end

#parse_mod(line) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/selenium_dsl/modules.rb', line 14

def parse_mod(line)
  arr = match_line(@r_mod,line.strip,'mod')
  cmd,prm = arr
  if (exc = in_modules?(cmd[0]))
    send("_#{exc}",prm) if !@mock
    true
  else
    false
  end
end