Sha256: 1057b30d648e5dc5be00886e5159e3fe78b7c0d356549d7bf12d135b9ac5a5a4

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'

ROOT = File.join(File.dirname(__FILE__), '..')

$LOAD_PATH << File.join(ROOT, 'lib')
require 'awsum/ec2'
require 'awsum/s3'

#Dumps the raw result of a call to the Awsum library
# Usage ruby dump.rb -a <access key> -s <secret key> -c <command to call>
#
# Awsum::Ec2 is available as ec2
# Awsum::S3 is available as s3
#
# Exampe
# ruby dump.rb -a ABC -s XYZ -c "ec2.images"

#Parse command line
access_key = nil
secret_key = nil
command = nil
ARGV.each_with_index do |arg, i|
  case arg
    when '-a'
      access_key = ARGV[i+1]
    when '-s'
      secret_key = ARGV[i+1]
    when '-c'
      command = ARGV[i+1]
  end
end

ENV['DEBUG'] = 'true'

ec2 = Awsum::Ec2.new(access_key, secret_key)
s3 = Awsum::S3.new(access_key, secret_key)


module Awsum
  module Requestable
    alias_method :old_handle_response, :handle_response
    def handle_response(response, &block)
      puts "block given" if block_given?
      puts response.body
      old_handle_response(response, &block)
    end
  end
end

begin
  eval(command)
rescue Awsum::Error => e
  puts "ERROR: #{e.inspect}"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
awsum-0.5.4 tools/dump.rb
awsum-0.5.3 tools/dump.rb
awsum-0.5.2 tools/dump.rb
awsum-0.5.1 tools/dump.rb