simple_record 1.4.11 → 1.4.12

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/lib/simple_record.rb CHANGED
@@ -26,6 +26,8 @@
26
26
 
27
27
  require 'aws'
28
28
  require 'base64'
29
+ require 'active_support'
30
+ require 'active_support/core_ext'
29
31
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/attributes")
30
32
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/active_sdb")
31
33
  require File.expand_path(File.dirname(__FILE__) + "/simple_record/callbacks")
@@ -232,7 +234,7 @@ module SimpleRecord
232
234
  unless @domain
233
235
  # This strips off the module if there is one.
234
236
  n2 = name.split('::').last || name
235
- puts 'n2=' + n2
237
+ # puts 'n2=' + n2
236
238
  if n2.respond_to?(:tableize)
237
239
  @domain = n2.tableize
238
240
  else
@@ -634,6 +636,7 @@ module SimpleRecord
634
636
  end
635
637
 
636
638
  def delete()
639
+ # TODO: DELETE CLOBS, etc from s3
637
640
  super
638
641
  end
639
642
 
@@ -839,6 +842,7 @@ module SimpleRecord
839
842
 
840
843
  # Pad and Offset number attributes
841
844
  options = {}
845
+ params_dup = params.dup
842
846
  if params.size > 1
843
847
  options = params[1]
844
848
  #puts 'options=' + options.inspect
@@ -850,15 +854,14 @@ module SimpleRecord
850
854
  op_dup = options.dup
851
855
  op_dup[:limit] = per_token # simpledb uses Limit as a paging thing, not what is normal
852
856
  op_dup[:consistent_read] = consistent_read
853
- params[1] = op_dup
857
+ params_dup[1] = op_dup
854
858
  end
855
-
856
859
  end
857
860
  # puts 'params2=' + params.inspect
858
861
 
859
862
  ret = q_type == :all ? [] : nil
860
863
  begin
861
- results=find_with_metadata(*params)
864
+ results=find_with_metadata(*params_dup)
862
865
  # puts "RESULT=" + results.inspect
863
866
  write_usage(:select, domain, q_type, options, results)
864
867
  #puts 'params3=' + params.inspect
@@ -25,9 +25,29 @@ module SimpleRecord
25
25
  end
26
26
 
27
27
  end
28
+ #
29
+ # def to_json(*a)
30
+ # puts 'SimpleRecord to_json called'
31
+ # result = {
32
+ # 'json_class' => self.class.name,
33
+ # 'id' => self.id
34
+ # }
35
+ # defined_attributes_local.each_pair do |name, val|
36
+ ## puts name.to_s + "=" + val.inspect
37
+ # if val.type == :belongs_to
38
+ # result[name.to_s + "_id"] = get_attribute_sdb(name)
39
+ # else
40
+ # result[name] = get_attribute(name)
41
+ # end
42
+ ## puts 'result[name]=' + result[name].inspect
43
+ # end
44
+ # ret = result.to_json(*a)
45
+ ## puts 'ret=' + ret.inspect
46
+ # return ret
47
+ # end
28
48
 
