ant-mapper 0.0.2

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 (52) hide show
  1. data/CHANGE +6 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +25 -0
  4. data/ant.gemspec +48 -0
  5. data/data.tch +0 -0
  6. data/examples/account.rb +71 -0
  7. data/examples/data.tch +0 -0
  8. data/examples/light_cloud.yml +18 -0
  9. data/examples/user.rb +84 -0
  10. data/init.rb +4 -0
  11. data/lib/ant.rb +7 -0
  12. data/lib/ant_mapper.rb +10 -0
  13. data/lib/ant_mapper/adapters/light_cloud.rb +59 -0
  14. data/lib/ant_mapper/adapters/tokyo_cabinet.rb +42 -0
  15. data/lib/ant_mapper/adapters/tokyo_tyrant.rb +14 -0
  16. data/lib/ant_mapper/base.rb +367 -0
  17. data/lib/ant_mapper/callbacks.rb +180 -0
  18. data/lib/ant_mapper/observer.rb +180 -0
  19. data/lib/ant_mapper/validations.rb +687 -0
  20. data/lib/ant_support.rb +4 -0
  21. data/lib/ant_support/callbacks.rb +303 -0
  22. data/lib/ant_support/core_ext.rb +4 -0
  23. data/lib/ant_support/core_ext/array.rb +5 -0
  24. data/lib/ant_support/core_ext/array/extract_options.rb +20 -0
  25. data/lib/ant_support/core_ext/blank.rb +58 -0
  26. data/lib/ant_support/core_ext/class.rb +3 -0
  27. data/lib/ant_support/core_ext/class/attribute_accessors.rb +54 -0
  28. data/lib/ant_support/core_ext/class/inheritable_attributes.rb +140 -0
  29. data/lib/ant_support/core_ext/class/removal.rb +50 -0
  30. data/lib/ant_support/core_ext/duplicable.rb +43 -0
  31. data/lib/ant_support/core_ext/enumerable.rb +72 -0
  32. data/lib/ant_support/core_ext/hash.rb +6 -0
  33. data/lib/ant_support/core_ext/hash/keys.rb +52 -0
  34. data/lib/ant_support/core_ext/module.rb +16 -0
  35. data/lib/ant_support/core_ext/module/aliasing.rb +74 -0
  36. data/lib/ant_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  37. data/lib/ant_support/core_ext/module/attribute_accessors.rb +58 -0
  38. data/lib/ant_support/core_ext/object.rb +1 -0
  39. data/lib/ant_support/core_ext/object/extending.rb +80 -0
  40. data/lib/ant_support/core_ext/string.rb +7 -0
  41. data/lib/ant_support/core_ext/string/inflections.rb +51 -0
  42. data/spec/case/callbacks_observers_test.rb +38 -0
  43. data/spec/case/callbacks_test.rb +417 -0
  44. data/spec/case/create_object_test.rb +56 -0
  45. data/spec/case/set_class_name_test.rb +17 -0
  46. data/spec/case/validations_test.rb +1482 -0
  47. data/spec/helper.rb +15 -0
  48. data/spec/light_cloud.yml +18 -0
  49. data/spec/model/account.rb +3 -0
  50. data/spec/model/topic.rb +28 -0
  51. data/spec/model/user.rb +4 -0
  52. metadata +125 -0
