le88-aws-s3 0.6.3.1310482014

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/COPYING +19 -0
  2. data/INSTALL +55 -0
  3. data/README +545 -0
  4. data/Rakefile +334 -0
  5. data/bin/s3sh +6 -0
  6. data/bin/setup.rb +10 -0
  7. data/lib/aws/s3/acl.rb +636 -0
  8. data/lib/aws/s3/authentication.rb +221 -0
  9. data/lib/aws/s3/base.rb +240 -0
  10. data/lib/aws/s3/bittorrent.rb +58 -0
  11. data/lib/aws/s3/bucket.rb +319 -0
  12. data/lib/aws/s3/connection.rb +278 -0
  13. data/lib/aws/s3/error.rb +69 -0
  14. data/lib/aws/s3/exceptions.rb +133 -0
  15. data/lib/aws/s3/extensions.rb +340 -0
  16. data/lib/aws/s3/logging.rb +314 -0
  17. data/lib/aws/s3/object.rb +612 -0
  18. data/lib/aws/s3/owner.rb +44 -0
  19. data/lib/aws/s3/parsing.rb +99 -0
  20. data/lib/aws/s3/response.rb +180 -0
  21. data/lib/aws/s3/service.rb +51 -0
  22. data/lib/aws/s3/version.rb +12 -0
  23. data/lib/aws/s3.rb +60 -0
  24. data/support/faster-xml-simple/lib/faster_xml_simple.rb +187 -0
  25. data/support/faster-xml-simple/test/regression_test.rb +47 -0
  26. data/support/faster-xml-simple/test/test_helper.rb +17 -0
  27. data/support/faster-xml-simple/test/xml_simple_comparison_test.rb +46 -0
  28. data/support/rdoc/code_info.rb +211 -0
  29. data/test/acl_test.rb +254 -0
  30. data/test/authentication_test.rb +114 -0
  31. data/test/base_test.rb +136 -0
  32. data/test/bucket_test.rb +74 -0
  33. data/test/connection_test.rb +215 -0
  34. data/test/error_test.rb +70 -0
  35. data/test/extensions_test.rb +340 -0
  36. data/test/fixtures/buckets.yml +133 -0
  37. data/test/fixtures/errors.yml +34 -0
  38. data/test/fixtures/headers.yml +3 -0
  39. data/test/fixtures/logging.yml +15 -0
  40. data/test/fixtures/loglines.yml +5 -0
  41. data/test/fixtures/logs.yml +7 -0
  42. data/test/fixtures/policies.yml +16 -0
  43. data/test/fixtures.rb +89 -0
  44. data/test/logging_test.rb +89 -0
  45. data/test/mocks/fake_response.rb +26 -0
  46. data/test/object_test.rb +205 -0
  47. data/test/parsing_test.rb +66 -0
  48. data/test/remote/acl_test.rb +117 -0
  49. data/test/remote/bittorrent_test.rb +45 -0
  50. data/test/remote/bucket_test.rb +146 -0
  51. data/test/remote/logging_test.rb +82 -0
  52. data/test/remote/object_test.rb +371 -0
  53. data/test/remote/test_file.data +0 -0
  54. data/test/remote/test_helper.rb +33 -0
  55. data/test/response_test.rb +68 -0
  56. data/test/service_test.rb +23 -0
  57. data/test/test_helper.rb +110 -0
  58. metadata +179 -0
