Sha256: e68fb0e7b3b959a3648e8972ee9bd10e45879b57069f13ee605e26f40afb95f8

Contents?: true

Size: 897 Bytes

Versions: 7

Compression:

Stored size: 897 Bytes

Contents

module Quandl
module Command
class Task

module Presentation
  
  extend ActiveSupport::Concern
  
  def present(object, opts={})
    opts = opts.symbolize_keys!
    opts.reverse_merge!(options.to_h) if options.to_h.present?
    presenters = Quandl::Command::Presenter.new( object, opts )
    # format order of importance
    format = get_output_format( opts )
    # convert each object to_format and write to stdout
    presenters.each do |presenter|
      # write requested format to stdout
      info( presenter.to_format(format) )
      # write errors to stderr
      error( presenter.to_stderr ) unless presenter.valid?
    end
  end
  
  private
  
  def get_output_format(override={})
    format = options.output_format || config.output_format || override[:output_format] || 'pipes'
    format = 'pipes' unless %w{ pipes json qdf }.include?(format.to_s)
    format
  end
  
end

end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
quandl-0.4.4 lib/quandl/command/task/presentation.rb
quandl-0.4.3 lib/quandl/command/task/presentation.rb
quandl-0.4.2 lib/quandl/command/task/presentation.rb
quandl-0.4.1 lib/quandl/command/task/presentation.rb
quandl-0.4.0 lib/quandl/command/task/presentation.rb
quandl-0.3.7 lib/quandl/command/task/presentation.rb
quandl-0.3.6 lib/quandl/command/task/presentation.rb