Sha256: 9315334a4c56aeddbbcc9b4627281f750ee4f395e3d47b68bad907293c3dc57f

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

# WARNING: Running this file will access /tmp/ernie.pid, /tmp/ernie.log and /tmp/fog-bertrpc-handler.
# Make sure you are not using any of these paths.
require 'rubygems'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'fog/external/storage'
require 'fog/external/backend/bertrpc'

Dir.chdir File.join(File.dirname(__FILE__), '..')

ROOT = '/tmp/fog-bertrpc-handler'
Dir.mkdir(ROOT) unless File.exists?(ROOT)

def run(cmd)
  puts "=> #{cmd}"
  system cmd
end

puts "Starting ernie on localhost:8000"
run "ernie -d -c examples/ernie.conf -P /tmp/ernie.pid -a /tmp/ernie.log"

puts "Ernie running."

begin

storage = Fog::Storage.new({
  :provider   => 'External',
  :delegate   => Fog::External::Backend::Bertrpc.new('localhost', 8000)
})

puts "Known directories: "
puts storage.directories.all.inspect

print "Creating directory mydir/ ..."
dir = storage.directories.new(key: 'mydir')
puts dir.save

puts "Known directories: "
puts storage.directories.all.inspect

print "Creating mydir/test.txt with content 'ohai' ..."
f = dir.files.new(key: 'test.txt')
f.body = 'ohai'
if f.save
  puts "done."
else
  puts "error."
end

print "Contents of mydir/test.txt: "
f = storage.directories.get('/').files.get('mydir/test.txt')
puts f.body

puts "Destroying mydir/test.txt"
f.destroy

puts "Destroying mydir/"
dir.destroy

puts "Known directories: "
puts storage.directories.all.inspect

ensure
  puts "Stopping ernie on localhost:8000"
  run "kill `cat /tmp/ernie.pid`"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-external-0.0.3 examples/example.rb
fog-external-0.0.2 examples/example.rb