activeobject 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/CHANGE +10 -0
  2. data/Interface_desc +21 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +72 -0
  5. data/Rakefile.rb +9 -0
  6. data/active-object.gemspec +50 -0
  7. data/examples/account.rb +69 -0
  8. data/examples/data.tch +0 -0
  9. data/examples/light_cloud.yml +18 -0
  10. data/examples/test.rb +3 -0
  11. data/examples/user.rb +112 -0
  12. data/init.rb +4 -0
  13. data/lib/active-object.rb +23 -0
  14. data/lib/active_object/adapters/light_cloud.rb +40 -0
  15. data/lib/active_object/adapters/tokyo_cabinet.rb +48 -0
  16. data/lib/active_object/adapters/tokyo_tyrant.rb +14 -0
  17. data/lib/active_object/associations.rb +200 -0
  18. data/lib/active_object/base.rb +415 -0
  19. data/lib/active_object/callbacks.rb +180 -0
  20. data/lib/active_object/observer.rb +180 -0
  21. data/lib/active_object/serialization.rb +99 -0
  22. data/lib/active_object/serializers/json_serializer.rb +75 -0
  23. data/lib/active_object/serializers/xml_serializer.rb +325 -0
  24. data/lib/active_object/validations.rb +687 -0
  25. data/lib/active_support/callbacks.rb +303 -0
  26. data/lib/active_support/core_ext/array/access.rb +53 -0
  27. data/lib/active_support/core_ext/array/conversions.rb +183 -0
  28. data/lib/active_support/core_ext/array/extract_options.rb +20 -0
  29. data/lib/active_support/core_ext/array/grouping.rb +106 -0
  30. data/lib/active_support/core_ext/array/random_access.rb +12 -0
  31. data/lib/active_support/core_ext/array.rb +13 -0
  32. data/lib/active_support/core_ext/blank.rb +58 -0
  33. data/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
  34. data/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  35. data/lib/active_support/core_ext/class/removal.rb +50 -0
  36. data/lib/active_support/core_ext/class.rb +3 -0
  37. data/lib/active_support/core_ext/duplicable.rb +43 -0
  38. data/lib/active_support/core_ext/enumerable.rb +72 -0
  39. data/lib/active_support/core_ext/hash/conversions.rb +259 -0
  40. data/lib/active_support/core_ext/hash/keys.rb +52 -0
  41. data/lib/active_support/core_ext/hash.rb +8 -0
  42. data/lib/active_support/core_ext/module/aliasing.rb +74 -0
  43. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  44. data/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
  45. data/lib/active_support/core_ext/module.rb +16 -0
  46. data/lib/active_support/core_ext/object/conversions.rb +14 -0
  47. data/lib/active_support/core_ext/object/extending.rb +80 -0
  48. data/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  49. data/lib/active_support/core_ext/object/metaclass.rb +13 -0
  50. data/lib/active_support/core_ext/object/misc.rb +43 -0
  51. data/lib/active_support/core_ext/object.rb +5 -0
  52. data/lib/active_support/core_ext/string/inflections.rb +167 -0
  53. data/lib/active_support/core_ext/string.rb +7 -0
  54. data/lib/active_support/core_ext.rb +4 -0
  55. data/lib/active_support/inflections.rb +55 -0
  56. data/lib/active_support/inflector.rb +348 -0
  57. data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  58. data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  59. data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  60. data/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  61. data/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  62. data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  63. data/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  64. data/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  65. data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
  66. data/lib/active_support/vendor.rb +14 -0
  67. data/lib/active_support.rb +6 -0
  68. data/spec/case/association_test.rb +97 -0
  69. data/spec/case/base_test.rb +74 -0
  70. data/spec/case/callbacks_observers_test.rb +38 -0
  71. data/spec/case/callbacks_test.rb +424 -0
  72. data/spec/case/serialization_test.rb +87 -0
  73. data/spec/case/validations_test.rb +1482 -0
  74. data/spec/data.tch +0 -0
  75. data/spec/helper.rb +15 -0
  76. data/spec/light_cloud.yml +18 -0
  77. data/spec/model/account.rb +4 -0
  78. data/spec/model/topic.rb +26 -0
  79. data/spec/model/user.rb +8 -0
  80. metadata +173 -0
