Class: Gauge::MethodCache Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.add_step(step_value, step_info) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/method_cache.rb', line 28

def self.add_step(step_value, step_info)
  if @@steps_map.key? step_value
    @@steps_map[step_value][:locations].push(step_info[:location])
  else
    @@steps_map[step_value] = {
        locations: [step_info[:location]],
        block: step_info[:block],
        step_text: step_info[:step_text],
        recoverable: step_info[:recoverable]
    }
  end
end

.add_step_alias(*step_texts) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
# File 'lib/method_cache.rb', line 50

def self.add_step_alias(*step_texts)
  @@steps_with_aliases.push *step_texts if step_texts.length > 1
end

.all_stepsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
# File 'lib/method_cache.rb', line 62

def self.all_steps
  @@steps_map.values.map { |si| si[:step_text] }
end

.clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/method_cache.rb', line 24

def self.clear()
  @@steps_map.clear
end

.clear_hooks(hook) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/method_cache.rb', line 20

def self.clear_hooks(hook)
  class_variable_get("@@#{hook}_hooks").clear
end

.get_step_info(step_value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/method_cache.rb', line 41

def self.get_step_info(step_value)
  @@steps_map[step_value]
end

.get_step_text(step_value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/method_cache.rb', line 46

def self.get_step_text(step_value)
  @@steps_map[step_value][:step_text]
end

.has_alias?(step_text) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


54
55
56
# File 'lib/method_cache.rb', line 54

def self.has_alias?(step_text)
  @@steps_with_aliases.include? step_text
end

.is_file_cached(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



83
84
85
86
87
88
89
90
# File 'lib/method_cache.rb', line 83

def self.is_file_cached(file)
  @@steps_map.each_pair do |step, info|
    if info[:locations].any? { |loc| relative_filepath(loc[:file]).eql? relative_filepath(file) }
      return true
    end
  end
  return false
end

.multiple_implementation?(step_value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


92
93
94
# File 'lib/method_cache.rb', line 92

def self.multiple_implementation?(step_value)
  @@steps_map[step_value][:locations].length > 1
end

.recoverable?(step_value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


66
67
68
# File 'lib/method_cache.rb', line 66

def self.recoverable?(step_value)
  @@steps_map[step_value][:recoverable]
end

.relative_filepath(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



70
71
72
73
74
# File 'lib/method_cache.rb', line 70

def self.relative_filepath(file)
  project_root =  Pathname.new(ENV['GAUGE_PROJECT_ROOT'])
  filename = Pathname.new(file).relative_path_from(project_root)
  return project_root.join(filename.to_s.split(":").first)
end

.remove_steps(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
79
80
81
# File 'lib/method_cache.rb', line 76

def self.remove_steps(file)
  @@steps_map.each_pair do |step, info|
    l = info[:locations].reject { |loc| relative_filepath(loc[:file]).eql? relative_filepath(file) }
    l.empty? ? @@steps_map.delete(step) : @@steps_map[step][:locations] = l
  end
end

.step_positions(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/method_cache.rb', line 96

def self.step_positions(file)
  step_positions = []
  @@steps_map.each_pair do |step, info|
    info[:locations].each do |location|
      if location[:file] == file
        step_positions.push({stepValue: step, span: location[:span]})
      end
    end
  end
  step_positions
end

.valid_step?(step) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


58
59
60
# File 'lib/method_cache.rb', line 58

def self.valid_step?(step)
  @@steps_map.key? step
end