Class: RequireProfiler::Printer::Base

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

Direct Known Subclasses

CallStack, Text

Instance Method Summary collapse

Constructor Details

#initialize(output, threshold: 0.0, focus: nil) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/require_profiler/printer.rb', line 9

def initialize(output, threshold: 0.0, focus: nil)
  @output = output
  @threshold = threshold
  @focus = focus

  # Identify prefixes for the project and the gems
  prefixes = [::Dir.pwd]
  prefixes << ::Gem.dir if defined?(::Gem.dir)
  prefixes << ::Bundler.bundle_path if defined?(::Bundler.bundle_path)

  @prefix_stripper = %r{^(#{prefixes.join("|")})/}
end

Instance Method Details

#finishObject



26
27
28
# File 'lib/require_profiler/printer.rb', line 26

def finish
  output.close if output.respond_to?(:close) && output != $stdout
end

#flush(node) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/require_profiler/printer.rb', line 22

def flush(node)
  raise NotImplementedError
end