s3cp 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,13 +1,24 @@
1
- === 0.2.1 / (Pending)
1
+ === 0.2.2 / (Pending)
2
+
3
+ === 0.2.1 / (2012-02-20)
4
+
5
+ * Added: Bash completion now supports exclusions through S3CP_EXCLUDES
6
+ and defaults to excluding keys containing "_$folder$".
7
+
8
+ * Changed: s3dir and s3ls --delimiter now display both directories and files
2
9
 
3
10
  === 0.2.0 / (2012-02-20)
4
11
 
5
12
  * Added: s3stat command to display S3 object properties
13
+
6
14
  * Added: s3dir as a shortcut for "s3ls --delimiter / ..."
7
15
  (default to character in S3CP_DELIMITER environment variable or "/" if not defined)
16
+
8
17
  * Added: s3cp defaults can now be set using environment variables
9
18
  S3CP_OVERWRITE, S3CP_CHECKSUM, S3CP_RETRIES, S3CP_RETRY_DELAY
19
+
10
20
  * Added: Support for Bash command-line completion of S3 URLs (see below).
21
+
11
22
  * Fixed: Skip checksum verification for S3 objects with invalid MD5's
12
23
  (details @ https://forums.aws.amazon.com/message.jspa?messageID=234538)
13
24
 
@@ -38,6 +38,8 @@ debug "url #{url}"
38
38
  delimiter = ENV["S3CP_DELIMITER"] || "/"
39
39
  debug "delimiter #{delimiter}"
40
40
 
41
+ excludes = (ENV["S3CP_EXCLUDES"] || "_$folder$").split(",")
42
+
41
43
  bucket, prefix = S3CP.bucket_and_key(url)
42
44
  if bucket == "s3"
43
45
  bucket = ""
@@ -56,6 +58,7 @@ debug "recursive #{recursive}"
56
58
  debug "dirs_only #{@dirs_only}"
57
59
 
58
60
  def print_keys(bucket, keys)
61
+ keys << keys[0] + " " if keys.size == 1 && @dirs_only
59
62
  keys.each do |key|
60
63
  if @legacy_format
61
64
  debug key
@@ -103,6 +106,10 @@ if (prefix && prefix.length > 0) || (url =~ /s3\:\/\/[^\/]+\//) || (url =~ /\:$/
103
106
  result = []
104
107
  end
105
108
 
109
+ excludes.each do |exclude|
110
+ result.reject! { |key| key.match(Regexp.escape(exclude)) }
111
+ end
112
+
106
113
  debug "result1 #{result.inspect}"
107
114
 
108
115
  # there may be longer matches
@@ -133,6 +140,10 @@ if (prefix && prefix.length > 0) || (url =~ /s3\:\/\/[^\/]+\//) || (url =~ /\:$/
133
140
  debug "result2 #{result.inspect}"
134
141
  end
135
142
 
143
+ excludes.each do |exclude|
144
+ result.reject! { |key| key.match(Regexp.escape(exclude)) }
145
+ end
146
+
136
147
  debug "final #{result.inspect}"
137
148
 
138
149
  print_keys(bucket, result)
data/lib/s3cp/s3ls.rb CHANGED
@@ -78,14 +78,18 @@ s3_options["max-keys"] = options[:max_keys] if options[:max_keys] && !options[:d
78
78
  s3_options[:delimiter] = options[:delimiter] if options[:delimiter]
79
79
 
80
80
  @s3.interface.incrementally_list_bucket(@bucket, s3_options) do |page|
81
- entries = page[:contents]
81
+ entries = []
82
82
  if options[:delimiter]
83
- entries = page[:common_prefixes]
84
- entries << page[:contents][0][:key] if page[:contents].length > 0 && entries.length > 0
83
+ entries << { :key => page[:contents][0][:key] } if page[:contents].length > 0 && entries.length > 0
84
+ page[:common_prefixes].each do |entry|
85
+ entries << { :key => entry }
86
+ end
87
+ entries << { :key => nil }
85
88
  end
89
+ entries += page[:contents]
86
90
  entries.each do |entry|
87
- key = "s3://#{@bucket}/#{options[:delimiter] ? entry : entry[:key]}"
88
- if options[:long_format]
91
+ key = entry[:key] ? "s3://#{@bucket}/#{entry[:key]}" : "---"
92
+ if options[:long_format] && entry[:last_modified] && entry[:size]
89
93
  last_modified = DateTime.parse(entry[:last_modified])
90
94
  size = entry[:size]
91
95
  puts "#{last_modified.strftime(options[:date_format])} #{ "%12d" % size} #{key}"
data/lib/s3cp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module S3CP
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Boisvert