Sha256: 0b16a6c58e9efd9c8c834a63866033d854d1352858cbb20d9a322494ea0d8fd5

Contents?: true

Size: 1.54 KB

Versions: 15

Compression:

Stored size: 1.54 KB

Contents

module AnswersEngine
  class CLI < Thor
    class ScraperExport < Thor
      package_name "scraper export"
      def self.banner(command, namespace = nil, subcommand = false)
        "#{basename} #{@package_name} #{command.usage}"
      end

      desc "show <export_id>", "Show a scraper's export"
      def show(export_id)
        client = Client::ScraperExport.new(options)
        puts "#{client.find(export_id)}"
      end


      desc "list", "Gets a list of exports"
      long_desc <<-LONGDESC
        List exports.
      LONGDESC
      option :scraper_name, :aliases => :s, type: :string, desc: 'Filter by a specific scraper_name'
      option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
      option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
      def list()
        if options[:scraper_name]
          client = Client::ScraperExport.new(options)
          puts "#{client.all(options[:scraper_name])}"
        else
          client = Client::Export.new(options)
          puts "#{client.all}"
        end
      end

      desc "download <export_id>", "Download the exported file"
      def download(export_id)
        client = Client::ScraperExport.new(options)
        result = JSON.parse(client.download(export_id).to_s)
        
        if result['signed_url']
          puts "Download url: \"#{result['signed_url']}\""
          `open "#{result['signed_url']}"`
        else
          puts "Exported file does not exist"
        end        
      end



    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
answersengine-0.10.1 lib/answersengine/cli/scraper_export.rb
answersengine-0.10.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.9.1 lib/answersengine/cli/scraper_export.rb
answersengine-0.9.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.8.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.7.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.6.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.5.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.4.1 lib/answersengine/cli/scraper_export.rb
answersengine-0.4.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.3.3 lib/answersengine/cli/scraper_export.rb
answersengine-0.3.2 lib/answersengine/cli/scraper_export.rb
answersengine-0.3.1 lib/answersengine/cli/scraper_export.rb
answersengine-0.3.0 lib/answersengine/cli/scraper_export.rb
answersengine-0.2.33 lib/answersengine/cli/scraper_export.rb