s3utils 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -39,12 +39,12 @@ HTTPS_PROXY='https://user:password@my.proxy:443/'
39
39
  Commands available after install
40
40
  ----------------------------
41
41
 
42
- s3cmd createbucket name # creates a bucket
43
- s3cmd deletebucket name # deletes a bucket, if it is empty
44
- s3cmd deletekey bucket:key # deletes a key in the given bucket
45
- s3cmd get bucket:key file # get the file for the key from the bucket
46
- s3cmd get_timestamp bucket:key # get the last modified integer timestamp for the key from the bucket
47
- s3cmd help [TASK] # Describe available tasks or one specific task
48
- s3cmd list bucket:prefix # list the keys of a bucket
49
- s3cmd listbuckets # lists all of the buckets in your account
50
- s3cmd put bucket:key file # puts a file for the key in the bucket
42
+ s3cmd createbucket name # creates a bucket
43
+ s3cmd deletebucket name [--force] # deletes a bucket, if it is empty. --force will delete a non-empty bucket
44
+ s3cmd deletekey bucket:key # deletes a key in the given bucket
45
+ s3cmd get bucket:key file # get the file for the key from the bucket
46
+ s3cmd get_timestamp bucket:key # get the last modified integer timestamp for the key from the bucket
47
+ s3cmd help [TASK] # Describe available tasks or one specific task
48
+ s3cmd list bucket:prefix # list the keys of a bucket
49
+ s3cmd listbuckets # lists all of the buckets in your account
50
+ s3cmd put bucket:key file # puts a file for the key in the bucket
data/lib/s3utils.rb CHANGED
@@ -24,15 +24,25 @@ module S3Utils
24
24
  end
25
25
 
26
26
 
27
- desc "deletekey bucket:key", "deletes a key in the given bucket"
27
+ desc "deletekey bucket:key [--prefix]", "deletes a key in the given bucket. --prefix will delete all keys in the bucket with the prefix"
28
+ method_options :prefix => false
28
29
  def deletekey(bucket_key)
29
30
  with_error_handling do
30
31
  abort "Error: incorrect bucket:key format" unless bucket_key =~ /(.+):(.+)/
31
- s3.buckets[$1].objects[$2].delete
32
+ if options.prefix?
33
+ objects = s3.buckets[$1].objects.with_prefix($2)
34
+ objects.each do |o|
35
+ o.delete
36
+ end
37
+ else
38
+ s3.buckets[$1].objects[$2].delete
39
+ end
32
40
  end
33
41
  end
34
42
 
35
- desc "deletebucket name [--force] ", "deletes a bucket, if it is empty or recursively with --force"
43
+
44
+
45
+ desc "deletebucket name [--force] ", "deletes a bucket. --force will delete a non-empty bucket"
36
46
  method_options :force => false
37
47
  def deletebucket(name)
38
48
  with_error_handling do
@@ -47,7 +57,7 @@ module S3Utils
47
57
  end
48
58
 
49
59
 
50
- desc "list bucket:prefix", "list the keys of a bucket"
60
+ desc "list bucket[:prefix]", "list the keys of a bucket. prefix is optional argument"
51
61
  def list(bucket_prefix)
52
62
  with_error_handling do
53
63
  if bucket_prefix =~ /(.+):(.+)/
@@ -1,3 +1,3 @@
1
1
  module S3Utils
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3utils
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jasmeet Chhabra
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-21 00:00:00 Z
18
+ date: 2012-08-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: aws-sdk