@@ -0,0 +1,15 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
+
3
+ require 'test/unit'
4
+
5
+ def uses_mocha(description)
6
+ require 'rubygems'
7
+ require 'mocha'
8
+ yield
9
+ rescue LoadError
10
+ $stderr.puts "Skipping #{description} tests. `gem install mocha` and try again."
11
+ end
12
+
13
+ require File.join(File.dirname(__FILE__),'..','lib','ant')
14
+
15
+ AntMapper::Base.configure :LC, File.join(File.dirname(__FILE__),'light_cloud.yml')
@@ -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,3 @@
1
+ class Account < User
2
+ self.class_name = 'User'
3
+ end
@@ -0,0 +1,28 @@
1
+ class Topic < AntMapper::Base
2
+ self.class_name = 'User'
3
+ set_primary_key :user_key,:create_time,:title
4
+ set_attributes :title,:content,:create_time,:user_key,:posts
5
+
6
+ before_create do |object|
7
+ object.create_time = Time.now
8
+ end
9
+
10
+ validates_presence_of :title,:content
11
+
12
+ validate_on_create :title_is_wrong_create
13
+
14
+
15
+ def validate_on_create
16
+ if content == "Mismatch"
17
+ errors.add("title", "is Content Mismatch")
18
+ end
19
+ end
20
+
21
+ def title_is_wrong_create
22
+ errors.add("title", "is Wrong Create") if title == "Wrong Create"
23
+ end
24
+
25
+ def validate_on_update
26
+ errors.add("title", "is Wrong Update") if title == "Wrong Update"
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ class User < AntMapper::Base
2
+ set_primary_key :email
3
+ set_attributes :name,:email,:password
4
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ant-mapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - yalong zhang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-25 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mitchellh-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
+ description: "Ant\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"
36
+ email:
37
+ - yalong1976@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - ./CHANGE
46
+ - ./examples/account.rb
47
+ - ./examples/user.rb
48
+ - ./examples/data.tch
49
+ - ./examples/light_cloud.yml
50
+ - ./lib/ant_mapper.rb
51
+ - ./lib/ant_mapper/adapters/tokyo_tyrant.rb
52
+ - ./lib/ant_mapper/adapters/tokyo_cabinet.rb
53
+ - ./lib/ant_mapper/adapters/light_cloud.rb
54
+ - ./lib/ant_mapper/validations.rb
55
+ - ./lib/ant_mapper/base.rb
56
+ - ./lib/ant_mapper/observer.rb
57
+ - ./lib/ant_mapper/callbacks.rb
58
+ - ./lib/ant_support.rb
59
+ - ./lib/ant.rb
60
+ - ./lib/ant_support/core_ext.rb
61
+ - ./lib/ant_support/core_ext/blank.rb
62
+ - ./lib/ant_support/core_ext/string.rb
63
+ - ./lib/ant_support/core_ext/string/inflections.rb
64
+ - ./lib/ant_support/core_ext/duplicable.rb
65
+ - ./lib/ant_support/core_ext/module.rb
66
+ - ./lib/ant_support/core_ext/module/attribute_accessors.rb
67
+ - ./lib/ant_support/core_ext/module/attr_accessor_with_default.rb
68
+ - ./lib/ant_support/core_ext/module/aliasing.rb
69
+ - ./lib/ant_support/core_ext/hash/keys.rb
70
+ - ./lib/ant_support/core_ext/hash.rb
71
+ - ./lib/ant_support/core_ext/array.rb
72
+ - ./lib/ant_support/core_ext/object.rb
73
+ - ./lib/ant_support/core_ext/enumerable.rb
74
+ - ./lib/ant_support/core_ext/array/extract_options.rb
75
+ - ./lib/ant_support/core_ext/class.rb
76
+ - ./lib/ant_support/core_ext/object/extending.rb
77
+ - ./lib/ant_support/core_ext/class/attribute_accessors.rb
78
+ - ./lib/ant_support/core_ext/class/inheritable_attributes.rb
79
+ - ./lib/ant_support/core_ext/class/removal.rb
80
+ - ./lib/ant_support/callbacks.rb
81
+ - ./MIT-LICENSE
82
+ - ./ant.gemspec
83
+ - ./spec/helper.rb
84
+ - ./spec/model/account.rb
85
+ - ./spec/model/topic.rb
86
+ - ./spec/model/user.rb
87
+ - ./spec/light_cloud.yml
88
+ - ./spec/case/validations_test.rb
89
+ - ./spec/case/create_object_test.rb
90
+ - ./spec/case/set_class_name_test.rb
91
+ - ./spec/case/callbacks_observers_test.rb
92
+ - ./spec/case/callbacks_test.rb
93
+ - ./README
94
+ - ./init.rb
95
+ - ./data.tch
96
+ has_rdoc: true
97
+ homepage: http://www.tokyocabinet.com
98
+ licenses: []
99
+
100
+ post_install_message:
101
+ rdoc_options: []
102
+
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.6
110
+ version:
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ version:
117
+ requirements: []
118
+
119
+ rubyforge_project: ant-mapper
120
+ rubygems_version: 1.3.5
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: "Ant\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"
124
+ test_files: []
125
+