first pass at an interactive console

This commit is contained in:
Wesley Beary 2009-10-01 23:22:47 -07:00
parent 757eeabaa9
commit b7b346c0bd
2 changed files with 27 additions and 3 deletions

24
bin/fog Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require 'irb'
require 'yaml'
if File.exists?(File.expand_path('~/.fog'))
@credentials = YAML.load(File.open(File.expand_path('~/.fog')).read)
end
@s3 = Fog::AWS::S3.new(
:aws_access_key_id => @credentials['aws_access_key_id'],
:aws_secret_access_key => @credentials['aws_secret_access_key']
)
def buckets
@s3.buckets
end
ARGV.clear # Avoid passing args to IRB
IRB.setup(nil)
@irb = IRB::Irb.new(nil)
IRB.conf[:MAIN_CONTEXT] = @irb.context
@irb.context.workspace = IRB::WorkSpace.new(binding)
catch(:IRB_EXIT) { @irb.eval_input }

View File

@ -29,10 +29,10 @@ module Fog
data << " #{attribute}=#{send(attribute).inspect}"
end
data << " ["
for key, value in self
data << "#{value.inspect},"
for member in self
data << "#{member.inspect},"
end
data.chomp!
data.chop!
data << "]>"
end