aws-s3 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2006-2008 Marcel Molina Jr. <marcel@vernix.org>
2
+ # Copyright (c) 2006-2009 Marcel Molina Jr. <marcel@vernix.org>
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
5
  # this software and associated documentation files (the "Software"), to deal in the
data/Rakefile CHANGED
@@ -208,7 +208,7 @@ namespace :test do
208
208
 
209
209
  desc 'Check test coverage'
210
210
  task :coverage do
211
- system("rcov --sort coverage #{File.join(library_root, 'test/*_test.rb')}")
211
+ system("rcov -x Library -x support --sort coverage #{File.join(library_root, 'test/*_test.rb')}")
212
212
  show_test_coverage_results
213
213
  end
214
214
 
@@ -224,7 +224,7 @@ namespace :test do
224
224
 
225
225
  desc 'Check test coverage of full stack remote tests'
226
226
  task :full_coverage do
227
- system("rcov --sort coverage #{File.join(library_root, 'test/remote/*_test.rb')} #{File.join(library_root, 'test/*_test.rb')}")
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
228
  show_test_coverage_results
229
229
  end
230
230
 
@@ -528,7 +528,7 @@ module AWS
528
528
  # bucket.acl(bucket.acl)
529
529
  def acl(reload = false)
530
530
  policy = reload.is_a?(ACL::Policy) ? reload : nil
531
- memoize(reload) do
531
+ expirable_memoize(reload) do
532
532
  self.class.acl(name, policy) if policy
533
533
  self.class.acl(name)
534
534
  end
@@ -579,7 +579,7 @@ module AWS
579
579
  # object.acl(object.acl)
580
580
  def acl(reload = false)
581
581
  policy = reload.is_a?(ACL::Policy) ? reload : nil
582
- memoize(reload) do
582
+ expirable_memoize(reload) do
583
583
  self.class.acl(key, bucket.name, policy) if policy
584
584
  self.class.acl(key, bucket.name)
585
585
  end
@@ -249,73 +249,28 @@ module AWS
249
249
  end
250
250
 
251
251
  class Options < Hash #:nodoc:
252
- class << self
253
- def valid_options
254
- [:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy]
255
- end
256
- end
252
+ VALID_OPTIONS = [:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy].freeze
257
253
 
258
- attr_reader :options
259
254
  def initialize(options = {})
260
255
  super()
261
- @options = options
262
- validate!
263
- extract_proxy_settings!
264
- extract_persistent!
265
- extract_server!
266
- extract_port!
267
- extract_remainder!
256
+ validate(options)
257
+ replace(:server => DEFAULT_HOST, :port => (options[:use_ssl] ? 443 : 80))
258
+ merge!(options)
268
259
  end
269
-
260
+
270
261
  def connecting_through_proxy?
271
262
  !self[:proxy].nil?
272
263
  end
273
264
 
274
265
  def proxy_settings
275
- proxy_setting_keys.map do |proxy_key|
276
- self[:proxy][proxy_key]
277
- end
266
+ self[:proxy].values_at(:host, :port, :user, :password)
278
267
  end
279
268
 
280
269
  private
281
- def proxy_setting_keys
282
- [:host, :port, :user, :password]
283
- end
284
-
285
- def missing_proxy_settings?
286
- !self[:proxy].keys.include?(:host)
287
- end
288
-
289
- def extract_persistent!
290
- self[:persistent] = options.has_key?(:persitent) ? options[:persitent] : false
291
- end
292
-
293
- def extract_proxy_settings!
294
- self[:proxy] = options.delete(:proxy) if options.include?(:proxy)
295
- validate_proxy_settings!
296
- end
297
-
298
- def extract_server!
299
- self[:server] = options.delete(:server) || DEFAULT_HOST
300
- end
301
-
302
- def extract_port!
303
- self[:port] = options.delete(:port) || (options[:use_ssl] ? 443 : 80)
304
- end
305
-
306
- def extract_remainder!
307
- update(options)
308
- end
309
-
310
- def validate!
311
- invalid_options = options.keys.select {|key| !self.class.valid_options.include?(key)}
270
+ def validate(options)
271
+ invalid_options = options.keys - VALID_OPTIONS
312
272
  raise InvalidConnectionOption.new(invalid_options) unless invalid_options.empty?
