Sha256: 4cfbc28e66d4d38c348f9f2be1ce633c2669ebd0116c38d8896d847fe9361b19

Contents?: true

Size: 838 Bytes

Versions: 1

Compression:

Stored size: 838 Bytes

Contents

require "bertrpc"

module Fog
  module External
    module Backend
      
      class Bertrpc
        def initialize(host, port)
          @service = BERTRPC::Service.new(host, port)
          @module = @service.call.fog
        end
        
        METHODS = %w(create_directory list_directories get_directory destroy_directory list_files head_file get_file destroy_file save_file)
        
        METHODS.each do |m|
          define_method m do |*args|
            @module.send m, *args
          end
        end
      
        def get_file(key)
          res = @module.get_file(key)
          res[:body] = Base64.decode64(res[:body])
          res
        end
        
        def save_file(key, body)
          body = Base64.encode64(body)
          @module.save_file(key, body)
        end
      end
      
    end
  end
end
      

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-external-0.0.2 lib/fog/external/backend/bertrpc.rb