data/spec/data.tch ADDED
Binary file
data/spec/helper.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'pathname'
2
+
3
+ require File.join(File.dirname(Pathname.new(__FILE__).realpath), '..','lib','active-object')
4
+
5
+ require 'test/unit'
6
+
7
+ def uses_mocha(description)
8
+ require 'rubygems'
9
+ require 'mocha'
10
+ yield
11
+ rescue LoadError
12
+ $stderr.puts "Skipping #{description} tests. `gem install mocha` and try again."
13
+ end
14
+
15
+ ActiveObject::Base.configure :TC, File.join(File.dirname(Pathname.new(__FILE__).realpath),'data.tch')
@@ -0,0 +1,18 @@
1
+ # LightCloud的配置文件,用于初始化LightCloud
2
+ # 示例
3
+ # user:
4
+ # lookup_one:
5
+ # - 127.0.0.1:41401
6
+ # - 127.0.0.1:41402
7
+ # storage_one:
8
+ # - 127.0.0.1:44401
9
+ # - 127.0.0.1:44402
10
+ #
11
+
12
+ user:
13
+ lookup_one:
14
+ - 127.0.0.1:30001
15
+ - 127.0.0.1:33001
16
+ storage_one:
17
+ - 127.0.0.1:20001
18
+ - 127.0.0.1:24001
@@ -0,0 +1,4 @@
1
+ class Account < ActiveObject::Base
2
+ primary_key :email
3
+ attribute :name,:email,:password
4
+ end
@@ -0,0 +1,26 @@
1
+ class Topic < ActiveObject::Base
2
+ attribute :title,:content,:create_time,:user_key,:posts
3
+
4
+ before_create do |object|
5
+ object.create_time = Time.now
6
+ end
7
+
8
+ validates_presence_of :title,:content
9
+
10
+ validate_on_create :title_is_wrong_create
11
+
12
+
13
+ def validate_on_create
14
+ if content == "Mismatch"
15
+ errors.add("title", "is Content Mismatch")
16
+ end
17
+ end
18
+
19
+ def title_is_wrong_create
20
+ errors.add("title", "is Wrong Create") if title == "Wrong Create"
21
+ end
22
+
23
+ def validate_on_update
24
+ errors.add("title", "is Wrong Update") if title == "Wrong Update"
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ class User < ActiveObject::Base
2
+ primary_key :email
3
+ attribute :name,:email,:password
4
+
5
+ has_many :friends,:class_name=>"User"
6
+
7
+ has_one :wife, :class_name=>"User"
8
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeobject
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - yalong zhang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-25 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: lightcloud
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rufus-tokyo
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: uuid
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: "Active Object\xE6\x98\xAF\xE7\x94\xA8\xE6\x9D\xA5\xE8\xAE\xBF\xE9\x97\xAELightCloud/TokyoCabinet/TokyoTyrant\xE7\x9A\x84\xE5\xB7\xA5\xE5\x85\xB7\xEF\xBC\x8C\xE5\xAE\x9E\xE7\x8E\xB0\xE4\xBA\x86\xE6\x8C\x81\xE4\xB9\x85\xE5\x8C\x96\xE6\x95\xB0\xE6\x8D\xAE\xE4\xB8\x8E\xE5\xAF\xB9\xE8\xB1\xA1\xE7\x9A\x84\xE6\x98\xA0\xE5\xB0\x84\xE3\x80\x82 \xE5\xAE\x83\xE7\xB1\xBB\xE4\xBC\xBC\xE4\xBA\x8EActiveRecord\xEF\xBC\x8C\xE6\x8F\x90\xE4\xBE\x9B\xE4\xB8\x80\xE7\xBB\x84\xE8\xAE\xBF\xE9\x97\xAELightCloud/TokyoCabinet/TokyoTyrant\xE7\x9A\x84\xE6\x96\xB9\xE6\xB3\x95\xE4\xBB\xA5\xE5\x8F\x8A\xE9\xAA\x8C\xE8\xAF\x81\xE8\xA7\x84\xE5\x88\x99\xE3\x80\x81\xE5\x9B\x9E\xE8\xB0\x83\xE5\x87\xBD\xE6\x95\xB0\xE5\x92\x8C\xE8\xA7\x82\xE5\xAF\x9F\xE5\x99\xA8\xE3\x80\x82"
56
+ email:
57
+ - yalong1976@gmail.com
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files: []
63
+
64
+ files:
65
+ - ./CHANGE
66
+ - ./examples/account.rb
67
+ - ./examples/user.rb
68
+ - ./examples/test.rb
69
+ - ./examples/data.tch
70
+ - ./examples/light_cloud.yml
71
+ - ./lib/active_object/serializers/xml_serializer.rb
72
+ - ./lib/active_object/serializers/json_serializer.rb
73
+ - ./lib/active_object/adapters/tokyo_tyrant.rb
74
+ - ./lib/active_object/adapters/tokyo_cabinet.rb
75
+ - ./lib/active_object/adapters/light_cloud.rb
76
+ - ./lib/active_object/validations.rb
77
+ - ./lib/active_object/base.rb
78
+ - ./lib/active_object/observer.rb
79
+ - ./lib/active_object/serialization.rb
80
+ - ./lib/active_object/associations.rb
81
+ - ./lib/active_object/callbacks.rb
82
+ - ./lib/active-object.rb
83
+ - ./lib/active_support.rb
84
+ - ./lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb
85
+ - ./lib/active_support/vendor/builder-2.1.2/builder.rb
86
+ - ./lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
87
+ - ./lib/active_support/vendor/builder-2.1.2/builder/css.rb
88
+ - ./lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb
89
+ - ./lib/active_support/vendor/builder-2.1.2/builder/xchar.rb
90
+ - ./lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb
91
+ - ./lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb
92
+ - ./lib/active_support/vendor/builder-2.1.2/blankslate.rb
93
+ - ./lib/active_support/core_ext.rb
94
+ - ./lib/active_support/inflector.rb
95
+ - ./lib/active_support/vendor.rb
96
+ - ./lib/active_support/inflections.rb
97
+ - ./lib/active_support/core_ext/blank.rb
98
+ - ./lib/active_support/core_ext/string.rb
99
+ - ./lib/active_support/core_ext/string/inflections.rb
100
+ - ./lib/active_support/core_ext/duplicable.rb
101
+ - ./lib/active_support/core_ext/module.rb
102
+ - ./lib/active_support/core_ext/module/attribute_accessors.rb
103
+ - ./lib/active_support/core_ext/module/attr_accessor_with_default.rb
104
+ - ./lib/active_support/core_ext/module/aliasing.rb
105
+ - ./lib/active_support/core_ext/hash/conversions.rb
106
+ - ./lib/active_support/core_ext/hash/keys.rb
107
+ - ./lib/active_support/core_ext/hash.rb
108
+ - ./lib/active_support/core_ext/array.rb
109
+ - ./lib/active_support/core_ext/object.rb
110
+ - ./lib/active_support/core_ext/enumerable.rb
111
+ - ./lib/active_support/core_ext/array/grouping.rb
112
+ - ./lib/active_support/core_ext/array/conversions.rb
113
+ - ./lib/active_support/core_ext/array/extract_options.rb
114
+ - ./lib/active_support/core_ext/array/access.rb
115
+ - ./lib/active_support/core_ext/array/random_access.rb
116
+ - ./lib/active_support/core_ext/class.rb
117
+ - ./lib/active_support/core_ext/object/metaclass.rb
118
+ - ./lib/active_support/core_ext/object/extending.rb
119
+ - ./lib/active_support/core_ext/object/instance_variables.rb
120
+ - ./lib/active_support/core_ext/object/conversions.rb
121
+ - ./lib/active_support/core_ext/object/misc.rb
122
+ - ./lib/active_support/core_ext/class/attribute_accessors.rb
123
+ - ./lib/active_support/core_ext/class/inheritable_attributes.rb
124
+ - ./lib/active_support/core_ext/class/removal.rb
125
+ - ./lib/active_support/callbacks.rb
126
+ - ./MIT-LICENSE
127
+ - ./spec/helper.rb
128
+ - ./spec/model/account.rb
129
+ - ./spec/model/topic.rb
130
+ - ./spec/model/user.rb
131
+ - ./spec/data.tch
132
+ - ./spec/light_cloud.yml
133
+ - ./spec/case/validations_test.rb
134
+ - ./spec/case/base_test.rb
135
+ - ./spec/case/association_test.rb
136
+ - ./spec/case/callbacks_observers_test.rb
137
+ - ./spec/case/callbacks_test.rb
138
+ - ./spec/case/serialization_test.rb
139
+ - ./Interface_desc
140
+ - ./README
141
+ - ./active-object.gemspec
142
+ - ./init.rb
143
+ - ./Rakefile.rb
144
+ has_rdoc: true
145
+ homepage: http://www.tokyocabinet.com
146
+ licenses: []
147
+
148
+ post_install_message:
149
+ rdoc_options: []
150
+
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 1.8.6
158
+ version:
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: "0"
164
+ version:
165
+ requirements: []
166
+
167
+ rubyforge_project: activeobject
168
+ rubygems_version: 1.3.5
169
+ signing_key:
170
+ specification_version: 3
171
+ summary: "Active Object\xE6\x98\xAF\xE7\x94\xA8\xE6\x9D\xA5\xE8\xAE\xBF\xE9\x97\xAELightCloud/TokyoCabinet/TokyoTyrant\xE7\x9A\x84\xE5\xB7\xA5\xE5\x85\xB7\xEF\xBC\x8C\xE5\xAE\x9E\xE7\x8E\xB0\xE4\xBA\x86\xE6\x8C\x81\xE4\xB9\x85\xE5\x8C\x96\xE6\x95\xB0\xE6\x8D\xAE\xE4\xB8\x8E\xE5\xAF\xB9\xE8\xB1\xA1\xE7\x9A\x84\xE6\x98\xA0\xE5\xB0\x84\xE3\x80\x82 \xE5\xAE\x83\xE7\xB1\xBB\xE4\xBC\xBC\xE4\xBA\x8EActiveRecord\xEF\xBC\x8C\xE6\x8F\x90\xE4\xBE\x9B\xE4\xB8\x80\xE7\xBB\x84\xE8\xAE\xBF\xE9\x97\xAELightCloud/TokyoCabinet/TokyoTyrant\xE7\x9A\x84\xE6\x96\xB9\xE6\xB3\x95\xE4\xBB\xA5\xE5\x8F\x8A\xE9\xAA\x8C\xE8\xAF\x81\xE8\xA7\x84\xE5\x88\x99\xE3\x80\x81\xE5\x9B\x9E\xE8\xB0\x83\xE5\x87\xBD\xE6\x95\xB0\xE5\x92\x8C\xE8\xA7\x82\xE5\xAF\x9F\xE5\x99\xA8\xE3\x80\x82"
172
+ test_files: []
173
+