s3cp 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 1.1.2 / (2012-08-22)
2
+
3
+ * Added: All commands now execute an init script ($HOME/.s3cp by default,
4
+ or $S3CP_CONFIG if defined) allowing customization, such as
5
+ setting up the AWS.config parameters such as S3 endpoints, max retries,
6
+ credentials, etc.
7
+
8
+ See http://docs.amazonwebservices.com/AWSRubySDK/latest/AWS.html#config-class_method
9
+ for details.
10
+
1
11
  === 1.1.1 / (2012-08-22)
2
12
 
3
13
  * Fixed: Invalid break (SyntaxError) in s3ls.
data/README.md CHANGED
@@ -9,17 +9,6 @@ Make sure you have Rubygems installed on your system then run:
9
9
 
10
10
  # gem install s3cp
11
11
 
12
- ### Building ###
13
-
14
- If you want to hack on s3cp and build the gem yourself, you will need Bundler (http://gembundler.com/) installed. Here is a typical development setup:
15
-
16
- # git clone git@github.com:aboisvert/s3cp.git
17
- # cd s3cp
18
- (... hack on s3cp ...)
19
- # bundle install
20
- # bundle exec rake gem
21
- # gem install s3cp-*.gem
22
-
23
12
  ### Examples ###
24
13
 
25
14
  export AWS_ACCESS_KEY_ID=...
@@ -39,13 +28,15 @@ All commands support both `s3://bucket/path/to/file` and the legacy `bucket:path
39
28
 
40
29
  Commands are also TTY-aware; when run in an interactive shell, their behavior will change. For example, `s3cat` will launch your favorite `PAGER` or `less` (the default pager) whereas `s3ls` will display N items at a time, where N is the number of display lines on your terminal and pause between pages.
41
30
 
42
- ### Bash completion for S3 URLs ###
31
+ ### Security / Credentials ###
43
32
 
44
- To install Bash completion for S3 URLs, add the following to ~/.bashrc:
33
+ Starting with v1.1.0, S3CP uses the default credential provider from the aws-sdk which makes a best effort to locate your AWS credentials. It checks a variety of locations in the following order:
45
34
 
46
- for cmd in [ s3cat s3cp s3dir s3ls s3mod s3rm s3stat ]; do
47
- complete -C s3cp_complete $cmd
48
- done
35
+ * Static credentials from AWS.config (e.g. AWS.config.access_key_id, AWS.config.secret_access_key)
36
+
37
+ * The environment (e.g. ENV['AWS_ACCESS_KEY_ID'] or ENV['AMAZON_ACCESS_KEY_ID'])
38
+
39
+ * EC2 metadata service (checks for credentials provided by roles for instances).
49
40
 
50
41
  ### Usage ###
51
42
 
@@ -139,16 +130,36 @@ To install Bash completion for S3 URLs, add the following to ~/.bashrc:
139
130
  --verbose Verbose mode
140
131
  -h, --help Show this message
141
132
 
133
+ ### Bash completion for S3 URLs ###
134
+
135
+ To install Bash completion for S3 URLs, add the following to ~/.bashrc:
136
+
137
+ for cmd in [ s3cat s3cp s3dir s3ls s3mod s3rm s3stat ]; do
138
+ complete -C s3cp_complete $cmd
139
+ done
140
+
142
141
  ### Dependencies ###
143
142
 
144
- * highline `>=1.5.1` (console/terminal size guessing)
145
- * right_aws `=2.1.0` (underlying Amazon S3 API)
146
- * right_http_connection `=1.3.0` (required by `right_aws`)
143
+ * extensions '~> 0.6' (portability between Ruby 1.8.7/1.9.2)
144
+ * highline `>=1.5.1` (console/terminal size guessing)
145
+ * aws-sdk '~> 1.6.3' (underlying Amazon S3 API)
146
+ * progressbar '~> 0.10.0' (nice console progress output)
147
147
 
148
148
  ### Target platform ###
149
149
 
150
150
  * Ruby 1.8.7 / 1.9.2
151
151
 
152
+ ### Development ###
153
+
154
+ If you want to hack on s3cp and build the gem yourself, you will need Bundler (http://gembundler.com/) installed. Here is a typical development setup:
155
+
156
+ # git clone git@github.com:aboisvert/s3cp.git
157
+ # cd s3cp
158
+ # bundle install
159
+ (... hack on s3cp ...)
160
+ # bundle exec rake gem
161
+ # gem install s3cp-*.gem
162
+
152
163
  ### License ###
153
164
 
154
165
  S3CP is is licensed under the terms of the Apache Software License v2.0.
@@ -40,6 +40,8 @@ arg2 = ARGV[2]
40
40
 
41
41
  DEBUG = true
42
42
 
43
+ S3CP.load_config()
44
+
43
45
  @s3 = S3CP.connect()
44
46
 
45
47
  if DEBUG
@@ -34,6 +34,8 @@ op = OptionParser.new do |opts|
34
34
  end
35
35
  op.parse!(ARGV)
36
36
 
37
+ S3CP.load_config()
38
+
37
39
  s3 = S3CP.connect()
38
40
  s3.buckets.each do |bucket|
39
41
  puts bucket.name
data/lib/s3cp/s3cat.rb CHANGED
@@ -57,6 +57,8 @@ end
57
57
  @bucket, @prefix = S3CP.bucket_and_key(url)
58
58
  fail "Your URL looks funny, doesn't it?" unless @bucket
59
59
 
60
+ S3CP.load_config()
61
+
60
62
  @s3 = S3CP.connect().buckets[@bucket]
61
63
 
62
64
  if options[:tty]
data/lib/s3cp/s3cp.rb CHANGED
@@ -188,12 +188,7 @@ end
188
188
  @includes = options[:include_regex].map { |s| Regexp.new(s) }
189
189
  @excludes = options[:exclude_regex].map { |s| Regexp.new(s) }
190
190
 
191
- def match(path)
192
- matching = true
193
- return false if @includes.any? && !@includes.any? { |regex| regex.match(path) }
194
- return false if @excludes.any? && @excludes.any? { |regex| regex.match(path) }
195
- true
196
- end
191
+ S3CP.load_config()
197
192
 
198
193
  @s3 = S3CP.connect()
199
194
 
@@ -209,6 +204,13 @@ def direction(from, to)
209
204
  end
210
205
  end
211
206
 
207
+ def match(path)
208
+ matching = true
209
+ return false if @includes.any? && !@includes.any? { |regex| regex.match(path) }
210
+ return false if @excludes.any? && @excludes.any? { |regex| regex.match(path) }
211
+ true
212
+ end
213
+
212
214
  def no_slash(path)
213
215
  path = path.match(/\/$/) ? path[0..-2] : path
214
216
  path.match(/^\//) ? path[1..-1] : path
data/lib/s3cp/s3du.rb CHANGED
@@ -63,6 +63,8 @@ url = ARGV[0]
63
63
  @bucket, @prefix = S3CP.bucket_and_key(url)
64
64
  fail "Your URL looks funny, doesn't it?" unless @bucket
65
65
 
66
+ S3CP.load_config()
67
+
66
68
  @s3 = S3CP.connect()
67
69
 
68
70
  def depth(path)
data/lib/s3cp/s3ls.rb CHANGED
@@ -86,6 +86,8 @@ if options[:verbose]
86
86
  puts "key #{@key}"
87
87
  end
88
88
 
89
+ S3CP.load_config()
90
+
89
91
  @s3 = S3CP.connect().buckets[@bucket]
90
92
 
91
93
  keys = 0
data/lib/s3cp/s3mod.rb CHANGED
@@ -50,6 +50,8 @@ end
50
50
  source = ARGV[0]
51
51
  permission = S3CP.validate_acl(ARGV.last)
52
52
 
53
+ S3CP.load_config()
54
+
53
55
  @s3 = S3CP.connect()
54
56
  bucket,key = S3CP.bucket_and_key(source)
55
57
  update_permissions(@s3, bucket, key, permission)
data/lib/s3cp/s3rm.rb CHANGED
@@ -98,6 +98,8 @@ end
98
98
  include_regex = options[:include_regex] ? Regexp.new(options[:include_regex]) : nil
99
99
  exclude_regex = options[:exclude_regex] ? Regexp.new(options[:exclude_regex]) : nil
100
100
 
101
+ S3CP.load_config()
102
+
101
103
  @s3 = S3CP.connect()
102
104
 
103
105
  if options[:recursive]
data/lib/s3cp/s3stat.rb CHANGED
@@ -37,6 +37,10 @@ source = ARGV[0]
37
37
  permission = ARGV.last
38
38
 
39
39
  @bucket, @key = S3CP.bucket_and_key(source)
40
+ fail "Your URL looks funny, doesn't it?" unless @bucket
41
+
42
+ S3CP.load_config()
43
+
40
44
  @s3 = S3CP.connect().buckets[@bucket]
41
45
 
42
46
  metadata = @s3.objects[@key].head
data/lib/s3cp/s3up.rb CHANGED
@@ -61,6 +61,8 @@ url = ARGV[0]
61
61
  bucket, key = S3CP.bucket_and_key(url)
62
62
  fail "Your URL looks funny, doesn't it?" unless bucket
63
63
 
64
+ S3CP.load_config()
65
+
64
66
  @s3 = S3CP.connect()
65
67
 
66
68
  # copy all of STDIN to a temp file
data/lib/s3cp/utils.rb CHANGED
@@ -21,6 +21,7 @@ require 'aws/s3'
21
21
  require 'optparse'
22
22
  require 'date'
23
23
  require 'highline/import'
24
+ require 's3cp/version'
24
25
 
25
26
  module S3CP
26
27
  extend self
@@ -42,6 +43,15 @@ module S3CP
42
43
  ::AWS::S3.new()
43
44
  end
44
45
 
46
+ # Load user-defined configuration file (e.g. to initialize AWS.config object)
47
+ def load_config()
48
+ aws_config = File.join(ENV['HOME'], '.s3cp')
49
+ aws_config = ENV['S3CP_CONFIG'] if ENV['S3CP_CONFIG']
50
+ if File.exist?(aws_config)
51
+ load aws_config
52
+ end
53
+ end
54
+
45
55
  # Parse URL and return bucket and key.
46
56
  #
47
57
  # e.g. s3://bucket/path/to/key => ["bucket", "path/to/key"]
data/lib/s3cp/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  # the License.
17
17
 
18
18
  module S3CP
19
- VERSION = "1.1.1"
19
+ VERSION = "1.1.2"
20
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3cp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Boisvert
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-22 00:00:00 Z
18
+ date: 2012-08-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -116,6 +116,7 @@ description:
116
116
  email:
117
117
  - alex.boisvert@gmail.com
118
118
  executables:
119
+ - s3buckets
119
120
  - s3cat
120
121
  - s3cp
121
122
  - s3cp_complete