lib/rorvswild/section.rb in rorvswild-1.5.1 vs lib/rorvswild/section.rb in rorvswild-1.5.2

- old
+ new

@@ -4,33 +4,34 @@ attr_accessor :kind, :file, :line, :calls, :command, :children_runtime, :total_runtime, :appendable_command def self.start(&block) section = Section.new block.call(section) if block_given? - stack.push(section) + stack && stack.push(section) section end def self.stop(&block) - section = stack.pop + return unless stack && section = stack.pop block.call(section) if block_given? section.total_runtime = RorVsWild.clock_milliseconds - section.started_at current.children_runtime += section.total_runtime if current RorVsWild.agent.add_section(section) end def self.stack - RorVsWild.agent.data[:section_stack] ||= [] + (data = RorVsWild.agent.current_data) && data[:section_stack] end def self.current - stack.last + (sections = stack) && sections.last end def initialize @calls = 1 @total_runtime = 0 @children_runtime = 0 + @kind = "code".freeze @started_at = RorVsWild.clock_milliseconds location = RorVsWild.agent.locator.find_most_relevant_location(caller_locations) @file = RorVsWild.agent.locator.relative_path(location.path) @line = location.lineno @appendable_command = false