Module: RequireProfiler::Printer
- Defined in:
- lib/require_profiler/printer.rb,
lib/require_profiler/printer/json.rb,
lib/require_profiler/printer/text.rb,
lib/require_profiler/printer/call_stack.rb
Defined Under Namespace
Classes: Base, CallStack, JSON, Text
Class Method Summary collapse
Class Method Details
.resolve(output, format) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/require_profiler/printer.rb', line 34 def resolve(output, format) format ||= (output.is_a?(String) && File.extname(output) == ".json") ? :json : :text output = File.open(output, "w+") if output.is_a?(String) case format.to_sym when :json then JSON.new(output) when :call_stack then CallStack.new(output) when :text then Text.new(output) else raise ArgumentError, "Unknown format specified: #{format}. Available formats: text, json, call_stack" end end |