jmonteiro-mongo_mapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +38 -0
  4. data/Rakefile +55 -0
  5. data/VERSION +1 -0
  6. data/bin/mmconsole +60 -0
  7. data/jmonteiro-mongo_mapper.gemspec +195 -0
  8. data/lib/mongo_mapper.rb +128 -0
  9. data/lib/mongo_mapper/descendant_appends.rb +44 -0
  10. data/lib/mongo_mapper/document.rb +402 -0
  11. data/lib/mongo_mapper/dynamic_finder.rb +74 -0
  12. data/lib/mongo_mapper/embedded_document.rb +61 -0
  13. data/lib/mongo_mapper/finder_options.rb +127 -0
  14. data/lib/mongo_mapper/plugins.rb +19 -0
  15. data/lib/mongo_mapper/plugins/associations.rb +104 -0
  16. data/lib/mongo_mapper/plugins/associations/base.rb +121 -0
  17. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +28 -0
  18. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +23 -0
  19. data/lib/mongo_mapper/plugins/associations/collection.rb +21 -0
  20. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +49 -0
  21. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +139 -0
  22. data/lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb +28 -0
  23. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +117 -0
  24. data/lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb +31 -0
  25. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +23 -0
  26. data/lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb +13 -0
  27. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +66 -0
  28. data/lib/mongo_mapper/plugins/associations/proxy.rb +118 -0
  29. data/lib/mongo_mapper/plugins/callbacks.rb +65 -0
  30. data/lib/mongo_mapper/plugins/clone.rb +13 -0
  31. data/lib/mongo_mapper/plugins/descendants.rb +16 -0
  32. data/lib/mongo_mapper/plugins/dirty.rb +119 -0
  33. data/lib/mongo_mapper/plugins/equality.rb +11 -0
  34. data/lib/mongo_mapper/plugins/identity_map.rb +66 -0
  35. data/lib/mongo_mapper/plugins/inspect.rb +14 -0
  36. data/lib/mongo_mapper/plugins/keys.rb +295 -0
  37. data/lib/mongo_mapper/plugins/logger.rb +17 -0
  38. data/lib/mongo_mapper/plugins/pagination.rb +85 -0
  39. data/lib/mongo_mapper/plugins/protected.rb +31 -0
  40. data/lib/mongo_mapper/plugins/rails.rb +80 -0
  41. data/lib/mongo_mapper/plugins/serialization.rb +109 -0
  42. data/lib/mongo_mapper/plugins/validations.rb +48 -0
  43. data/lib/mongo_mapper/support.rb +213 -0
  44. data/performance/read_write.rb +52 -0
  45. data/specs.watchr +51 -0
  46. data/test/NOTE_ON_TESTING +1 -0
  47. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +63 -0
  48. data/test/functional/associations/test_belongs_to_proxy.rb +93 -0
  49. data/test/functional/associations/test_in_array_proxy.rb +309 -0
  50. data/test/functional/associations/test_many_documents_as_proxy.rb +246 -0
  51. data/test/functional/associations/test_many_documents_proxy.rb +437 -0
  52. data/test/functional/associations/test_many_embedded_polymorphic_proxy.rb +175 -0
  53. data/test/functional/associations/test_many_embedded_proxy.rb +216 -0
  54. data/test/functional/associations/test_many_polymorphic_proxy.rb +340 -0
  55. data/test/functional/associations/test_one_proxy.rb +149 -0
  56. data/test/functional/test_associations.rb +44 -0
  57. data/test/functional/test_binary.rb +27 -0
  58. data/test/functional/test_callbacks.rb +81 -0
  59. data/test/functional/test_dirty.rb +156 -0
  60. data/test/functional/test_document.rb +1171 -0
  61. data/test/functional/test_embedded_document.rb +125 -0
  62. data/test/functional/test_identity_map.rb +233 -0
  63. data/test/functional/test_logger.rb +20 -0
  64. data/test/functional/test_modifiers.rb +252 -0
  65. data/test/functional/test_pagination.rb +93 -0
  66. data/test/functional/test_protected.rb +41 -0
  67. data/test/functional/test_string_id_compatibility.rb +67 -0
  68. data/test/functional/test_validations.rb +329 -0
  69. data/test/models.rb +232 -0
  70. data/test/support/custom_matchers.rb +55 -0
  71. data/test/support/timing.rb +16 -0
  72. data/test/test_helper.rb +60 -0
  73. data/test/unit/associations/test_base.rb +207 -0
  74. data/test/unit/associations/test_proxy.rb +103 -0
  75. data/test/unit/serializers/test_json_serializer.rb +189 -0
  76. data/test/unit/test_descendant_appends.rb +71 -0
  77. data/test/unit/test_document.rb +203 -0
  78. data/test/unit/test_dynamic_finder.rb +125 -0
  79. data/test/unit/test_embedded_document.rb +628 -0
  80. data/test/unit/test_finder_options.rb +325 -0
  81. data/test/unit/test_keys.rb +169 -0
  82. data/test/unit/test_mongo_mapper.rb +65 -0
  83. data/test/unit/test_pagination.rb +127 -0
  84. data/test/unit/test_plugins.rb +42 -0
  85. data/test/unit/test_rails.rb +139 -0
  86. data/test/unit/test_rails_compatibility.rb +42 -0
  87. data/test/unit/test_serialization.rb +51 -0
  88. data/test/unit/test_support.rb +350 -0
  89. data/test/unit/test_time_zones.rb +39 -0
  90. data/test/unit/test_validations.rb +492 -0
  91. metadata +260 -0
