cliaws 1.1.2 → 1.2.0

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/History.txt CHANGED
@@ -1,7 +1,10 @@
1
- == 1.1.2 2008-04-30
1
+ == 1.2.0 2008-05-30
2
2
 
3
- * New clisqs info.
4
- * New internal method for fetching multiple messages in one swoop in Cliaws::Sqs.
3
+ * clis3 url returns the authenticated URL to an s3 object
4
+ * clisqs info subcommand
5
+ * Cliaws::Sqs#fetch returns a number of messages in one call
6
+ * clis3 put handles multiple arguments (put A B C bucket/dir)
7
+ * clis3 handles unknown bucket names gracefully
5
8
 
6
9
  == 1.1.1 2008-04-17
7
10
 
data/bin/clis3 CHANGED
@@ -10,36 +10,56 @@ rescue LoadError
10
10
  end
11
11
 
12
12
  require "main"
13
+
14
+ $:.unshift File.dirname(__FILE__) + "/../lib"
13
15
  require "cliaws"
14
16
 
15
17
  Main {
16
- argument("s3_object") do
17
- required
18
- argument_required
18
+ mixin :s3_object do
19
+ argument("s3_object") do
20
+ required
21
+ argument_required
22
+ end
19
23
  end
20
24
 
21
25
  mode("url") do
26
+ mixin :s3_object
27
+
22
28
  def run
23
29
  puts Cliaws.s3.url(params["s3_object"].value)
30
+
31
+ rescue Cliaws::S3::UnknownBucket
32
+ abort "Could not find bucket named #{$!.bucket_name}"
24
33
  end
25
34
  end
26
35
 
27
36
  mode("list") do
37
+ mixin :s3_object
38
+
28
39
  def run
29
40
  puts Cliaws.s3.list(params["s3_object"].value)
41
+
42
+ rescue Cliaws::S3::UnknownBucket
43
+ abort "Could not find bucket named #{$!.bucket_name}"
30
44
  end
31
45
  end
32
46
 
33
47
  mode("touch") do
48
+ mixin :s3_object
49
+
34
50
  def run
35
51
  Cliaws.s3.put("", params["s3_object"].value)
52
+
53
+ rescue Cliaws::S3::UnknownBucket
54
+ abort "Could not find bucket named #{$!.bucket_name}"
36
55
  end
37
56
  end
38
57
 
39
58
  mode("put") do
40
- argument("local_file") do
59
+ argument("local_files") do
41
60
  optional
42
61
  argument_required
62
+ arity -2
43
63
  end
44
64
 
45
65
  option("data") do
@@ -48,34 +68,61 @@ Main {
48
68
  end
49
69
 
50
70
  def run
51
- if params["local_file"].given? && params["data"].given? then
52
- abort "Cannot give both the --data and local_file parameters at the same time"
53
- elsif !params["local_file"].given? && !params["data"].given? then
71
+ if params["local_files"].given? && params["data"].given? then
72
+ abort "Cannot give both the --data and local_files parameters at the same time"
73
+ elsif !params["local_files"].given? && !params["data"].given? then
54
74
  source = STDIN
55
- elsif params["local_file"].given? then
56
- source = File.open(params["local_file"].value, "rb")
75
+ elsif params["local_files"].given? && params["local_files"].values.length == 2 then
76
+ source = File.open(params["local_files"].values.shift, "rb")
77
+ elsif params["local_files"].given? then
78
+ s3_object = params["local_files"].values.pop
79
+ targets = params["local_files"].values.map {|filename| filename.to_s}
80
+ targets.each do |local_file|
81
+ File.open(local_file, "rb") do |source|
82
+ remote_file = File.join(s3_object, File.basename(local_file))
83
+ puts "%-30s => %s" % [local_file, remote_file]
84
+ Cliaws.s3.put(source, remote_file)
85
+ end
86
+ end
87
+
88
+ exit 0
57
89
  else
58
90
  source = params["data"].value
59
91
  end
60
92
 
61
- Cliaws.s3.put(source, params["s3_object"].value)
93
+ Cliaws.s3.put(source, params["local_files"].values.pop)
94
+
95
+ rescue Cliaws::S3::UnknownBucket
96
+ abort "Could not find bucket named #{$!.bucket_name}"
62
97
  end
63
98
  end
64
99
 
65
100
  mode("rm") do
101
+ mixin :s3_object
102
+
66
103
  def run
67
104
  Cliaws.s3.rm(params["s3_object"].value)
105
+
106
+ rescue Cliaws::S3::UnknownBucket
107
+ abort "Could not find bucket named #{$!.bucket_name}"
68
108
  end
69
109
  end
70
110
 
71
111
  mode("cat") do
112
+ mixin :s3_object
113
+
72
114
  def run
73
115
  Cliaws.s3.get(params["s3_object"].value, STDOUT)
74
116
  puts
117
+
118
+ rescue Cliaws::S3::UnknownBucket
119
+ abort "Could not find bucket named #{$!.bucket_name}"
75
120
  end
76
121
  end
77
122
 
78
123
  mode("get") do
124
+ mixin :s3_object
125
+
79
126
  argument("local_file") do
80
127
  argument_required
81
128
  optional
@@ -89,12 +136,20 @@ Main {
89
136
  end
90
137
 
91
138
  Cliaws.s3.get(params["s3_object"].value, dest)
139
+
140
+ rescue Cliaws::S3::UnknownBucket
141
+ abort "Could not find bucket named #{$!.bucket_name}"
92
142
  end
93
143
  end
94
144
 
95
145
  mode("head") do
146
+ mixin :s3_object
147
+
96
148
  def run
97
149
  Cliaws.s3.head(params["s3_object"].value)
150
+
151
+ rescue Cliaws::S3::UnknownBucket
152
+ abort "Could not find bucket named #{$!.bucket_name}"
98
153
  end
99
154
  end
100
155
 
data/lib/cliaws/s3.rb CHANGED
@@ -53,6 +53,7 @@ module Cliaws
53
53
  def bucket_and_key_name(full_name)
54
54
  bucket_name, path = full_name.split("/", 2)
55
55
  bucket = s3.bucket(bucket_name, false)
56
+ raise UnknownBucket.new(bucket_name) unless bucket
56
57
  [bucket, path]
57
58
  end
58
59
 
@@ -63,5 +64,14 @@ module Cliaws
63
64
  def s3g
64
65
  @s3i ||= RightAws::S3Generator.new(access_key_id, secret_access_key, :logger => Logger.new("/dev/null"))
65
66
  end
67
+
68
+ class UnknownBucket < ArgumentError
69
+ attr_reader :bucket_name
70
+
71
+ def initialize(bucket_name)
72
+ super("Bucket #{bucket_name.inspect} could not be found")
73
+ @bucket_name = bucket_name
74
+ end
75
+ end
66
76
  end
67
77
  end
@@ -1,8 +1,8 @@
1
1
  module Cliaws #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 1
5
- TINY = 2
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,36 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cliaws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Beausoleil"
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMREwDwYDVQQDDAhmcmFu
14
- Y29pczEWMBQGCgmSJomT8ixkARkWBnRla3NvbDEUMBIGCgmSJomT8ixkARkWBGlu
15
- Zm8wHhcNMDcxMDExMDM1MzE3WhcNMDgxMDEwMDM1MzE3WjBBMREwDwYDVQQDDAhm
16
- cmFuY29pczEWMBQGCgmSJomT8ixkARkWBnRla3NvbDEUMBIGCgmSJomT8ixkARkW
17
- BGluZm8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2BxCY5a+ER1ep
18
- eO1UOeiW6L5fFOF618YL125/KQStsro+YbVkLFwOkNSvboAdVxNMauWw839s4Jma
19
- LU8pW+hx56J6YPFjp9af7Clli3oAGa0QaZWN8fA8iALWoFn2WTPQ6uVvKeva5qzF
20
- iiMiDVc+hiaQQpIRV6SEJPxrd8a2esYUX5CkPs27PRa/i9MuwRbHgp4MQPTm2PiU
21
- F+U9UafOXeRka3OWdD3CbzKbRwjorO0iZuLbe5hapvY2TC8I/3GWPFg5D5BaYE0p
22
- nQSsKmr0PvcUQOr0GnX9Na7llUBedef06htxTIXpbIpl2K9MNiEJrK6L7sVsez8l
23
- nEwp/m4DAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
24
- BBSUERBKzt5bhCREUh67iY3HT12I5TANBgkqhkiG9w0BAQUFAAOCAQEAJh3YJh+d
25
- ufqAV9sMWCSmiL0ZylZSE4qlRRCjxwPd1izYFM5lfUr43LkkR8Xrs69iyxg+wC7J
26
- Hvz4s027X71NZ4kVeGpZn7QN50ChgxENPYztQrHrgP1yjMi0yx2yktMZEgHp3MXZ
27
- xojT8ss6fSF44S04flHOCw4Se83rXTut56DgBXmGz3RXNKlVgi3petxlAijP8fR9
28
- 9AermHuLVXQxKdq2rDQZn87UhyXoqrK66NW98P5yCVR0aAw965aBSQQuZPLPzZJN
29
- 5j4veg4yDT2dMtIAb5+9YOKcpxFiO4Uckn9UKXGpOJ4LONp45thttZCP2gFgZpan
30
- DdYn10CtfIKBFg==
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- date: 2008-04-30 00:00:00 -04:00
12
+ date: 2008-05-30 00:00:00 -04:00
34
13
  default_executable:
35
14
  dependencies:
36
15
  - !ruby/object:Gem::Dependency
@@ -128,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
107
  requirements: []
129
108
 
130
109
  rubyforge_project: cliaws
131
- rubygems_version: 1.1.0
110
+ rubygems_version: 1.1.1
132
111
  signing_key:
133
112
  specification_version: 2
134
113
  summary: A command-line suite of tools to access Amazon Web Services, using the RightAws gems.
data.tar.gz.sig DELETED
@@ -1,4 +0,0 @@
1
- h��ܕ�
2
- �mgKVػ�V�3�8��a����$�����&*3s~Ok�
3
- ��K�#%����{t/Vqٷ, ���j rr��%���@4��D� /��UH1����BvU���d�PM!U�6>�����נ��53�'{NH^�U1�%�ʐ�� DO{�Q�ˊ}E l���
4
- 7|%�~k��b�����a{KG�!���Mu{�'�u��P|��/R{&M���PK٨���]�8 ��N�Rc�
metadata.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- ���]��r!FWt�*N�DN۶�a�j(�ݓ�tUk�匷�qrsﳳ�Y�>�_Z&�}��`
2
- O}3n�eǃ�6Qr�VZ��D���y?��yc����8��E