Class: BinderCore::Debug::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/binder_core/debug/stack.rb

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



7
8
9
10
# File 'lib/binder_core/debug/stack.rb', line 7

def initialize
  @entry_hash = {}
  @route = []
end

Instance Attribute Details

#routeObject

Returns the value of attribute route.



5
6
7
# File 'lib/binder_core/debug/stack.rb', line 5

def route
  @route
end

Instance Method Details

#add_file(route, file) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/binder_core/debug/stack.rb', line 21

def add_file(route,file)
  entry = create_entry route, file.file.path, file
  @entry_hash[route.join("~")] ||= []
  @entry_hash[route.join("~")].insert 1, entry
  self.route = route
  entry
end

#add_folder(route, folder) ⇒ Object

FIXME: it will not properly register the root file context and parser



14
15
16
17
18
19
# File 'lib/binder_core/debug/stack.rb', line 14

def add_folder(route,folder)
  entry = create_entry route, folder.file.path, folder
  @entry_hash[route.join("~")] = [entry]
  self.route = route
  entry
end

#add_parser(route, parser) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/binder_core/debug/stack.rb', line 29

def add_parser(route,parser)
  entry = create_entry route, parser.file.path, parser
  @entry_hash[route.join("~")] ||= []
  @entry_hash[route.join("~")].insert 2, entry
  self.route = route
  entry
end

#traceObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/binder_core/debug/stack.rb', line 37

def trace
  output = []
  tmp = []
  route.each do |step|
    tmp << step
    ky = tmp.join("~").to_s
    output.concat @entry_hash[ky]
  end
  output.reverse
end