Class: Pwl::Commands::Export

Inherits:
Base
  • Object
show all
Defined in:
lib/pwl/commands/export.rb

Constant Summary collapse

DEFAULT_EXPORT_TEMPLATE =
File.join(File.dirname(__FILE__), *%w[.. .. templates export.html.erb])

Instance Method Summary collapse

Methods inherited from Base

default_locker_file, exit_codes_help

Instance Method Details

#call(args, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pwl/commands/export.rb', line 6

def call(args, options)
  options.default :format => 'html'

  # TODO See Stats for slightly changed approach using a method
  presenter = {:html => Presenter::Html, :json => Presenter::Json, :yaml => Presenter::Yaml}[options.format.to_sym]
  exit_with(:unknown_export_format, options.verbose, :format => options.format) if presenter.nil?

  begin
    locker = open_locker(options)
    puts presenter.new(locker).to_s
  rescue Dialog::Cancelled
    exit_with(:aborted, options.verbose)
  end
end