simple_record 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. data/README.txt +3 -0
  2. data/lib/simple_record.rb +35 -8
  3. metadata +4 -1
data/README.txt CHANGED
@@ -7,6 +7,9 @@ http://code.google.com/p/simple-record/
7
7
  An ActiveRecord interface for SimpleDB that takes care of offsets and padding, etc.
8
8
  Can be used as a drop in replacement for ActiveRecord in rails.
9
9
 
10
+ Special thanks to Garrett Cox for creating Activerecord2sdb which SimpleRecord is based on:
11
+ http://activrecord2sdb.rubyforge.org/
12
+
10
13
  == FEATURES/PROBLEMS:
11
14
 
12
15
  * FIX (list of features or problems)
data/lib/simple_record.rb CHANGED
@@ -1,10 +1,35 @@
1
+ # Usage:
2
+ # require 'simple_record'
3
+ #
4
+ # class MyModel < SimpleRecord::Base
5
+ #
6
+ # has_attributes :name, :age
7
+ # are_ints :age
8
+ #
9
+ # end
10
+ #
11
+ # AWS_ACCESS_KEY_ID='XXXXX'
12
+ # AWS_SECRET_ACCESS_KEY='YYYYY'
13
+ # RightAws::ActiveSdb.establish_connection(AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, {:multi_thread => false})
14
+ # # Save an object
15
+ # mm = MyModel.new
16
+ # mm.name = "Travis"
17
+ # mm.age = 32
18
+ # mm.save
19
+ # id = mm.id
20
+ # # Get the object back
21
+ # mm2 = MyModel.select(id)
22
+ # puts 'got=' + mm2.name + ' and he/she is ' + mm.age.to_s + ' years old'
23
+
24
+
25
+
1
26
  require 'right_aws'
2
27
  require 'sdb/active_sdb'
3
28
  require 'local_cache'
4
29
 
5
30
  module SimpleRecord
6
31
 
7
- VERSION = '1.0.0'
32
+ VERSION = '1.0.1'
8
33
 
9
34
  class Base < RightAws::ActiveSdb::Base
10
35
 
@@ -21,16 +46,17 @@ VERSION = '1.0.0'
21
46
  return @@cache_store
22
47
  end
23
48
 
49
+ # If you want a domain prefix for all your models, set it here.
24
50
  def self.set_domain_prefix(prefix)
25
51
  @@domain_prefix = prefix
26
52
  end
27
53
 
28
- # Sets the table name.
29
- # Passes it to set_domain_name in ActiveSDB.
54
+ # Same as set_table_name
30
55
  def self.set_table_name(table_name)
31
56
  set_domain_name table_name
32
57
  end
33
58
 
59
+ # Sets the domain name for this class
34
60
  def self.set_domain_name(table_name)
35
61
  # puts 'setting domain name for class ' + self.inspect + '=' + table_name
36
62
  @domain_name_for_class = table_name
@@ -304,7 +330,7 @@ VERSION = '1.0.0'
304
330
  else
305
331
  super()
306
332
  end
307
- @errors=Activerecordtosdb_errors.new
333
+ @errors=SimpleRecord_errors.new
308
334
  end
309
335
 
310
336
 
@@ -341,6 +367,7 @@ VERSION = '1.0.0'
341
367
 
342
368
  def domain_ok(ex)
343
369
  if (ex.message().index("NoSuchDomain") != nil)
370
+ puts "Creating new SimpleDB Domain: " + domain
344
371
  self.class.create_domain
345
372
  return true
346
373
  end
@@ -408,7 +435,7 @@ VERSION = '1.0.0'
408
435
  return false
409
436
  end
410
437
  rescue RightAws::AwsError
411
- puts "RESCUED in save: " + $!
438
+ # puts "RESCUED in save: " + $!
412
439
  if (domain_ok($!))
413
440
  if !@create_domain_called
414
441
  @create_domain_called = true
@@ -475,7 +502,7 @@ VERSION = '1.0.0'
475
502
  for d in @@dates
476
503
  # puts 'converting created: ' + self['created'].inspect
477
504
  if d == arg
478
- x = DateTime.parse(d2)
505
+ x = DateTime.parse(x)
479
506
  end
480
507
  # if !self[d].nil?
481
508
  # self[d].collect!{ |d2|
@@ -759,7 +786,7 @@ This is done on getters now
759
786
 
760
787
  end
761
788
 
762
- class Activerecordtosdb_errors
789
+ class SimpleRecord_errors
763
790
  def initialize(*params)
764
791
  super(*params)
765
792
  @errors=[]
@@ -774,7 +801,7 @@ This is done on getters now
774
801
  end
775
802
 
776
803
  def count
777
- return @errors.length
804
+ return length
778
805
  end
779
806
 
780
807
  def length
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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -25,6 +25,9 @@ dependencies:
25
25
  description: |-
26
26
  An ActiveRecord interface for SimpleDB that takes care of offsets and padding, etc.
27
27
  Can be used as a drop in replacement for ActiveRecord in rails.
28
+
29
+ Special thanks to Garrett Cox for creating Activerecord2sdb which SimpleRecord is based on:
30
+ http://activrecord2sdb.rubyforge.org/
28
31
  email:
29
32
  - travis@crankapps.com
30
33
  executables: