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.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/method_cache.rb', line 40

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.



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

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.



74
75
76
# File 'lib/method_cache.rb', line 74

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.



36
37
38
# File 'lib/method_cache.rb', line 36

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.



32
33
34
# File 'lib/method_cache.rb', line 32

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.



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

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.



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

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)


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

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.



95
96
97
98
99
100
101
102
# File 'lib/method_cache.rb', line 95

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)


104
105
106
# File 'lib/method_cache.rb', line 104

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)


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

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.



82
83
84
85
86
# File 'lib/method_cache.rb', line 82

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.



88
89
90
91
92
93
# File 'lib/method_cache.rb', line 88

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.



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/method_cache.rb', line 108

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)


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

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