simply_stored 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Changelog
2
2
  =============
3
3
 
4
+
5
+ 0.2.5
6
+ =============
7
+
8
+ - Allow to pass a custom logger to S3-attachments / RightAws
9
+
4
10
  - Support :order option to has_many associations and classes, e.g:
5
11
 
6
12
  @user.posts(:order => :desc)
data/README.md CHANGED
@@ -177,7 +177,8 @@ Both the CouchDB backend and the SimpleDB backend have support for S3 attachment
177
177
  :access_key => 'my-AWS-key-id',
178
178
  :secret_access_key => 'psst!-secret',
179
179
  :location => :eu,
180
- :after_delete => :delete
180
+ :after_delete => :delete,
181
+ :logger => Logger.new('/dev/null')
181
182
 
182
183
  end
183
184
 
@@ -6,7 +6,7 @@ module SimplyStored
6
6
  end
7
7
 
8
8
  def s3_connection(name)
9
- @_s3_connection ||= RightAws::S3.new(_s3_options[name][:access_key], _s3_options[name][:secret_access_key], :multi_thread => true, :ca_file => _s3_options[name][:ca_file])
9
+ @_s3_connection ||= RightAws::S3.new(_s3_options[name][:access_key], _s3_options[name][:secret_access_key], :multi_thread => true, :ca_file => _s3_options[name][:ca_file], :logger => _s3_options[name][:logger])
10
10
  end
11
11
 
12
12
  def s3_bucket(name)
@@ -107,7 +107,8 @@ module SimplyStored
107
107
  :ssl => true,
108
108
  :location => :us, # use :eu for European buckets
109
109
  :ca_file => nil, # point to CA file for SSL certificate verification
110
- :after_delete => :nothing # or :delete to delete the item on S3 after it is deleted in the DB
110
+ :after_delete => :nothing, # or :delete to delete the item on S3 after it is deleted in the DB,
111
+ :logger => nil # use the default RightAws logger (stdout)
111
112
  }.update(options)
112
113
  self._s3_options ||= {}
113
114
  self._s3_options[name] = options
@@ -1295,7 +1295,7 @@ class CouchTest < Test::Unit::TestCase
1295
1295
  context "when saving the attachment" do
1296
1296
  should "fetch the collection" do
1297
1297
  @log_item.log_data = "Yay! It logged!"
1298
- RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => nil).returns(@s3)
1298
+ RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => nil, :logger => nil).returns(@s3)
1299
1299
  @log_item.save
1300
1300
  end
1301
1301
 
@@ -1349,6 +1349,16 @@ class CouchTest < Test::Unit::TestCase
1349
1349
  @log_item.save
1350
1350
  end
1351
1351
  end
1352
+
1353
+ should "pass the logger object down to RightAws" do
1354
+ logger = mock()
1355
+ @log_item.log_data = "Yay! log me"
1356
+ CouchLogItem._s3_options[:log_data][:bucket] = 'mybucket'
1357
+ CouchLogItem._s3_options[:log_data][:logger] = logger
1358
+
1359
+ RightAws::S3.expects(:new).with(anything, anything, {:logger => logger, :ca_file => nil, :multi_thread => true}).returns(@s3)
1360
+ @log_item.save
1361
+ end
1352
1362
 
1353
1363
  should "not upload the attachment when it hasn't been changed" do
1354
1364
  @bucket.expects(:put).never
@@ -1465,7 +1475,7 @@ class CouchTest < Test::Unit::TestCase
1465
1475
  CouchLogItem._s3_options[:log_data][:location] = :eu
1466
1476
  CouchLogItem._s3_options[:log_data][:ca_file] = '/etc/ssl/ca.crt'
1467
1477
 
1468
- RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => '/etc/ssl/ca.crt').returns(@s3)
1478
+ RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => '/etc/ssl/ca.crt', :logger => nil).returns(@s3)
1469
1479
 
1470
1480
  @log_item.log_data
1471
1481
  end
@@ -1190,7 +1190,7 @@ class SimplyStoredTest < Test::Unit::TestCase
1190
1190
  context "when saving the attachment" do
1191
1191
  should "fetch the collection" do
1192
1192
  @log_item.log_data = "Yay! It logged!"
1193
- RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => nil).returns(@s3)
1193
+ RightAws::S3.expects(:new).with('abcdef', 'secret!', :multi_thread => true, :ca_file => nil, :logger => nil).returns(@s3)
1194
1194
  @log_item.save
1195
1195
  end
1196
1196
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_stored
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Meyer, Jonathan Weiss