Sha256: 84f8be165222b834d192153dc4d7dac52828d9d43212e18f411d07b03635584e

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

require 'fog'

module SimpleDeploy
  class AWS
    class SimpleDB

      def initialize
        c = SimpleDeploy.config
        @connect = Fog::AWS::SimpleDB.new :aws_access_key_id     => c.access_key,
                                          :aws_secret_access_key => c.secret_key,
                                          :region                => c.region
      end

      def domains
        @connect.list_domains.body['Domains']
      end

      def domain_exists?(domain)
        domains.include? domain
      end

      def create_domain(domain)
        @connect.create_domain(domain) unless domain_exists?(domain)
      end

      def put_attributes(domain, key, attributes, options)
        @connect.put_attributes domain, key, attributes, options
      end

      def select(query)
        options = { 'ConsistentRead' => true }
        data = {}
        next_token = nil
        
        while true
          options.merge! 'NextToken' => next_token
          chunk = @connect.select(query, options).body
          data.merge! chunk['Items']
          next_token = chunk['NextToken']
          break unless next_token
        end

        data
      end

      def delete(domain, key)
        @connect.delete_attributes domain, key
      end

      def delete_items(domain, key, attributes)
        @connect.delete_attributes domain, key, attributes
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
simple_deploy-0.9.2 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.9.1 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.9.0 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.8.2 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.8.2.beta1 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.8.1.beta1 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.8.0 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.8 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.7 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.7.beta.1 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.6 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.6.beta.6 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.6.beta.5 lib/simple_deploy/aws/simpledb.rb
simple_deploy-0.7.6.beta.3 lib/simple_deploy/aws/simpledb.rb