313
- end
314
-
315
- def validate_proxy_settings!
316
- if connecting_through_proxy? && missing_proxy_settings?
317
- raise ArgumentError, "Missing proxy settings. Must specify at least :host."
318
- end
273
+ raise ArgumentError, "Missing proxy settings. Must specify at least :host." if options[:proxy] && !options[:proxy][:host]
319
274
  end
320
275
  end
321
276
  end
@@ -58,7 +58,7 @@ module AWS
58
58
  class InvalidConnectionOption < InvalidOption
59
59
  def initialize(invalid_options)
60
60
  message = "The following connection options are invalid: #{invalid_options.join(', ')}. " +
61
- "The valid connection options are: #{Connection::Options.valid_options.join(', ')}."
61
+ "The valid connection options are: #{Connection::Options::VALID_OPTIONS.join(', ')}."
62
62
  super(message)
63
63
  end
64
64
  end
@@ -133,8 +133,8 @@ module Kernel
133
133
  caller[1][/`([^']+)'/, 1]
134
134
  end if RUBY_VERSION > '1.8.7'
135
135
 
136
- def memoize(reload = false, storage = nil)
137
- current_method = RUBY_VERSION >= '1.8.7' ? __called_from__ : __method__(1)
136
+ def expirable_memoize(reload = false, storage = nil)
137
+ current_method = RUBY_VERSION > '1.8.7' ? __called_from__ : __method__(1)
138
138
  storage = "@#{storage || current_method}"
139
139
  if reload
140
140
  instance_variable_set(storage, nil)
@@ -174,7 +174,7 @@ class Module
174
174
  alias_method original_method, method_name
175
175
  module_eval(<<-EVAL, __FILE__, __LINE__)
176
176
  def #{method_name}(reload = false, *args, &block)
177
- memoize(reload) do
177
+ expirable_memoize(reload) do
178
178
  send(:#{original_method}, *args, &block)
179
179
  end
180
180
  end
@@ -485,7 +485,7 @@ module AWS
485
485
  reload = options
486
486
  options = {}
487
487
  end
488
- memoize(reload) do
488
+ expirable_memoize(reload) do
489
489
  self.class.stream(key, bucket.name, options, &block)
490
490
  end
491
491
  end
@@ -561,7 +561,7 @@ module AWS
561
561
 
562
562
  def etag(reload = false)
563
563
  return nil unless stored?
564
- memoize(reload) do
564
+ expirable_memoize(reload) do
565
565
  reload ? about(reload)['etag'][1...-1] : attributes['e_tag'][1...-1]
566
566
  end
567
567
  end
@@ -3,8 +3,8 @@ module AWS
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = '0'
5
5
  MINOR = '6'
6
- TINY = '0'
7
- BETA = nil # Time.now.to_i.to_s
6
+ TINY = '1'
7
+ BETA = nil #Time.now.to_i.to_s
8
8
  end
9
9
 
10
10
  Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class ConnectionTest < Test::Unit::TestCase
4
4
  attr_reader :keys
5
5
  def setup
6
- @keys = {:access_key_id => '123', :secret_access_key => 'abc'}
6
+ @keys = {:access_key_id => '123', :secret_access_key => 'abc'}.freeze
7
7
  end
8
8
 
9
9
  def test_creating_a_connection
@@ -207,7 +207,6 @@ class ConnectionOptionsTest < Test::Unit::TestCase
207
207
  private
208
208
  def assert_key_transfered(key, value, options)
209
209
  assert_equal value, options[key]
210
- assert !options.instance_variable_get('@options').has_key?(key)
211
210
  end
212
211
 
213
212
  def generate_options(options = {})
@@ -144,13 +144,13 @@ end if RUBY_VERSION < '1.8.7'
144
144
  class ModuleExtensionsTest < Test::Unit::TestCase
145
145
  class Foo
146
146
  def foo(reload = false)
147
- memoize(reload) do
147
+ expirable_memoize(reload) do
148
148
  Time.now
149
149
  end
150
150
  end
151
151
 
152
152
  def bar(reload = false)
153
- memoize(reload, :baz) do
153
+ expirable_memoize(reload, :baz) do
154
154
  Time.now
155
155
  end
156
156
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcel Molina Jr.
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-19 00:00:00 -07:00
12
+ date: 2009-04-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency