Module: Gauge::StaticLoader Private
- Defined in:
- lib/static_loader.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .aliases?(node) ⇒ Boolean private
- .load_aliases(file, node) ⇒ Object private
- .load_files(dir) ⇒ Object private
- .load_step(file, step_value, step_text, block, options) ⇒ Object private
- .load_steps(file, ast) ⇒ Object private
- .process_node(file, node) ⇒ Object private
- .recoverable?(node) ⇒ Boolean private
- .reload_steps(file, ast) ⇒ Object private
- .remove_steps(file) ⇒ Object private
- .step_node?(node) ⇒ Boolean private
- .traverse(ast, &visitor) ⇒ Object private
Class Method Details
.aliases?(node) ⇒ 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.
60 61 62 |
# File 'lib/static_loader.rb', line 60 def self.aliases?(node) return node.children[0].children.size > 3 && node.children[0].children[3].type == :str end |
.load_aliases(file, node) ⇒ 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.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/static_loader.rb', line 64 def self.load_aliases(file, node) recoverable = false if recoverable? node aliases = node.children[0].children.slice(2, node.children[0].children.length() - 3) recoverable = true else aliases = node.children[0].children.slice(2, node.children[0].children.length() - 2) end Gauge::MethodCache.add_step_alias(*aliases.map {|x| x.children[0]}) aliases.each {|x| sv = Gauge::Util.step_value x.children[0] load_step(file, sv, x.children[0], node, {recoverable: recoverable}) } end |
.load_files(dir) ⇒ 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.
13 14 15 16 17 |
# File 'lib/static_loader.rb', line 13 def self.load_files(dir) Dir["#{dir}/**/*.rb"].each do |x| load_steps(x, CodeParser.code_to_ast(File.read(x))) end end |
.load_step(file, step_value, step_text, block, options) ⇒ 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.
85 86 87 88 89 |
# File 'lib/static_loader.rb', line 85 def self.load_step(file, step_value, step_text, block, ) si = {location: {file: file, span: block.loc}, step_text: step_text, block: block, recoverable: [:recoverable]} Gauge::MethodCache.add_step(step_value, si) end |
.load_steps(file, ast) ⇒ 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.
30 31 32 33 34 |
# File 'lib/static_loader.rb', line 30 def self.load_steps(file, ast) traverse ast do |node| process_node(file, node) end end |
.process_node(file, node) ⇒ 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 53 54 55 56 57 58 |
# File 'lib/static_loader.rb', line 50 def self.process_node(file, node) if aliases?(node) load_aliases(file, node) else step_text = node.children[0].children[2].children[0] step_value = Gauge::Util.step_value step_text load_step(file, step_value, step_text, node, {recoverable: recoverable?(node)}) end end |
.recoverable?(node) ⇒ 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.
79 80 81 82 83 |
# File 'lib/static_loader.rb', line 79 def self.recoverable?(node) size = node.children[0].children.length = node.children[0].children[size - 1] .type == :hash && .children[0].children[0].children[0] == :continue_on_failure end |
.reload_steps(file, ast) ⇒ 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.
36 37 38 39 40 |
# File 'lib/static_loader.rb', line 36 def self.reload_steps(file, ast) return unless ast remove_steps file load_steps(file, ast) 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.
42 43 44 |
# File 'lib/static_loader.rb', line 42 def self.remove_steps(file) Gauge::MethodCache.remove_steps file end |
.step_node?(node) ⇒ 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.
46 47 48 |
# File 'lib/static_loader.rb', line 46 def self.step_node?(node) node.type == :block && node.children[0].children[1] == :step end |
.traverse(ast, &visitor) ⇒ 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.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/static_loader.rb', line 19 def self.traverse(ast, &visitor) return if !ast || ast.class != Parser::AST::Node if step_node?(ast) visitor.call(ast) elsif ast.children ast.children.each {|node| traverse(node, &visitor) } end end |