@@ -0,0 +1,10 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *~
7
+ *.gem
8
+ tmp
9
+ .yardoc
10
+ doc/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ = MongoMapper
2
+
3
+ Awesome gem for modeling your domain and storing it in mongo.
4
+
5
+ Releases are tagged on github and released on gemcutter. Master is pushed to whenever I add a patch or a new feature, but I do not release a new gem version each time I push.
6
+
7
+ == Note on Patches/Pull Requests
8
+
9
+ * Fork the project.
10
+ * Make your feature addition or bug fix.
11
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
12
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Install
16
+
17
+ $ gem install mongo_mapper
18
+
19
+ == Dependencies
20
+
21
+ * ActiveSupport (typically the latest version)
22
+ * Mongo Ruby Driver (mongo)
23
+ * My fork of the validatable gem (jnunemaker-validatable)
24
+
25
+ == Documentation
26
+
27
+ Documentation is lacking right now because if you can't look through the code right now and feel comfortable, this is probably too young for you to use. Wait til it stabilizes a bit more.
28
+
29
+ http://groups.google.com/group/mongomapper
30
+
31
+ == More Info
32
+
33
+ * http://www.mongodb.org/
34
+ * http://github.com/mongodb/mongo-ruby-driver/
35
+
36
+ == Copyright
37
+
38
+ Copyright (c) 2009 John Nunemaker. See LICENSE for details.
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+ require 'yard'
5
+ require 'yard/rake/yardoc_task'
6
+
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "jmonteiro-mongo_mapper"
9
+ gem.summary = %Q{Awesome gem for modeling your domain and storing it in mongo}
10
+ gem.email = ["nunemaker@gmail.com", "julio@monteiro.eti.br"]
11
+ gem.homepage = "http://github.com/jmonteiro/mongomapper"
12
+ gem.authors = ["John Nunemaker", "Julio Monteiro"]
13
+
14
+ gem.add_dependency('activesupport', '>= 2.3')
15
+ gem.add_dependency('mongo', '0.18.2')
16
+ gem.add_dependency('jnunemaker-validatable', '1.8.1')
17
+
18
+ gem.add_development_dependency('jnunemaker-matchy', '0.4.0')
19
+ gem.add_development_dependency('shoulda', '2.10.2')
20
+ gem.add_development_dependency('timecop', '0.3.1')
21
+ gem.add_development_dependency('mocha', '0.9.8')
22
+ end
23
+
24
+ Jeweler::GemcutterTasks.new
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'test'
29
+ test.ruby_opts << '-rubygems'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ namespace :test do
35
+ Rake::TestTask.new(:units) do |test|
36
+ test.libs << 'test'
37
+ test.ruby_opts << '-rubygems'
38
+ test.pattern = 'test/unit/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+
42
+ Rake::TestTask.new(:functionals) do |test|
43
+ test.libs << 'test'
44
+ test.ruby_opts << '-rubygems'
45
+ test.pattern = 'test/functional/**/test_*.rb'
46
+ test.verbose = true
47
+ end
48
+ end
49
+
50
+ task :default => :test
51
+ task :test => :check_dependencies
52
+
53
+ YARD::Rake::YardocTask.new(:doc) do |t|
54
+ t.options = ["--legacy"] if RUBY_VERSION < "1.9.0"
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
3
+
4
+ begin
5
+ require 'mongo_mapper'
6
+ require 'irb'
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ retry
10
+ end
11
+
12
+ IRB.setup(nil)
13
+ irb = IRB::Irb.new
14
+
15
+ IRB.conf[:MAIN_CONTEXT] = irb.context
16
+
17
+ irb.context.evaluate("require 'irb/completion'", 0)
18
+ irb.context.evaluate(%@
19
+ include MongoMapper
20
+
21
+ MongoMapper.database = "mmtest"
22
+ $db = MongoMapper.database
23
+
24
+ @, 0)
25
+
26
+ puts %@
27
+ Welcome to the MongoMapper Console!
28
+
29
+ Example 1:
30
+ things = $db.collection("things")
31
+ things.insert("name" => "Raw Thing")
32
+ things.insert("name" => "Another Thing", "date" => Time.now)
33
+
34
+ cursor = things.find("name" => "Raw Thing")
35
+ puts cursor.next_object.inspect
36
+
37
+ Example 2:
38
+ class Thing
39
+ include MongoMapper::Document
40
+ key :name, String, :required => true
41
+ key :date, Time
42
+ end
43
+
44
+ thing = Thing.new
45
+ thing.name = "My thing"
46
+ thing.date = Time.now
47
+ thing.save
48
+
49
+ all_things = Thing.all
50
+ puts all_things.map { |object| object.name }.inspect
51
+ @
52
+
53
+ trap("SIGINT") do
54
+ irb.signal_handle
55
+ end
56
+
57
+ catch(:IRB_EXIT) do
58
+ irb.eval_input
59
+ end
60
+
@@ -0,0 +1,195 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{jmonteiro-mongo_mapper}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["John Nunemaker", "Julio Monteiro"]
12
+ s.date = %q{2010-01-13}
13
+ s.default_executable = %q{mmconsole}
14
+ s.email = ["nunemaker@gmail.com", "julio@monteiro.eti.br"]
15
+ s.executables = ["mmconsole"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/mmconsole",
27
+ "jmonteiro-mongo_mapper.gemspec",
28
+ "lib/mongo_mapper.rb",
29
+ "lib/mongo_mapper/descendant_appends.rb",
30
+ "lib/mongo_mapper/document.rb",
31
+ "lib/mongo_mapper/dynamic_finder.rb",
32
+ "lib/mongo_mapper/embedded_document.rb",
33
+ "lib/mongo_mapper/finder_options.rb",
34
+ "lib/mongo_mapper/plugins.rb",
35
+ "lib/mongo_mapper/plugins/associations.rb",
36
+ "lib/mongo_mapper/plugins/associations/base.rb",
37
+ "lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb",
38
+ "lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb",
39
+ "lib/mongo_mapper/plugins/associations/collection.rb",
40
+ "lib/mongo_mapper/plugins/associations/embedded_collection.rb",
41
+ "lib/mongo_mapper/plugins/associations/in_array_proxy.rb",
42
+ "lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb",
43
+ "lib/mongo_mapper/plugins/associations/many_documents_proxy.rb",
44
+ "lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb",
45
+ "lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb",
46
+ "lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb",
47
+ "lib/mongo_mapper/plugins/associations/one_proxy.rb",
48
+ "lib/mongo_mapper/plugins/associations/proxy.rb",
49
+ "lib/mongo_mapper/plugins/callbacks.rb",
50
+ "lib/mongo_mapper/plugins/clone.rb",
51
+ "lib/mongo_mapper/plugins/descendants.rb",
52
+ "lib/mongo_mapper/plugins/dirty.rb",
53
+ "lib/mongo_mapper/plugins/equality.rb",
54
+ "lib/mongo_mapper/plugins/identity_map.rb",
55
+ "lib/mongo_mapper/plugins/inspect.rb",
56
+ "lib/mongo_mapper/plugins/keys.rb",
57
+ "lib/mongo_mapper/plugins/logger.rb",
58
+ "lib/mongo_mapper/plugins/pagination.rb",
59
+ "lib/mongo_mapper/plugins/protected.rb",
60
+ "lib/mongo_mapper/plugins/rails.rb",
61
+ "lib/mongo_mapper/plugins/serialization.rb",
62
+ "lib/mongo_mapper/plugins/validations.rb",
63
+ "lib/mongo_mapper/support.rb",
64
+ "performance/read_write.rb",
65
+ "specs.watchr",
66
+ "test/NOTE_ON_TESTING",
67
+ "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
68
+ "test/functional/associations/test_belongs_to_proxy.rb",
69
+ "test/functional/associations/test_in_array_proxy.rb",
70
+ "test/functional/associations/test_many_documents_as_proxy.rb",
71
+ "test/functional/associations/test_many_documents_proxy.rb",
72
+ "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
73
+ "test/functional/associations/test_many_embedded_proxy.rb",
74
+ "test/functional/associations/test_many_polymorphic_proxy.rb",
75
+ "test/functional/associations/test_one_proxy.rb",
76
+ "test/functional/test_associations.rb",
77
+ "test/functional/test_binary.rb",
78
+ "test/functional/test_callbacks.rb",
79
+ "test/functional/test_dirty.rb",
80
+ "test/functional/test_document.rb",
81
+ "test/functional/test_embedded_document.rb",
82
+ "test/functional/test_identity_map.rb",
83
+ "test/functional/test_logger.rb",
84
+ "test/functional/test_modifiers.rb",
85
+ "test/functional/test_pagination.rb",
86
+ "test/functional/test_protected.rb",
87
+ "test/functional/test_string_id_compatibility.rb",
88
+ "test/functional/test_validations.rb",
89
+ "test/models.rb",
90
+ "test/support/custom_matchers.rb",
91
+ "test/support/timing.rb",
92
+ "test/test_helper.rb",
93
+ "test/unit/associations/test_base.rb",
94
+ "test/unit/associations/test_proxy.rb",
95
+ "test/unit/serializers/test_json_serializer.rb",
96
+ "test/unit/test_descendant_appends.rb",
97
+ "test/unit/test_document.rb",
98
+ "test/unit/test_dynamic_finder.rb",
99
+ "test/unit/test_embedded_document.rb",
100
+ "test/unit/test_finder_options.rb",
101
+ "test/unit/test_keys.rb",
102
+ "test/unit/test_mongo_mapper.rb",
103
+ "test/unit/test_pagination.rb",
104
+ "test/unit/test_plugins.rb",
105
+ "test/unit/test_rails.rb",
106
+ "test/unit/test_rails_compatibility.rb",
107
+ "test/unit/test_serialization.rb",
108
+ "test/unit/test_support.rb",
109
+ "test/unit/test_time_zones.rb",
110
+ "test/unit/test_validations.rb"
111
+ ]
112
+ s.homepage = %q{http://github.com/jmonteiro/mongomapper}
113
+ s.rdoc_options = ["--charset=UTF-8"]
114
+ s.require_paths = ["lib"]
115
+ s.rubygems_version = %q{1.3.5}
116
+ s.summary = %q{Awesome gem for modeling your domain and storing it in mongo}
117
+ s.test_files = [
118
+ "test/functional/associations/test_belongs_to_polymorphic_proxy.rb",
119
+ "test/functional/associations/test_belongs_to_proxy.rb",
120
+ "test/functional/associations/test_in_array_proxy.rb",
121
+ "test/functional/associations/test_many_documents_as_proxy.rb",
122
+ "test/functional/associations/test_many_documents_proxy.rb",
123
+ "test/functional/associations/test_many_embedded_polymorphic_proxy.rb",
124
+ "test/functional/associations/test_many_embedded_proxy.rb",
125
+ "test/functional/associations/test_many_polymorphic_proxy.rb",
126
+ "test/functional/associations/test_one_proxy.rb",
127
+ "test/functional/test_associations.rb",
128
+ "test/functional/test_binary.rb",
129
+ "test/functional/test_callbacks.rb",
130
+ "test/functional/test_dirty.rb",
131
+ "test/functional/test_document.rb",
132
+ "test/functional/test_embedded_document.rb",
133
+ "test/functional/test_identity_map.rb",
134
+ "test/functional/test_logger.rb",
135
+ "test/functional/test_modifiers.rb",
136
+ "test/functional/test_pagination.rb",
137
+ "test/functional/test_protected.rb",
138
+ "test/functional/test_string_id_compatibility.rb",
139
+ "test/functional/test_validations.rb",
140
+ "test/models.rb",
141
+ "test/support/custom_matchers.rb",
142
+ "test/support/timing.rb",
143
+ "test/test_helper.rb",
144
+ "test/unit/associations/test_base.rb",
145
+ "test/unit/associations/test_proxy.rb",
146
+ "test/unit/serializers/test_json_serializer.rb",
147
+ "test/unit/test_descendant_appends.rb",
148
+ "test/unit/test_document.rb",
149
+ "test/unit/test_dynamic_finder.rb",
150
+ "test/unit/test_embedded_document.rb",
151
+ "test/unit/test_finder_options.rb",
152
+ "test/unit/test_keys.rb",
153
+ "test/unit/test_mongo_mapper.rb",
154
+ "test/unit/test_pagination.rb",
155
+ "test/unit/test_plugins.rb",
156
+ "test/unit/test_rails.rb",
157
+ "test/unit/test_rails_compatibility.rb",
158
+ "test/unit/test_serialization.rb",
159
+ "test/unit/test_support.rb",
160
+ "test/unit/test_time_zones.rb",
161
+ "test/unit/test_validations.rb"
162
+ ]
163
+
164
+ if s.respond_to? :specification_version then
165
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
166
+ s.specification_version = 3
167
+
168
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
169
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3"])
170
+ s.add_runtime_dependency(%q<mongo>, ["= 0.18.2"])
171
+ s.add_runtime_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
172
+ s.add_development_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
173
+ s.add_development_dependency(%q<shoulda>, ["= 2.10.2"])
174
+ s.add_development_dependency(%q<timecop>, ["= 0.3.1"])
175
+ s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
176
+ else
177
+ s.add_dependency(%q<activesupport>, [">= 2.3"])
178
+ s.add_dependency(%q<mongo>, ["= 0.18.2"])
179
+ s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
180
+ s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
181
+ s.add_dependency(%q<shoulda>, ["= 2.10.2"])
182
+ s.add_dependency(%q<timecop>, ["= 0.3.1"])
183
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
184
+ end
185
+ else
186
+ s.add_dependency(%q<activesupport>, [">= 2.3"])
187
+ s.add_dependency(%q<mongo>, ["= 0.18.2"])
188
+ s.add_dependency(%q<jnunemaker-validatable>, ["= 1.8.1"])
189
+ s.add_dependency(%q<jnunemaker-matchy>, ["= 0.4.0"])
190
+ s.add_dependency(%q<shoulda>, ["= 2.10.2"])
191
+ s.add_dependency(%q<timecop>, ["= 0.3.1"])
192
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
193
+ end
194
+ end
195
+
@@ -0,0 +1,128 @@
1
+ require 'set'
2
+
3
+ # if Gem is defined i'll assume you are using rubygems and lock specific versions
4
+ # call me crazy but a plain old require will just get the latest version you have installed
5
+ # so i want to make sure that if you are using gems you do in fact have the correct versions
6
+ # if there is a better way to do this, please enlighten me!
7
+ if self.class.const_defined?(:Gem)
8
+ gem 'activesupport', '>= 2.3'
9
+ gem 'mongo', '0.18.2'
10
+ gem 'jnunemaker-validatable', '1.8.1'
11
+ end
12
+
13
+ require 'active_support'
14
+ require 'mongo'
15
+ require 'validatable'
16
+
17
+ module MongoMapper
18
+ # generic MM error
19
+ class MongoMapperError < StandardError; end
20
+
21
+ # raised when key expected to exist but not found
22
+ class KeyNotFound < MongoMapperError; end
23
+
24
+ # raised when document expected but not found
25
+ class DocumentNotFound < MongoMapperError; end
26
+
27
+ # raised when document not valid and using !
28
+ class DocumentNotValid < MongoMapperError
29
+ def initialize(document)
30
+ super("Validation failed: #{document.errors.full_messages.join(", ")}")
31
+ end
32
+ end
33
+
34
+ # @api public
35
+ def self.connection
36
+ @@connection ||= Mongo::Connection.new
37
+ end
38
+
39
+ # @api public
40
+ def self.connection=(new_connection)
41
+ @@connection = new_connection
42
+ end
43
+
44
+ # @api public
45
+ def self.logger
46
+ connection.logger
47
+ end
48
+
49
+ # @api public
50
+ def self.database=(name)
51
+ @@database = nil
52
+ @@database_name = name
53
+ end
54
+
55
+ # @api public
56
+ def self.database
57
+ if @@database_name.blank?
58
+ raise 'You forgot to set the default database name: MongoMapper.database = "foobar"'
59
+ end
60
+
61
+ @@database ||= MongoMapper.connection.db(@@database_name)
62
+ end
63
+
64
+ # @api private
65
+ def self.ensured_indexes
66
+ @@ensured_indexes ||= []
67
+ end
68
+
69
+ # @api private
70
+ def self.ensured_indexes=(value)
71
+ @@ensured_indexes = value
72
+ end
73
+
74
+ # @api private
75
+ def self.ensure_index(klass, keys, options={})
76
+ ensured_indexes << {:klass => klass, :keys => keys, :options => options}
77
+ end
78
+
79
+ # @api public
80
+ def self.ensure_indexes!
81
+ ensured_indexes.each do |index|
82
+ unique = index[:options].delete(:unique)
83
+ index[:klass].collection.create_index(index[:keys], unique)
84
+ end
85
+ end
86
+
87
+ # @api private
88
+ def self.use_time_zone?
89
+ Time.respond_to?(:zone) && Time.zone ? true : false
90
+ end
91
+
92
+ # @api private
93
+ def self.time_class
94
+ use_time_zone? ? Time.zone : Time
95
+ end
96
+
97
+ # @api private
98
+ def self.normalize_object_id(value)
99
+ value.is_a?(String) ? Mongo::ObjectID.from_string(value) : value
100
+ end
101
+ end
102
+
103
+ require 'mongo_mapper/finder_options'
104
+ require 'mongo_mapper/support'
105
+ require 'mongo_mapper/descendant_appends'
106
+
107
+ require 'mongo_mapper/dynamic_finder'
108
+ require 'mongo_mapper/key'
109
+
110
+ require 'mongo_mapper/plugins'
111
+ require 'mongo_mapper/plugins/associations'
112
+ require 'mongo_mapper/plugins/callbacks'
113
+ require 'mongo_mapper/plugins/clone'
114
+ require 'mongo_mapper/plugins/descendants'
115
+ require 'mongo_mapper/plugins/dirty'
116
+ require 'mongo_mapper/plugins/equality'
117
+ require 'mongo_mapper/plugins/identity_map'
118
+ require 'mongo_mapper/plugins/inspect'
119
+ require 'mongo_mapper/plugins/keys'
120
+ require 'mongo_mapper/plugins/logger'
121
+ require 'mongo_mapper/plugins/pagination'
122
+ require 'mongo_mapper/plugins/protected'
123
+ require 'mongo_mapper/plugins/rails'
124
+ require 'mongo_mapper/plugins/serialization'
125
+ require 'mongo_mapper/plugins/validations'
126
+
127
+ require 'mongo_mapper/embedded_document'
128
+ require 'mongo_mapper/document'