data/Rakefile ADDED
@@ -0,0 +1,334 @@
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 = 'le88-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, :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
+ Rake::TestTask.new(:remote) do |test|
216
+ test.pattern = 'test/remote/*_test.rb'
217
+ test.verbose = true
218
+ end
219
+
220
+ Rake::TestTask.new(:all) do |test|
221
+ test.pattern = 'test/**/*_test.rb'
222
+ test.verbose = true
223
+ end
224
+
225
+ desc 'Check test coverage of full stack remote tests'
226
+ task :full_coverage do
227
+ system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/remote/*_test.rb')} #{File.join(library_root, 'test/*_test.rb')}")
228
+ show_test_coverage_results
229
+ end
230
+
231
+ desc 'Run local tests against multiple versions of Ruby'
232
+ task :version_audit do
233
+ multiruby['test/*_test.rb']
234
+ end
235
+
236
+ namespace :version_audit do
237
+ desc 'Run remote tests against multiple versions of Ruby'
238
+ task :remote do
239
+ multiruby['test/remote/*_test.rb']
240
+ end
241
+
242
+ desc 'Run all tests against multiple versions of Ruby'
243
+ task :all do
244
+ multiruby['test/**/*_test.rb']
245
+ end
246
+ end
247
+
248
+ def show_test_coverage_results
249
+ system("open #{File.join(library_root, 'coverage/index.html')}") if PLATFORM['darwin']
250
+ end
251
+
252
+ desc 'Remove coverage products'
253
+ task :clobber_coverage do
254
+ rm_r 'coverage' rescue nil
255
+ end
256
+ end
257
+
258
+ namespace :todo do
259
+ class << TODOS = IO.read(File.join(library_root, 'TODO'))
260
+ def items
261
+ split("\n").grep(/^\[\s|X\]/)
262
+ end
263
+
264
+ def completed
265
+ find_items_matching(/^\[X\]/)
266
+ end
267
+
268
+ def uncompleted
269
+ find_items_matching(/^\[\s\]/)
270
+ end
271
+
272
+ def find_items_matching(regexp)
273
+ items.grep(regexp).instance_eval do
274
+ def display
275
+ puts map {|item| "* #{item.sub(/^\[[^\]]\]\s/, '')}"}
276
+ end
277
+ self
278
+ end
279
+ end
280
+ end
281
+
282
+ desc 'Completed todo items'
283
+ task :completed do
284
+ TODOS.completed.display
285
+ end
286
+
287
+ desc 'Incomplete todo items'
288
+ task :uncompleted do
289
+ TODOS.uncompleted.display
290
+ end
291
+ end if File.exists?(File.join(library_root, 'TODO'))
292
+
293
+ # namespace :site do
294
+ # require 'erb'
295
+ # require 'rdoc/markup/simple_markup'
296
+ # require 'rdoc/markup/simple_markup/to_html'
297
+ #
298
+ # readme = lambda { IO.read('README')[/^== Getting started\n(.*)/m, 1] }
299
+ #
300
+ # readme_to_html = lambda do
301
+ # handler = SM::ToHtml.new
302
+ # handler.instance_eval do
303
+ # require 'syntax'
304
+ # require 'syntax/convertors/html'
305
+ # def accept_verbatim(am, fragment)
306
+ # syntax = Syntax::Convertors::HTML.for_syntax('ruby')
307
+ # @res << %(<div class="ruby">#{syntax.convert(fragment.txt, true)}</div>)
308
+ # end
309
+ # end
310
+ # SM::SimpleMarkup.new.convert(readme.call, handler)
311
+ # end
312
+ #
313
+ # desc 'Regenerate the public website page'
314
+ # task :build => 'doc:readme' do
315
+ # open('site/public/index.html', 'w') do |file|
316
+ # erb_data = {}
317
+ # erb_data[:readme] = readme_to_html.call
318
+ # file.write ERB.new(IO.read('site/index.erb')).result(binding)
319
+ # end
320
+ # end
321
+ #
322
+ # task :refresh => :build do
323
+ # system 'open site/public/index.html'
324
+ # end
325
+ #
326
+ # desc 'Update the live website'
327
+ # task :deploy => :build do
328
+ # site_files = FileList['site/public/*']
329
+ # site_files.delete_if {|file| File.directory?(file)}
330
+ # sh %(scp #{site_files.join ' '} marcel@rubyforge.org:/var/www/gforge-projects/amazon/)
331
+ # end
332
+ # end
333
+
334
+ task :clean => ['dist:clobber_package', 'doc:clobber_rdoc', 'test:clobber_coverage']
data/bin/s3sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ s3_lib = File.dirname(__FILE__) + '/../lib/aws/s3'
3
+ setup = File.dirname(__FILE__) + '/setup'
4
+ irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
5
+
6
+ exec "#{irb_name} -r #{s3_lib} -r #{setup} --simple-prompt"
data/bin/setup.rb ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ if ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY']
3
+ AWS::S3::Base.establish_connection!(
4
+ :access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
5
+ :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
6
+ )
7
+ end
8
+
9
+ require File.dirname(__FILE__) + '/../test/fixtures'
10
+ include AWS::S3