ghazel-aws-s3 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,107 @@
1
+ head:
2
+
3
+ 0.6.3:
4
+
5
+ - Make bucket names globally unique [Jeffrey Hardy jeff@37signals.com]
6
+ - Add S3Object.update for updating things like the content-type without re-uploading the file [Jeffrey Hardy jeff@37signals.com]
7
+ 0.6.2:
8
+
9
+ - Use custom __method__ in Ruby versions *prior* to 1.8.7 not *up to* 1.8.7.
10
+
11
+ 0.6.1:
12
+
13
+ - Rename Kernel#memoize to Kernel#expirable_memoize so that it doesn't conflict with memoize method in ActiveSupport which has an entirely different API and semantics. Reported by [Florian Dütsc (mail@florian-duetsch.de)].
14
+
15
+ 0.6.0:
16
+
17
+ - Full 1.9 compatibility (all tests passing against 1.9 & 1.8.6). Thanks to [David (dvdplm@gmail.com), Cyril David (cyx.ucron@gmail.com)]
18
+
19
+ 0.5.1:
20
+
21
+ - For now just redefine __method__ to take arguments so we don't break 1.8.7 use today
22
+
23
+ 0.5.0:
24
+
25
+ - Bug #17458 fixed. Normalize the :expires_in option to always be an integer even if the actual object passed in is a proxy to an integer, such as is the case with 2.hours from ActiveSupport which is actually an instance of ActiveSupport::Duration. Reported by [Steve Kickert steve@riverocktech.com]
26
+
27
+ - Bug #19158 fixed. Don't prepend leading slash onto bucket name when deleting a bucket with the :force => true option.
28
+
29
+ - Bug #17628 fixed. Don't ignore :use_ssl => false in url_for when the connection is established over ssl. Reported by [Tom Fixed (tkat11)]
30
+
31
+ - Bug #13052 fixed. Appease some proxies by always including a Content-Length with all requests. Reported by [James Murty (jmurty)]
32
+
33
+ - Bug #13756 fixed. Attributes that are false should not raise NoMethodError in Base#method_missing. Fixed by [Scott Patten]
34
+
35
+ - Bug #19189 fixed. No longer reference Date::ABBR_MONTHS constant which was removed in Ruby 1.8.6. Reported by [Khurram Virani (kvirani)]
36
+
37
+ - Bug #20487 fixed. If a request fails and is retried, only escape the request path the first time. Reported by [anonymous]
38
+
39
+ - Replace ad-hoc S3Object.copy method with newly support built in API call.
40
+
41
+ - Do not make connections persistent by default. This "feature" causes far more broken pipes than it is worth. Use with caution.
42
+
43
+ 0.4.0:
44
+
45
+ - Various adjustments to connection handling to try to mitigate exceptions raised from deep within Net::HTTP.
46
+
47
+ - Don't coerce numbers that start with a zero because the zero will be lost. If a bucket, for example, has a name like '0815', all operation it will fail. Closes ticket #10089 [reported anonymously]"
48
+
49
+ - Add ability to connect through a proxy using the :proxy option when establishing a connection. Suggested by [Simon Horne <simon@soulware.co.uk>]
50
+
51
+ - Add :authenticated option to url_for. When passing false, don't generate signature parameters for query string.
52
+
53
+ - Make url_for accept custom port settings. [Rich Olson]
54
+
55
+ 0.3.0:
56
+
57
+ - Ensure content type is eventually set to account for changes made to Net::HTTP in Ruby version 1.8.5. Reported by [David Hanson, Stephen Caudill, Tom Mornini <tmornini@engineyard.com>]
58
+
59
+ - Add :persistent option to connections which keeps a persistent connection rather than creating a new one per request, defaulting to true. Based on a patch by [Metalhead <metalhead@metalhead.ws>]
60
+
61
+ - If we are retrying a request after rescuing one of the retry exceptions, rewind the body if its an IO stream so it starts at the beginning. [Jamis Buck]
62
+
63
+ - Ensure that all paths being submitted to S3 are valid utf8. If they are not, we remove the extended characters. Ample help from [Jamis Buck]
64
+
65
+ - Wrap logs in Log objects which exposes each line as a Log::Line that has accessors by name for each field.
66
+
67
+ - Various performance optimizations for the extensions code. [Roman LE NEGRATE <roman2k@free.fr>]
68
+
69
+ - Make S3Object.copy more efficient by streaming in both directions in parallel.
70
+
71
+ - Open up Net:HTTPGenericRequest to make the chunk size 1 megabyte, up from 1 kilobyte.
72
+
73
+ - Add S3Object.exists?
74
+
75
+ 0.2.1:
76
+
77
+ - When the bucket name argument (for e.g. Bucket.objects) is being used as the option hash, reassign it to the options variable and set the bucket to nil so bucket inference + options works.
78
+
79
+ - Don't call CGI.escape on query string parameters in Hash#to_query_string since all paths get passed through URI.escape right before the request is made. Paths were getting double escaped. Bug spotted by [David Hanson]
80
+
81
+ - Make s3sh exec irb.bat if on Windows. Bug spotted by [N. Sathish Kumar <nsathishk@yahoo.com>]
82
+
83
+ - Avoid class_variable_(get|set) since it was only recently added to Ruby. Spotted by [N. Sathish Kumar <nsathishk@yahoo.com>]
84
+
85
+ - Raise NoSuchKey if S3Object.about requests a key that does not exist.
86
+
87
+ - If the response body is an empty string, don't try to parse it as xml.
88
+
89
+ - Don't reject every body type save for IO and String at the door when making a request. Suggested by [Alex MacCaw <maccman@gmail.com>]
90
+
91
+ - Allow dots in bucket names. [Jesse Newland]
92
+
93
+ 0.2.0:
94
+
95
+ - Infer content type for an object when calling S3Object.store without explicitly passing in the :content_type option.
96
+
97
+ 0.1.2:
98
+
99
+ - Scrap (overly) fancy generator based version of CoercibleString with a much simpler and clearer case statement. Continuations are really slow and the specific use of the generator was leaking memory. Bug spotted by [Remco van't Veer]
100
+
101
+ 0.1.1:
102
+
103
+ - Don't add the underscore method to String if it is already defined (like, for example, from ActiveSupport). Bug spotted by [Matt White <stockliasteroid@gmail.com>]
104
+
105
+ 0.1.0:
106
+
107
+ - Initial public release
data/COPYING ADDED
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright (c) 2006-2009 Marcel Molina Jr. <marcel@vernix.org>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in the
6
+ # Software without restriction, including without limitation the rights to use,
7
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8
+ # Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/INSTALL ADDED
@@ -0,0 +1,55 @@
1
+ == Rubygems
2
+
3
+ The easiest way to install aws/s3 is with Rubygems:
4
+
5
+ % sudo gem i aws-s3 -ry
6
+
7
+ == Directly from svn
8
+
9
+ % svn co svn://rubyforge.org/var/svn/amazon/s3/trunk aws
10
+
11
+ == As a Rails plugin
12
+
13
+ If you want to use aws/s3 with a Rails application, you can export the repository
14
+ into your plugins directory and then check it in:
15
+
16
+ % cd my-rails-application/vendor/plugins
17
+ % svn export svn://rubyforge.org/var/svn/amazon/s3/trunk aws
18
+ % svn add aws
19
+
20
+ Or you could pull it down with an svn:externals:
21
+
22
+ % cd my-rails-application/vendor/plugins
23
+ % svn propedit svn:externals .
24
+
25
+ Then add the following line, save and exit:
26
+
27
+ aws svn://rubyforge.org/var/svn/amazon/s3/trunk
28
+
29
+ If you go the svn route, be sure that you have all the dependencies installed. The list of dependencies follow.
30
+
31
+ == Dependencies
32
+
33
+ AWS::S3 requires Ruby 1.8.4 or greater.
34
+
35
+ It also has the following dependencies:
36
+
37
+ sudo gem i xml-simple -ry
38
+ sudo gem i builder -ry
39
+ sudo gem i mime-types -ry
40
+
41
+ === XML parsing (xml-simple)
42
+
43
+ AWS::S3 depends on XmlSimple (http://xml-simple.rubyforge.org/). When installing aws/s3 with
44
+ Rubygems, this dependency will be taken care of for you. Otherwise, installation instructions are listed on the xml-simple
45
+ site.
46
+
47
+ If your system has the Ruby libxml bindings installed (http://libxml.rubyforge.org/) they will be used instead of REXML (which is what XmlSimple uses). For those concerned with speed and efficiency, it would behoove you to install libxml (instructions here: http://libxml.rubyforge.org/install.html) as it is considerably faster and less expensive than REXML.
48
+
49
+ === XML generation (builder)
50
+
51
+ AWS::S3 also depends on the Builder library (http://builder.rubyforge.org/ and http://rubyforge.org/projects/builder/). This will also automatically be installed for you when using Rubygems.
52
+
53
+ === Content type inference (mime-types)
54
+
55
+ AWS::S3 depends on the MIME::Types library (http://mime-types.rubyforge.org/) to infer the content type of an object that does not explicitly specify it. This library will automatically be installed for you when using Rubygems.
data/Rakefile ADDED
@@ -0,0 +1,344 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+
8
+ require File.dirname(__FILE__) + '/lib/aws/s3'
9
+
10
+ def library_root
11
+ File.dirname(__FILE__)
12
+ end
13
+
14
+ task :default => :test
15
+
16
+ Rake::TestTask.new do |test|
17
+ test.pattern = 'test/*_test.rb'
18
+ test.verbose = true
19
+ end
20
+
21
+ namespace :doc do
22
+ Rake::RDocTask.new do |rdoc|
23
+ rdoc.rdoc_dir = 'doc'
24
+ rdoc.title = "AWS::S3 -- Support for Amazon S3's REST api"
25
+ rdoc.options << '--line-numbers' << '--inline-source'
26
+ rdoc.rdoc_files.include('README')
27
+ rdoc.rdoc_files.include('COPYING')
28
+ rdoc.rdoc_files.include('INSTALL')
29
+ rdoc.rdoc_files.include('lib/**/*.rb')
30
+ end
31
+
32
+ task :rdoc => 'doc:readme'
33
+
34
+ task :refresh => :rerdoc do
35
+ system 'open doc/index.html'
36
+ end
37
+
38
+ task :readme do
39
+ require 'support/rdoc/code_info'
40
+ RDoc::CodeInfo.parse('lib/**/*.rb')
41
+
42
+ strip_comments = lambda {|comment| comment.gsub(/^# ?/, '')}
43
+ docs_for = lambda do |location|
44
+ info = RDoc::CodeInfo.for(location)
45
+ raise RuntimeError, "Couldn't find documentation for `#{location}'" unless info
46
+ strip_comments[info.comment]
47
+ end
48
+
49
+ open('README', 'w') do |file|
50
+ file.write ERB.new(IO.read('README.erb')).result(binding)
51
+ end
52
+ end
53
+
54
+ task :deploy => :rerdoc do
55
+ sh %(scp -r doc marcel@rubyforge.org:/var/www/gforge-projects/amazon/)
56
+ end
57
+ end
58
+
59
+ namespace :dist do
60
+ spec = Gem::Specification.new do |s|
61
+ s.name = 'aws-s3'
62
+ s.version = Gem::Version.new(AWS::S3::Version)
63
+ s.summary = "Client library for Amazon's Simple Storage Service's REST API"
64
+ s.description = s.summary
65
+ s.email = 'marcel@vernix.org'
66
+ s.author = 'Marcel Molina Jr.'
67
+ s.has_rdoc = true
68
+ s.extra_rdoc_files = %w(README COPYING INSTALL)
69
+ s.homepage = 'http://amazon.rubyforge.org'
70
+ s.rubyforge_project = 'amazon'
71
+ s.files = FileList['Rakefile', 'lib/**/*.rb', 'bin/*', 'support/**/*.rb']
72
+ s.executables << 's3sh'
73
+ s.test_files = Dir['test/**/*']
74
+
75
+ s.add_dependency 'xml-simple'
76
+ s.add_dependency 'builder'
77
+ s.add_dependency 'mime-types'
78
+ s.rdoc_options = ['--title', "AWS::S3 -- Support for Amazon S3's REST api",
79
+ '--main', 'README',
80
+ '--line-numbers', '--inline-source']
81
+ end
82
+
83
+ # Regenerate README before packaging
84
+ task :package => 'doc:readme'
85
+ Rake::GemPackageTask.new(spec) do |pkg|
86
+ pkg.need_tar_gz = true
87
+ pkg.package_files.include('{lib,script,test,support}/**/*')
88
+ pkg.package_files.include('README')
89
+ pkg.package_files.include('COPYING')
90
+ pkg.package_files.include('INSTALL')
91
+ pkg.package_files.include('Rakefile')
92
+ end
93
+
94
+ desc 'Install with gems'
95
+ task :install => :repackage do
96
+ sh "sudo gem i pkg/#{spec.name}-#{spec.version}.gem"
97
+ end
98
+
99
+ desc 'Uninstall gem'
100
+ task :uninstall do
101
+ sh "sudo gem uninstall #{spec.name} -x"
102
+ end
103
+
104
+ desc 'Reinstall gem'
105
+ task :reinstall => [:uninstall, :install]
106
+
107
+ task :confirm_release do
108
+ print "Releasing version #{spec.version}. Are you sure you want to proceed? [Yn] "
109
+ abort if STDIN.getc == ?n
110
+ end
111
+
112
+ desc 'Tag release'
113
+ task :tag do
114
+ sh %(git tag -a '#{spec.version}-release' -m 'Tagging #{spec.version} release')
115
+ sh 'git push --tags'
116
+ end
117
+
118
+ desc 'Update changelog to include a release marker'
119
+ task :add_release_marker_to_changelog do
120
+ changelog = IO.read('CHANGELOG')
121
+ changelog.sub!(/^head:/, "#{spec.version}:")
122
+
123
+ open('CHANGELOG', 'w') do |file|
124
+ file.write "head:\n\n#{changelog}"
125
+ end
126
+ end
127
+
128
+ task :commit_changelog do
129
+ sh %(git commit CHANGELOG -m "Bump changelog version marker for release")
130
+ sh 'git push'
131
+ end
132
+
133
+ package_name = lambda {|specification| File.join('pkg', "#{specification.name}-#{specification.version}")}
134
+
135
+ desc 'Push a release to rubyforge'
136
+ task :release => [:confirm_release, :clean, :add_release_marker_to_changelog, :package, :commit_changelog, :tag] do
137
+ require 'rubyforge'
138
+ package = package_name[spec]
139
+
140
+ rubyforge = RubyForge.new.configure
141
+ rubyforge.login
142
+
143
+ user_config = rubyforge.userconfig
144
+ user_config['release_changes'] = YAML.load_file('CHANGELOG')[spec.version.to_s].join("\n")
145
+
146
+ version_already_released = lambda do
147
+ releases = rubyforge.autoconfig['release_ids']
148
+ releases.has_key?(spec.name) && releases[spec.name][spec.version.to_s]
149
+ end
150
+
151
+ abort("Release #{spec.version} already exists!") if version_already_released.call
152
+
153
+ begin
154
+ rubyforge.add_release(spec.rubyforge_project, spec.name, spec.version.to_s, "#{package}.tar.gz", "#{package}.gem")
155
+ puts "Version #{spec.version} released!"
156
+ rescue Exception => exception
157
+ puts 'Release failed!'
158
+ raise
159
+ end
160
+ end
161
+
162
+ desc 'Upload a beta gem'
163
+ task :push_beta_gem => [:clobber_package, :package] do
164
+ beta_gem = package_name[spec]
165
+ sh %(scp #{beta_gem}.gem marcel@rubyforge.org:/var/www/gforge-projects/amazon/beta)
166
+ end
167
+
168
+ task :spec do
169
+ puts spec.to_ruby
170
+ end
171
+ end
172
+
173
+ desc 'Check code to test ratio'
174
+ task :stats do
175
+ library_files = FileList["#{library_root}/lib/**/*.rb"]
176
+ test_files = FileList["#{library_root}/test/**/*_test.rb"]
177
+ count_code_lines = Proc.new do |lines|
178
+ lines.inject(0) do |code_lines, line|
179
+ next code_lines if [/^\s*$/, /^\s*#/].any? {|non_code_line| non_code_line === line}
180
+ code_lines + 1
181
+ end
182
+ end
183
+
184
+ count_code_lines_for_files = Proc.new do |files|
185
+ files.inject(0) {|code_lines, file| code_lines + count_code_lines[IO.read(file)]}
186
+ end
187
+
188
+ library_code_lines = count_code_lines_for_files[library_files]
189
+ test_code_lines = count_code_lines_for_files[test_files]
190
+ ratio = Proc.new { sprintf('%.2f', test_code_lines.to_f / library_code_lines)}
191
+
192
+ puts "Code LOC: #{library_code_lines} Test LOC: #{test_code_lines} Code to Test Ratio: 1:#{ratio.call}"
193
+ end
194
+
195
+ namespace :test do
196
+ find_file = lambda do |name|
197
+ file_name = lambda {|path| File.join(path, "#{name}.rb")}
198
+ root = $:.detect do |path|
199
+ File.exist?(file_name[path])
200
+ end
201
+ file_name[root] if root
202
+ end
203
+
204
+ TEST_LOADER = find_file['rake/rake_test_loader']
205
+ multiruby = lambda do |glob|
206
+ system 'multiruby', TEST_LOADER, *Dir.glob(glob)
207
+ end
208
+
209
+ desc 'Check test coverage'
210
+ task :coverage do
211
+ system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/*_test.rb')}")
212
+ show_test_coverage_results
213
+ end
214
+
215
+ namespace :remote do
216
+ task :preflight_check do
217
+ required_vars = %w(AMAZON_ACCESS_KEY_ID AMAZON_SECRET_ACCESS_KEY TEST_BUCKET)
218
+
219
+ if (missing_vars = required_vars.select { |k| ENV[k].nil? }).any?
220
+ abort 'You must set ' + missing_vars.join(', ')
221
+ end
222
+ end
223
+ end
224
+
225
+ Rake::TestTask.new(:remote => 'remote:preflight_check') do |test|
226
+ test.pattern = 'test/remote/*_test.rb'
227
+ test.verbose = true
228
+ end
229
+
230
+ Rake::TestTask.new(:all) do |test|
231
+ test.pattern = 'test/**/*_test.rb'
232
+ test.verbose = true
233
+ end
234
+
235
+ desc 'Check test coverage of full stack remote tests'
236
+ task :full_coverage do
237
+ system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/remote/*_test.rb')} #{File.join(library_root, 'test/*_test.rb')}")
238
+ show_test_coverage_results
239
+ end
240
+
241
+ desc 'Run local tests against multiple versions of Ruby'
242
+ task :version_audit do
243
+ multiruby['test/*_test.rb']
244
+ end
245
+
246
+ namespace :version_audit do
247
+ desc 'Run remote tests against multiple versions of Ruby'
248
+ task :remote do
249
+ multiruby['test/remote/*_test.rb']
250
+ end
251
+
252
+ desc 'Run all tests against multiple versions of Ruby'
253
+ task :all do
254
+ multiruby['test/**/*_test.rb']
255
+ end
256
+ end
257
+
258
+ def show_test_coverage_results
259
+ system("open #{File.join(library_root, 'coverage/index.html')}") if PLATFORM['darwin']
260
+ end
261
+
262
+ desc 'Remove coverage products'
263
+ task :clobber_coverage do
264
+ rm_r 'coverage' rescue nil
265
+ end
266
+ end
267
+
268
+ namespace :todo do
269
+ class << TODOS = IO.read(File.join(library_root, 'TODO'))
270
+ def items
271
+ split("\n").grep(/^\[\s|X\]/)
272
+ end
273
+
274
+ def completed
275
+ find_items_matching(/^\[X\]/)
276
+ end
277
+
278
+ def uncompleted
279
+ find_items_matching(/^\[\s\]/)
280
+ end
281
+
282
+ def find_items_matching(regexp)
283
+ items.grep(regexp).instance_eval do
284
+ def display
285
+ puts map {|item| "* #{item.sub(/^\[[^\]]\]\s/, '')}"}
286
+ end
287
+ self
288
+ end
289
+ end
290
+ end
291
+
292
+ desc 'Completed todo items'
293
+ task :completed do
294
+ TODOS.completed.display
295
+ end
296
+
297
+ desc 'Incomplete todo items'
298
+ task :uncompleted do
299
+ TODOS.uncompleted.display
300
+ end
301
+ end if File.exists?(File.join(library_root, 'TODO'))
302
+
303
+ namespace :site do
304
+ require 'erb'
305
+ require 'rdoc/markup/simple_markup'
306
+ require 'rdoc/markup/simple_markup/to_html'
307
+
308
+ readme = lambda { IO.read('README')[/^== Getting started\n(.*)/m, 1] }
309
+
310
+ readme_to_html = lambda do
311
+ handler = SM::ToHtml.new
312
+ handler.instance_eval do
313
+ require 'syntax'
314
+ require 'syntax/convertors/html'
315
+ def accept_verbatim(am, fragment)
316
+ syntax = Syntax::Convertors::HTML.for_syntax('ruby')
317
+ @res << %(<div class="ruby">#{syntax.convert(fragment.txt, true)}</div>)
318
+ end
319
+ end
320
+ SM::SimpleMarkup.new.convert(readme.call, handler)
321
+ end
322
+
323
+ desc 'Regenerate the public website page'
324
+ task :build => 'doc:readme' do
325
+ open('site/public/index.html', 'w') do |file|
326
+ erb_data = {}
327
+ erb_data[:readme] = readme_to_html.call
328
+ file.write ERB.new(IO.read('site/index.erb')).result(binding)
329
+ end
330
+ end
331
+
332
+ task :refresh => :build do
333
+ system 'open site/public/index.html'
334
+ end
335
+
336
+ desc 'Update the live website'
337
+ task :deploy => :build do
338
+ site_files = FileList['site/public/*']
339
+ site_files.delete_if {|file| File.directory?(file)}
340
+ sh %(scp #{site_files.join ' '} marcel@rubyforge.org:/var/www/gforge-projects/amazon/)
341
+ end
342
+ end
343
+
344
+ task :clean => ['dist:clobber_package', 'doc:clobber_rdoc', 'test:clobber_coverage']