Sha256: 7042a7d64730c1fb4275f73bd9a7d4cba7b9474d0a91b98c08f6cbb54ac8251a

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

class Quandl::Command::Tasks::Superset < Quandl::Command::Task
  
  autoload_quandl_client
  authenticated_users_only!
  
  description "Superset a script to be run in the quandl cloud."
  syntax %{quandl superset command [file]

  COMMANDS:
    
    superset new
    superset list
    superset upload [file]
    superset download [code]
    superset delete [code] }

  def execute
    # fire a subcommand if specified
    return self.send(args.shift) if args.first.present? && self.respond_to?(args.first)
    # otherwise default to upload
    upload
  end

  def new
    info Quandl::Client::Superset.example.to_qdf
  end

  def list
    Quandl::Client::Superset.owner('myself').each_in_page do |superset|
      present(superset)
    end
  end
  
  def upload
    Quandl::Format::Superset.foreach( file_or_stdin ) do |superset|
      # execute in parallel
      background_job do
        # upload the superset
        superset.save if superset.respond_to?(:valid?) && superset.valid?
        # present the result
        present(superset)
      end
    end
  end
  
  def download
    each_line_in_background( args_or_stdin ) do |code|
      # find superset
      dataset = Quandl::Client::Superset.find( code )
      # present
      present dataset, output_format: :qdf
    end
  end
  
  def delete
    each_line_in_background( args_or_stdin ) do |code|
      # find
      dataset = Quandl::Client::Dataset.find( code )
      # destroy
      dataset.destroy
      # present
      present dataset
    end
  end
 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quandl-0.3.4 lib/quandl/command/tasks/superset.rb
quandl-0.3.3 lib/quandl/command/tasks/superset.rb