Class: Gauge::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/util.rb

Class Method Summary collapse

Class Method Details

.get_file_name(prefix = "", counter = 0) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/util.rb', line 19

def get_file_name(prefix = "", counter = 0)
  name = "step_implementation#{prefix}.rb"
  file_name = File.join(get_step_implementation_dir, name)
  return file_name unless File.file? file_name
  counter += 1
  get_file_name("_#{counter}", counter)
end

.get_param_name(params, index) ⇒ Object



9
10
11
12
13
# File 'lib/util.rb', line 9

def get_param_name(params, index)
  name = "arg_#{index}"
  return name unless params.include? name
  get_param_name(params, index + 1)
end

.get_step_implementation_dirObject



15
16
17
# File 'lib/util.rb', line 15

def get_step_implementation_dir
  return File.join(ENV["GAUGE_PROJECT_ROOT"].gsub(/\\/, "/"), "step_implementations")
end

.step_value(text) ⇒ Object



27
28
29
# File 'lib/util.rb', line 27

def step_value(text)
  text.gsub(/(<.*?>)/, "{}")
end

.unique_screenshot_fileObject



30
31
32
33
# File 'lib/util.rb', line 30

def unique_screenshot_file
  base_name = "screenshot-#{Process.pid}-#{(Time.now.to_f*10000).to_i}.png"
  File.join(ENV['gauge_screenshots_dir'],base_name)
end