Sha256: ca87027c82bf6fc141ce573b0febf2c5ef58a733d46f6d95c8010e0cbbabf3b9

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

module Monsoon
  class Client

    def initialize(bucket = Monsoon.bucket, key = Monsoon.key, secret = Monsoon.secret, mongo_uri = Monsoon.mongo_uri)
      @bucket           = bucket
      @key              = key
      @secret           = secret
      @mongo_uri        = mongo_uri
    end

    # Run the Monsoon process to backup, save, and clean the work.
    #
    # Examples
    #
    #   Monsoon::Client.new.run
    #   # => True
    #
    # Returns True
    def run
      # Backup the MongoDB database to filesystem
      b = backup.run
      
      # Compress the contents of the backup
      c = compress(b).run
      
      # Sent to AWS
      store(c.filename).save

      # Remove the compressed file from the filesystem
      c.clean

      true
    end

    # Creates an instance of the Monsoon::Backup class
    #
    # Examples
    #
    #   Monsoon::Client.new.backup
    #   # => #<Monsoon::Backup>
    #
    # Returns an instance of the Monsoon::Client object
    def backup
      Backup.new(@mongo_uri)
    end

    # Creates an instnace of the Monsoon::Compress class
    #
    # backup  - The Monsoon::Backup instance the preceeded.
    #
    # Examples
    #
    #   Monsoon::Client.new.compress(#<Monsoon::Backup>)
    #   # => #<Monsoon::Compress>
    #
    # Returns an instance of the Monsoon::Compress object
    def compress(backup)
      Compress.new(backup)
    end
      
    # Creates an instance of the Monsoon::Store class
    #
    # filename  - The String filename of the compressed backup to push to S3.
    #
    # Examples
    #
    #   Monsoon::Client.new.store("test.tar.gz")
    #   # => #<Monsoon::Store>
    #
    # Returns an instance of the Monsoon::Store object
    def store(filename)
      Store.new(filename, @bucket, @key, @secret)
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
monsoon-0.6.1 lib/monsoon/client.rb
monsoon-0.6 lib/monsoon/client.rb
monsoon-0.5 lib/monsoon/client.rb
monsoon-0.4 lib/monsoon/client.rb
monsoon-0.3 lib/monsoon/client.rb
monsoon-0.2 lib/monsoon/client.rb