29
- def to_json(*a)
30
- # puts 'to_json called'
49
+ def as_json(options={})
50
+ # puts 'SimpleRecord as_json called'
31
51
  result = {
32
52
  'json_class' => self.class.name,
33
53
  'id' => self.id
@@ -41,7 +61,7 @@ module SimpleRecord
41
61
  end
42
62
  # puts 'result[name]=' + result[name].inspect
43
63
  end
44
- ret = result.to_json(*a)
64
+ ret = result.as_json(options)
45
65
  # puts 'ret=' + ret.inspect
46
66
  return ret
47
67
  end
@@ -1,8 +1,8 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
-
3
- class MyBaseModel < SimpleRecord::Base
4
-
5
- has_strings :base_string
6
-
7
-
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
+
3
+ class MyBaseModel < SimpleRecord::Base
4
+
5
+ has_strings :base_string
6
+
7
+
8
8
  end
@@ -1,35 +1,35 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
- require 'my_model'
3
-
4
- class MyChildModel < SimpleRecord::Base
5
- belongs_to :my_model
6
- belongs_to :x, :class_name=>"MyModel"
7
- has_attributes :name, :child_attr
8
-
9
- end
10
-
11
-
12
- =begin
13
-
14
-
15
- puts 'word'
16
-
17
- mm = MyModel.new
18
- puts 'word2'
19
-
20
- mcm = MyChildModel.new
21
-
22
- puts 'mcm instance methods=' + MyChildModel.instance_methods(true).inspect
23
- #puts 'mcm=' + mcm.instance_methods(false)
24
- puts 'mcm class vars = ' + mcm.class.class_variables.inspect
25
- puts mcm.class == MyChildModel
26
- puts 'saved? ' + mm.save.to_s
27
- puts mm.errors.inspect
28
-
29
- puts "mm attributes=" + MyModel.defined_attributes.inspect
30
- puts "mcm attributes=" + MyChildModel.defined_attributes.inspect
31
-
32
- mcm2 = MyChildModel.new
33
- puts "mcm2 attributes=" + MyChildModel.defined_attributes.inspect
34
-
35
- =end
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/simple_record")
2
+ require_relative 'my_model'
3
+
4
+ class MyChildModel < SimpleRecord::Base
5
+ belongs_to :my_model
6
+ belongs_to :x, :class_name=>"MyModel"
7
+ has_attributes :name, :child_attr
8
+
9
+ end
10
+
11
+
12
+ =begin
13
+
14
+
15
+ puts 'word'
16
+
17
+ mm = MyModel.new
18
+ puts 'word2'
19
+
20
+ mcm = MyChildModel.new
21
+
22
+ puts 'mcm instance methods=' + MyChildModel.instance_methods(true).inspect
23
+ #puts 'mcm=' + mcm.instance_methods(false)
24
+ puts 'mcm class vars = ' + mcm.class.class_variables.inspect
25
+ puts mcm.class == MyChildModel
26
+ puts 'saved? ' + mm.save.to_s
27
+ puts mm.errors.inspect
28
+
29
+ puts "mm attributes=" + MyModel.defined_attributes.inspect
30
+ puts "mcm attributes=" + MyChildModel.defined_attributes.inspect
31
+
32
+ mcm2 = MyChildModel.new
33
+ puts "mcm2 attributes=" + MyChildModel.defined_attributes.inspect
34
+
35
+ =end
@@ -1,15 +1,15 @@
1
-
2
- require File.expand_path(File.dirname(__FILE__) + "/../lib/results_array")
3
-
4
- array = SimpleRecord::ResultsArray.new()
5
- #array.extend(ResultsArray)
6
-
7
- 500.times do |i|
8
- array << "_ob_" + i.to_s
9
- end
10
-
11
- array.each do |v|
12
- puts v.to_s
13
- end
14
-
1
+
2
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/results_array")
3
+
4
+ array = SimpleRecord::ResultsArray.new()
5
+ #array.extend(ResultsArray)
6
+
7
+ 500.times do |i|
8
+ array << "_ob_" + i.to_s
9
+ end
10
+
11
+ array.each do |v|
12
+ puts v.to_s
13
+ end
14
+
15
15
  puts array[10]
data/test/test_base.rb CHANGED
@@ -3,8 +3,8 @@ require File.join(File.dirname(__FILE__), "/../lib/simple_record")
3
3
  require File.join(File.dirname(__FILE__), "./test_helpers")
4
4
  require "yaml"
5
5
  require 'aws'
6
- require 'my_model'
7
- require 'my_child_model'
6
+ require_relative 'my_model'
7
+ require_relative 'my_child_model'
8
8
  require 'active_support'
9
9
 
10
10
  class TestBase < Test::Unit::TestCase
data/test/test_json.rb CHANGED
@@ -4,10 +4,10 @@ require File.join(File.dirname(__FILE__), "./test_helpers")
4
4
  require File.join(File.dirname(__FILE__), "./test_base")
5
5
  require "yaml"
6
6
  require 'aws'
7
- require 'my_model'
8
- require 'my_child_model'
9
- require 'model_with_enc'
10
- require 'active_support'
7
+ require_relative 'my_model'
8
+ require_relative 'my_child_model'
9
+ require_relative 'model_with_enc'
10
+ require 'active_support/core_ext'
11
11
 
12
12
  # Tests for SimpleRecord
13
13
  #
@@ -30,6 +30,8 @@ class TestJson < TestBase
30
30
 
31
31
  mm.save
32
32
 
33
+ puts 'no trying an array'
34
+
33
35
  data = {}
34
36
  models = []
35
37
  data[:models] = models
@@ -47,15 +49,19 @@ class TestJson < TestBase
47
49
  assert unjsoned[0].id.present?
48
50
  assert unjsoned[0].id == mm.id, "unjsoned.id=#{unjsoned[0].id}"
49
51
 
52
+ puts 'array good'
53
+
50
54
  t = Tester.new
51
55
  t2 = Tester.new
52
56
  t2.x1 = "i'm number 2"
53
57
  t.x1 = 1
54
58
  t.x2 = t2
55
- t.to_json
56
- jsoned = JSON.generate t
59
+ jsoned = t.to_json
60
+
57
61
  puts 'jsoned=' + jsoned
58
62
 
63
+ puts 'non simplerecord object good'
64
+
59
65
  mcm = MyChildModel.new
60
66
  mcm.name = "child"
61
67
  mcm.my_model = mm
@@ -4,10 +4,9 @@ require File.join(File.dirname(__FILE__), "./test_helpers")
4
4
  require File.join(File.dirname(__FILE__), "./test_base")
5
5
  require "yaml"
6
6
  require 'aws'
7
- require 'my_model'
8
- require 'my_child_model'
9
- require 'model_with_enc'
10
- require 'active_support'
7
+ require_relative 'my_model'
8
+ require_relative 'my_child_model'
9
+ require_relative 'model_with_enc'
11
10
 
12
11
  # Tests for SimpleRecord
13
12
  #
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_record
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 4
9
- - 11
10
- version: 1.4.11
8
+ - 12
9
+ version: 1.4.12
11
10
  platform: ruby
12
11
  authors:
13
12
  - Travis Reeder
@@ -17,7 +16,7 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-09-13 00:00:00 -07:00
19
+ date: 2010-09-23 00:00:00 -07:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -28,12 +27,24 @@ dependencies:
28
27
  requirements:
29
28
  - - ">="
30
29
  - !ruby/object:Gem::Version
31
- hash: 3
32
30
  segments:
33
31
  - 0
34
32
  version: "0"
35
33
  type: :runtime
36
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: active_support
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
37
48
  description: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
38
49
  email: travis@appoxy.com
39
50
  executables: []
@@ -57,26 +68,26 @@ files:
57
68
  - lib/simple_record/stats.rb
58
69
  - lib/simple_record/translations.rb
59
70
  - README.markdown
60
- - test/test_lobs.rb
61
- - test/paging_array_test.rb
62
- - test/test_marshalled.rb
63
- - test/test_dirty.rb
64
- - test/test_helpers.rb
65
- - test/test_base.rb
66
- - test/test_pagination.rb
71
+ - test/conversions.rb
72
+ - test/model_with_enc.rb
67
73
  - test/my_base_model.rb
68
74
  - test/my_child_model.rb
69
- - test/test_global_options.rb
70
- - test/test_results_array.rb
71
- - test/test_usage.rb
72
- - test/conversions.rb
75
+ - test/my_model.rb
76
+ - test/paging_array_test.rb
77
+ - test/temp.rb
73
78
  - test/temp_test.rb
79
+ - test/test_base.rb
80
+ - test/test_dirty.rb
74
81
  - test/test_encodings.rb
82
+ - test/test_global_options.rb
83
+ - test/test_helpers.rb
75
84
  - test/test_json.rb
85
+ - test/test_lobs.rb
86
+ - test/test_marshalled.rb
87
+ - test/test_pagination.rb
88
+ - test/test_results_array.rb
76
89
  - test/test_simple_record.rb
77
- - test/temp.rb
78
- - test/model_with_enc.rb
79
- - test/my_model.rb
90
+ - test/test_usage.rb
80
91
  has_rdoc: true
81
92
  homepage: http://github.com/appoxy/simple_record/
82
93
  licenses: []
@@ -91,7 +102,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
102
  requirements:
92
103
  - - ">="
93
104
  - !ruby/object:Gem::Version
94
- hash: 3
95
105
  segments:
96
106
  - 0
97
107
  version: "0"
@@ -100,7 +110,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
110
  requirements:
101
111
  - - ">="
102
112
  - !ruby/object:Gem::Version
103
- hash: 3
104
113
  segments:
105
114
  - 0
106
115
  version: "0"
@@ -112,23 +121,23 @@ signing_key:
112
121
  specification_version: 3
113
122
  summary: Drop in replacement for ActiveRecord to Amazon SimpleDB instead.
114
123
  test_files:
115
- - test/test_lobs.rb
116
- - test/paging_array_test.rb
117
- - test/test_marshalled.rb
118
- - test/test_dirty.rb
119
- - test/test_helpers.rb
120
- - test/test_base.rb
121
- - test/test_pagination.rb
124
+ - test/conversions.rb
125
+ - test/model_with_enc.rb
122
126
  - test/my_base_model.rb
123
127
  - test/my_child_model.rb
124
- - test/test_global_options.rb
125
- - test/test_results_array.rb
126
- - test/test_usage.rb
127
- - test/conversions.rb
128
+ - test/my_model.rb
129
+ - test/paging_array_test.rb
130
+ - test/temp.rb
128
131
  - test/temp_test.rb
132
+ - test/test_base.rb
133
+ - test/test_dirty.rb
129
134
  - test/test_encodings.rb
135
+ - test/test_global_options.rb
136
+ - test/test_helpers.rb
130
137
  - test/test_json.rb
138
+ - test/test_lobs.rb
139
+ - test/test_marshalled.rb
140
+ - test/test_pagination.rb
141
+ - test/test_results_array.rb
131
142
  - test/test_simple_record.rb
132
- - test/temp.rb
133
- - test/model_with_enc.rb
134
- - test/my_model.rb
143
+ - test/test_usage.rb