mongo-db-utils 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,6 +25,11 @@ And then execute:
25
25
 
26
26
  $ mongo-db-utils console
27
27
 
28
+
29
+ ## Limitatons
30
+
31
+ Only works on ruby 1.9.3 (to_yaml is throwing an error in earlier versions)
32
+
28
33
  ## Usage
29
34
  Once you launch the console it'll provide you with a set of options - pretty self explanatory.
30
35
  When it does backups it stores them in ````~/.mongo-db-utils/backups/````. The naming convention is ````${server}_${port}/${database_name}/${timestamp}/db````
@@ -2,17 +2,24 @@ require 'aws/s3'
2
2
 
3
3
  module MongoDbUtils
4
4
 
5
- class S3
5
+ class S3
6
6
 
7
- def self.put_file(file, name, bucket_name, access_key_id, secret_access_key)
8
- puts "putting file to Amazon S3"
9
- AWS::S3::Base.establish_connection!(
10
- :access_key_id => access_key_id,
11
- :secret_access_key => secret_access_key
12
- )
7
+ def self.put_file(file, name, bucket_name, access_key_id, secret_access_key)
8
+ puts "putting file to Amazon S3"
9
+ AWS::S3::Base.establish_connection!(
10
+ :access_key_id => access_key_id,
11
+ :secret_access_key => secret_access_key
12
+ )
13
13
 
14
- AWS::S3::Service.buckets.create(bucket_name) if AWS::S3::Service.buckets.find(bucket_name).nil?
15
- AWS::S3::S3Object.store(name, open(file), bucket_name)
14
+ begin
15
+ AWS::S3::Bucket.find(bucket_name)
16
+ rescue AWS::S3::NoSuchBucket
17
+ AWS::S3::Bucket.create(bucket_name)
18
+ rescue AWS::S3::AllAccessDisabled
19
+ puts "Error:: You cannot access this bucket: #{bucket_name}"
20
+ return
16
21
  end
22
+ AWS::S3::S3Object.store(name, open(file), bucket_name)
17
23
  end
24
+ end
18
25
  end
@@ -1,4 +1,4 @@
1
1
  module MongoDbUtils
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  READY_FOR_USE = "(Alpha version - not for production use!!)"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo-db-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: