mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
allow passing a request into bin/fog to return json
This commit is contained in:
parent
f77fdc9a7e
commit
1761fc53f8
3 changed files with 31 additions and 17 deletions
40
bin/fog
40
bin/fog
|
@ -16,22 +16,28 @@ require File.join(lib_dir, 'fog', 'rackspace', 'bin')
|
||||||
require File.join(lib_dir, 'fog', 'slicehost', 'bin')
|
require File.join(lib_dir, 'fog', 'slicehost', 'bin')
|
||||||
require File.join(lib_dir, 'fog', 'terremark', 'bin')
|
require File.join(lib_dir, 'fog', 'terremark', 'bin')
|
||||||
|
|
||||||
ARGV.clear # Avoid passing args to IRB
|
if ARGV.length > 1
|
||||||
IRB.setup(nil)
|
p instance_eval(ARGV[1..-1].join(' ')).to_json
|
||||||
@irb = IRB::Irb.new(nil)
|
|
||||||
IRB.conf[:MAIN_CONTEXT] = @irb.context
|
|
||||||
IRB.conf[:PROMPT][:FOG] = IRB.conf[:PROMPT][:SIMPLE].dup
|
|
||||||
IRB.conf[:PROMPT][:FOG][:RETURN] = "%s\n"
|
|
||||||
@irb.context.prompt_mode = :FOG
|
|
||||||
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
|
||||||
|
|
||||||
services = Fog.services.map{|service| service.to_s}
|
|
||||||
available_services = if services.length > 1
|
|
||||||
services[0...-1].join(', ') << ' and ' << services[-1]
|
|
||||||
else
|
else
|
||||||
services.first
|
|
||||||
end
|
|
||||||
print "Welcome to fog interactive!\n"
|
|
||||||
print "Your '#{Fog.credential.to_s}' configuration provides access to #{available_services}.\n"
|
|
||||||
|
|
||||||
catch(:IRB_EXIT) { @irb.eval_input }
|
ARGV.clear # Avoid passing args to IRB
|
||||||
|
IRB.setup(nil)
|
||||||
|
@irb = IRB::Irb.new(nil)
|
||||||
|
IRB.conf[:MAIN_CONTEXT] = @irb.context
|
||||||
|
IRB.conf[:PROMPT][:FOG] = IRB.conf[:PROMPT][:SIMPLE].dup
|
||||||
|
IRB.conf[:PROMPT][:FOG][:RETURN] = "%s\n"
|
||||||
|
@irb.context.prompt_mode = :FOG
|
||||||
|
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
||||||
|
|
||||||
|
services = Fog.services.map{|service| service.to_s}
|
||||||
|
available_services = if services.length > 1
|
||||||
|
services[0...-1].join(', ') << ' and ' << services[-1]
|
||||||
|
else
|
||||||
|
services.first
|
||||||
|
end
|
||||||
|
print "Welcome to fog interactive!\n"
|
||||||
|
print "Your '#{Fog.credential.to_s}' configuration provides access to #{available_services}.\n"
|
||||||
|
|
||||||
|
catch(:IRB_EXIT) { @irb.eval_input }
|
||||||
|
|
||||||
|
end
|
|
@ -145,6 +145,10 @@ module Fog
|
||||||
Formatador.display_table(self.map {|instance| instance.attributes}, attributes)
|
Formatador.display_table(self.map {|instance| instance.attributes}, attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_json
|
||||||
|
self.map {|member| member}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def lazy_load
|
def lazy_load
|
||||||
|
|
|
@ -102,6 +102,10 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_json
|
||||||
|
attributes.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def wait_for(timeout = 600, &block)
|
def wait_for(timeout = 600, &block)
|
||||||
start = Time.now
|
start = Time.now
|
||||||
until instance_eval(&block)
|
until instance_eval(&block)
|
||||||
|
|
Loading…
Add table
Reference in a new issue