jmonteiro-mongo_mapper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/lib/mongo_mapper.rb +1 -2
- data/test/unit/test_keys.rb +27 -27
- metadata +1 -2
- data/jmonteiro-mongo_mapper.gemspec +0 -195
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/mongo_mapper.rb
CHANGED
@@ -105,7 +105,6 @@ require 'mongo_mapper/support'
|
|
105
105
|
require 'mongo_mapper/descendant_appends'
|
106
106
|
|
107
107
|
require 'mongo_mapper/dynamic_finder'
|
108
|
-
require 'mongo_mapper/key'
|
109
108
|
|
110
109
|
require 'mongo_mapper/plugins'
|
111
110
|
require 'mongo_mapper/plugins/associations'
|
@@ -125,4 +124,4 @@ require 'mongo_mapper/plugins/serialization'
|
|
125
124
|
require 'mongo_mapper/plugins/validations'
|
126
125
|
|
127
126
|
require 'mongo_mapper/embedded_document'
|
128
|
-
require 'mongo_mapper/document'
|
127
|
+
require 'mongo_mapper/document'
|
data/test/unit/test_keys.rb
CHANGED
@@ -24,45 +24,45 @@ class KeyTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
context "Initializing a new key" do
|
26
26
|
should "allow setting the name" do
|
27
|
-
Key.new(:foo, String).name.should == 'foo'
|
27
|
+
MongoMapper::Plugins::Keys::Key.new(:foo, String).name.should == 'foo'
|
28
28
|
end
|
29
29
|
|
30
30
|
should "allow setting the type" do
|
31
|
-
Key.new(:foo, Integer).type.should be(Integer)
|
31
|
+
MongoMapper::Plugins::Keys::Key.new(:foo, Integer).type.should be(Integer)
|
32
32
|
end
|
33
33
|
|
34
34
|
should "allow setting options" do
|
35
|
-
Key.new(:foo, Integer, :required => true).options[:required].should be(true)
|
35
|
+
MongoMapper::Plugins::Keys::Key.new(:foo, Integer, :required => true).options[:required].should be(true)
|
36
36
|
end
|
37
37
|
|
38
38
|
should "default options to {}" do
|
39
|
-
Key.new(:foo, Integer, nil).options.should == {}
|
39
|
+
MongoMapper::Plugins::Keys::Key.new(:foo, Integer, nil).options.should == {}
|
40
40
|
end
|
41
41
|
|
42
42
|
should "symbolize option keys" do
|
43
|
-
Key.new(:foo, Integer, 'required' => true).options[:required].should be(true)
|
43
|
+
MongoMapper::Plugins::Keys::Key.new(:foo, Integer, 'required' => true).options[:required].should be(true)
|
44
44
|
end
|
45
45
|
|
46
46
|
should "work with just name" do
|
47
|
-
key = Key.new(:foo)
|
47
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo)
|
48
48
|
key.name.should == 'foo'
|
49
49
|
end
|
50
50
|
|
51
51
|
should "work with name and type" do
|
52
|
-
key = Key.new(:foo, String)
|
52
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, String)
|
53
53
|
key.name.should == 'foo'
|
54
54
|
key.type.should == String
|
55
55
|
end
|
56
56
|
|
57
57
|
should "work with name, type, and options" do
|
58
|
-
key = Key.new(:foo, String, :required => true)
|
58
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, String, :required => true)
|
59
59
|
key.name.should == 'foo'
|
60
60
|
key.type.should == String
|
61
61
|
key.options[:required].should be_true
|
62
62
|
end
|
63
63
|
|
64
64
|
should "work with name and options" do
|
65
|
-
key = Key.new(:foo, :required => true)
|
65
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, :required => true)
|
66
66
|
key.name.should == 'foo'
|
67
67
|
key.options[:required].should be_true
|
68
68
|
end
|
@@ -70,62 +70,62 @@ class KeyTest < Test::Unit::TestCase
|
|
70
70
|
|
71
71
|
context "A key" do
|
72
72
|
should "be equal to another key with same name and type" do
|
73
|
-
Key.new(:name, String).should == Key.new(:name, String)
|
73
|
+
MongoMapper::Plugins::Keys::Key.new(:name, String).should == MongoMapper::Plugins::Keys::Key.new(:name, String)
|
74
74
|
end
|
75
75
|
|
76
76
|
should "not be equal to another key with different name" do
|
77
|
-
Key.new(:name, String).should_not == Key.new(:foo, String)
|
77
|
+
MongoMapper::Plugins::Keys::Key.new(:name, String).should_not == MongoMapper::Plugins::Keys::Key.new(:foo, String)
|
78
78
|
end
|
79
79
|
|
80
80
|
should "not be equal to another key with different type" do
|
81
|
-
Key.new(:name, String).should_not == Key.new(:name, Integer)
|
81
|
+
MongoMapper::Plugins::Keys::Key.new(:name, String).should_not == MongoMapper::Plugins::Keys::Key.new(:name, Integer)
|
82
82
|
end
|
83
83
|
|
84
84
|
should "know if it is a embedded_document" do
|
85
|
-
Key.new(:name, EDoc()).embeddable?.should be_true
|
85
|
+
MongoMapper::Plugins::Keys::Key.new(:name, EDoc()).embeddable?.should be_true
|
86
86
|
end
|
87
87
|
|
88
88
|
should "know if it is not a embedded_document" do
|
89
|
-
Key.new(:name, String).embeddable?.should be_false
|
89
|
+
MongoMapper::Plugins::Keys::Key.new(:name, String).embeddable?.should be_false
|
90
90
|
end
|
91
91
|
|
92
92
|
should "know if it is a number" do
|
93
|
-
Key.new(:age, Integer).number?.should be_true
|
94
|
-
Key.new(:age, Float).number?.should be_true
|
93
|
+
MongoMapper::Plugins::Keys::Key.new(:age, Integer).number?.should be_true
|
94
|
+
MongoMapper::Plugins::Keys::Key.new(:age, Float).number?.should be_true
|
95
95
|
end
|
96
96
|
|
97
97
|
should "know if it is not a number" do
|
98
|
-
Key.new(:age, String).number?.should be_false
|
98
|
+
MongoMapper::Plugins::Keys::Key.new(:age, String).number?.should be_false
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
context "setting a value with a custom type" do
|
103
103
|
should "correctly typecast" do
|
104
|
-
key = Key.new(:foo, FooType)
|
104
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, FooType)
|
105
105
|
key.set("something").should == 'to_mongo'
|
106
106
|
end
|
107
107
|
|
108
108
|
should "correctly typecast if object of that type is given" do
|
109
|
-
key = Key.new(:foo, FooType)
|
109
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, FooType)
|
110
110
|
key.set(FooType.new('something')).should == 'to_mongo'
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
context "getting a value with a custom type" do
|
115
115
|
should "use #from_mongo to convert back to custom type" do
|
116
|
-
key = Key.new(:foo, FooType)
|
116
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, FooType)
|
117
117
|
key.get('something').should == 'from_mongo'
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
121
|
context "getting a value" do
|
122
122
|
should "work with a type" do
|
123
|
-
key = Key.new(:foo, String)
|
123
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, String)
|
124
124
|
key.get('bar').should == 'bar'
|
125
125
|
end
|
126
126
|
|
127
127
|
should "work without type" do
|
128
|
-
key = Key.new(:foo)
|
128
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo)
|
129
129
|
key.get([1, '2']).should == [1, '2']
|
130
130
|
key.get(false).should == false
|
131
131
|
key.get({}).should == {}
|
@@ -133,13 +133,13 @@ class KeyTest < Test::Unit::TestCase
|
|
133
133
|
|
134
134
|
context "for a embedded_document" do
|
135
135
|
should "default to nil" do
|
136
|
-
key = Key.new(:foo, Address)
|
136
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, Address)
|
137
137
|
key.get(nil).should be_nil
|
138
138
|
end
|
139
139
|
|
140
140
|
should "return instance if instance" do
|
141
141
|
address = Address.new(:city => 'South Bend', :state => 'IN', :zip => 46544)
|
142
|
-
key = Key.new(:foo, Address)
|
142
|
+
key = MongoMapper::Plugins::Keys::Key.new(:foo, Address)
|
143
143
|
key.get(address).should == address
|
144
144
|
end
|
145
145
|
end
|
@@ -147,7 +147,7 @@ class KeyTest < Test::Unit::TestCase
|
|
147
147
|
|
148
148
|
context "getting a value with a default set" do
|
149
149
|
setup do
|
150
|
-
@key = Key.new(:foo, String, :default => 'baz')
|
150
|
+
@key = MongoMapper::Plugins::Keys::Key.new(:foo, String, :default => 'baz')
|
151
151
|
end
|
152
152
|
|
153
153
|
should "return default value if value nil" do
|
@@ -159,11 +159,11 @@ class KeyTest < Test::Unit::TestCase
|
|
159
159
|
end
|
160
160
|
|
161
161
|
should "work with Boolean type and false value" do
|
162
|
-
Key.new(:active, Boolean, :default => false).get(nil).should be_false
|
162
|
+
MongoMapper::Plugins::Keys::Key.new(:active, Boolean, :default => false).get(nil).should be_false
|
163
163
|
end
|
164
164
|
|
165
165
|
should "work with Boolean type and true value" do
|
166
|
-
Key.new(:active, Boolean, :default => true).get(nil).should be_true
|
166
|
+
MongoMapper::Plugins::Keys::Key.new(:active, Boolean, :default => true).get(nil).should be_true
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end # KeyTest
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jmonteiro-mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- Rakefile
|
102
102
|
- VERSION
|
103
103
|
- bin/mmconsole
|
104
|
-
- jmonteiro-mongo_mapper.gemspec
|
105
104
|
- lib/mongo_mapper.rb
|
106
105
|
- lib/mongo_mapper/descendant_appends.rb
|
107
106
|
- lib/mongo_mapper/document.rb
|
@@ -1,195 +0,0 @@
|
|
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
|
-
|