Sha256: 168272e9194e988a58b74c940fe6ea3f9138779ce20f30e7958e35e0cfe27ffe
Contents?: true
Size: 1.4 KB
Versions: 5
Compression:
Stored size: 1.4 KB
Contents
begin require "aws/s3" rescue LoadError raise "You don't have the 'aws' gem installed." end module Monsoon class Store def initialize(filename, bucket, key, secret) @filename, @bucket, @key, @secret = filename, bucket, key, secret end # Runs the Monsoon Store save process. # # Examples # # Monsoon::Store("backup.tar.gz", "backups_bucket", "super_secret_key", "super_secret_secret").save # # => #<AWS::S3::S3Object> # # Returns an instance of the AWS::S3::S3Object class def save connect AWS::S3::S3Object.store(@filename, read_file_contents, @bucket) end # Parses the contents of the compressed backup. # # Examples # # Monsoon::Store("backup.tar.gz", "backups_bucket", "super_secret_key", "super_secret_secret").read_file_contents # # => #<AWS::S3::S3Object> # # Returns contents of the binary file. def read_file_contents file = File.open(@filename, "rb") file.read end # Connects to AWS. # # Examples # # Monsoon::Store("backup.tar.gz", "backups_bucket", "super_secret_key", "super_secret_secret").connect # # => #<AWS::S3::Connection> # # Returns an instance of the AWS::S3::Connection class. def connect AWS::S3::Base.establish_connection!( :access_key_id => @key, :secret_access_key => @secret ) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
monsoon-0.5 | lib/monsoon/store.rb |
monsoon-0.4 | lib/monsoon/store.rb |
monsoon-0.3 | lib/monsoon/store.rb |
monsoon-0.2 | lib/monsoon/store.rb |
monsoon-0.1 | lib/monsoon/store.rb |