Class: ResponseMate::Commands::Export

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

Overview

Command which performs the operations required by `response_mate list`

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ Export


3
4
5
6
7
8
9
# File 'lib/response_mate/commands/export.rb', line 3

def initialize(args, options)
  super(args, options)
  @type = args.first || 'requests'

  @options[:environment] = ResponseMate::Environment.new(options[:environment])
  @options[:manifest] = ResponseMate::Manifest.new(options[:requests_manifest])
end

Instance Method Details

#runObject

Run the command based on args, options provided


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/response_mate/commands/export.rb', line 12

def run
  output = ResponseMate::Exporter.new(options).export
  if options[:upload]
    url = Faraday.post 'http://getpostman.com/collections' do |req|
      req.body = output.to_json
    end
    puts JSON.parse(url.body)['link']
  else
    puts JSON.pretty_generate(output)
  end
end