simple_record 1.1.26 → 1.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -184,7 +184,7 @@ Then in addition to being able to access the something object with:
184
184
  or setting it with:
185
185
 
186
186
  o.something = someo
187
-
187
+
188
188
  You can also access the ID for something directly with:
189
189
 
190
190
  o.something_id
@@ -193,12 +193,21 @@ or
193
193
 
194
194
  o.something_id = x
195
195
 
196
- #### Batch Save
196
+ ### Batch Save
197
197
 
198
198
  To do a batch save using SimpleDB's batch saving feature to improve performance, simply create your objects, add them to an array, then call:
199
199
 
200
200
  MyClass.batch_save(object_list)
201
201
 
202
+ ## Caching
203
+
204
+ You can use any cache that supports the ActiveSupport::Cache::Store interface.
205
+
206
+ SimpleRecord::Base.cache_store = my_cache_store
207
+
208
+ If you want a simple in memory cache store, try: http://gemcutter.org/gems/local_cache . It supports max cache size and
209
+ timeouts. You can also use memcached or http://www.quetzall.com/cloudcache.
210
+
202
211
  ## Kudos
203
212
 
204
213
  Special thanks to Garrett Cox for creating Activerecord2sdb which SimpleRecord is based on:
data/lib/simple_record.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  # puts 'got=' + mm2.name + ' and he/she is ' + mm.age.to_s + ' years old'
23
23
 
24
24
 
25
- require 'right_aws'
25
+ require 'aws'
26
26
  require 'sdb/active_sdb'
27
27
  #require 'results_array' # why the heck isn't this picking up???
28
28
  require File.expand_path(File.dirname(__FILE__) + "/results_array")
@@ -75,7 +75,7 @@ module SimpleRecord
75
75
  end
76
76
  end
77
77
 
78
- class Base < RightAws::ActiveSdb::Base
78
+ class Base < Aws::ActiveSdb::Base
79
79
 
80
80
  include SimpleRecord::Callbacks
81
81
 
@@ -530,14 +530,14 @@ module SimpleRecord
530
530
  # Amazon suggests: 2008-02-10T16:52:01.000-05:00
531
531
  # "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
532
532
  #
533
- if x.is_a? Date
534
- x_str = x.strftime(@@date_format)
535
- elsif x.is_a? DateTime
536
- x_str = x.new_offset(0).strftime(@@date_format)
537
- else
533
+ if x.is_a? DateTime
534
+ x_str = x.getutc.strftime(@@date_format)
535
+ elsif x.is_a? Time
538
536
  x_str = x.getutc.strftime(@@date_format)
537
+ elsif x.is_a? Date
538
+ x_str = x.strftime(@@date_format)
539
+
539
540
  end
540
- # puts 'utc=' + x_str
541
541
  return x_str
542
542
  else
543
543
  return x
@@ -917,7 +917,7 @@ module SimpleRecord
917
917
  #puts 'after collect=' + options.inspect
918
918
  convert_condition_params(options)
919
919
  end
920
- #puts 'params2=' + params.inspect
920
+ # puts 'params2=' + params.inspect
921
921
 
922
922
  results = q_type == :all ? [] : nil
923
923
  begin
data/test/my_model.rb CHANGED
@@ -6,7 +6,7 @@ class MyModel < MyBaseModel
6
6
  has_strings :name, :nickname
7
7
  has_ints :age, :save_count
8
8
  has_booleans :cool
9
- has_dates :birthday
9
+ has_dates :birthday, :date1, :date2, :date3
10
10
 
11
11
 
12
12
  #callbacks
@@ -4,17 +4,18 @@ require "yaml"
4
4
  require 'right_aws'
5
5
  require 'my_model'
6
6
  require 'my_child_model'
7
+ require 'active_support'
7
8
 
8
9
  class TestSimpleRecord < Test::Unit::TestCase
9
10
 
10
11
  def setup
11
12
  @config = YAML::load(File.open(File.expand_path("~/.test-configs/simple_record.yml")))
12
13
  #puts 'inspecting config = ' + @config.inspect
13
-
14
+
14
15
  # Establish AWS connection directly
15
16
  @@sdb = RightAws::SdbInterface.new(@config['amazon']['access_key'], @config['amazon']['secret_key'], {:connection_mode => :per_request, :protocol => "http", :port => 80})
16
-
17
-
17
+
18
+
18
19
  SimpleRecord.establish_connection(@config['amazon']['access_key'], @config['amazon']['secret_key'], :connection_mode=>:single)
19
20
  SimpleRecord::Base.set_domain_prefix("simplerecord_tests_")
20
21
  end
@@ -351,7 +352,7 @@ class TestSimpleRecord < Test::Unit::TestCase
351
352
  end
352
353
  assert mms.size == 1
353
354
  assert mms[0].id = mm.id
354
- mms = MyModel.find(:all, :conditions=>["birthday is not null"])
355
+ mms = MyModel.find(:all, :conditions=>["birthday is not null"])
355
356
  mms.each do |m|
356
357
  puts m.inspect
357
358
  end
@@ -387,5 +388,29 @@ class TestSimpleRecord < Test::Unit::TestCase
387
388
 
388
389
  end
389
390
 
391
+ def test_dates
392
+ mm = MyModel.new()
393
+ mm.name = "test name"
394
+ mm.date1 = Date.today
395
+ mm.date2 = Time.now
396
+ mm.date3 = DateTime.now
397
+ mm.save
398
+
399
+ sleep 1
400
+
401
+ mm = MyModel.find(:first, :conditions=>["date1 >= ?", 1.days.ago.to_date])
402
+ puts 'mm=' + mm.inspect
403
+ assert mm
404
+
405
+ mm = MyModel.find(:first, :conditions=>["date2 >= ?", 1.minutes.ago])
406
+ puts 'mm=' + mm.inspect
407
+ assert mm
408
+
409
+ mm = MyModel.find(:first, :conditions=>["date3 >= ?", 1.minutes.ago])
410
+ puts 'mm=' + mm.inspect
411
+ assert mm
412
+
413
+ end
414
+
390
415
 
391
416
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.26
4
+ version: 1.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-10-29 00:00:00 -07:00
14
+ date: 2009-11-04 00:00:00 -08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency