mongoid_ext 0.7.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -5
- data/Gemfile.lock +76 -27
- data/VERSION +1 -1
- data/bin/mongoid_console +9 -3
- data/lib/mongoid_ext.rb +8 -1
- data/lib/mongoid_ext/encryptor.rb +1 -1
- data/lib/mongoid_ext/file.rb +41 -14
- data/lib/mongoid_ext/file_list.rb +7 -5
- data/lib/mongoid_ext/file_server.rb +1 -3
- data/lib/mongoid_ext/filter.rb +21 -6
- data/lib/mongoid_ext/modifiers.rb +1 -1
- data/lib/mongoid_ext/paranoia.rb +2 -1
- data/lib/mongoid_ext/random.rb +3 -3
- data/lib/mongoid_ext/slugizer.rb +6 -2
- data/lib/mongoid_ext/storage.rb +10 -3
- data/lib/mongoid_ext/tags.rb +35 -4
- data/lib/mongoid_ext/types/embedded_hash.rb +4 -5
- data/lib/mongoid_ext/types/open_struct.rb +12 -8
- data/lib/mongoid_ext/types/timestamp.rb +2 -4
- data/lib/mongoid_ext/types/translation.rb +2 -4
- data/lib/mongoid_ext/versioning.rb +7 -6
- data/lib/mongoid_ext/voteable.rb +17 -12
- data/mongoid_ext.gemspec +21 -14
- data/test/helper.rb +4 -5
- data/test/models.rb +1 -1
- data/test/mongoid.yml +19 -0
- data/test/test_encryptor.rb +1 -1
- data/test/test_storage.rb +7 -7
- data/test/test_versioning.rb +5 -5
- data/test/types/test_timestamp.rb +2 -2
- metadata +89 -56
data/test/test_storage.rb
CHANGED
@@ -11,7 +11,7 @@ class StorageTest < Test::Unit::TestCase
|
|
11
11
|
@avatar.put_file("an_avatar.png", @data)
|
12
12
|
@avatar.save
|
13
13
|
avatar = Avatar.find(@avatar.id)
|
14
|
-
data = avatar.fetch_file("an_avatar.png").
|
14
|
+
data = avatar.fetch_file("an_avatar.png").data
|
15
15
|
data.should == "my avatar image"
|
16
16
|
end
|
17
17
|
|
@@ -25,7 +25,7 @@ class StorageTest < Test::Unit::TestCase
|
|
25
25
|
@avatar.data = @data
|
26
26
|
@avatar.save!
|
27
27
|
@avatar.data.should_not be_nil
|
28
|
-
@avatar.data.
|
28
|
+
@avatar.data.data.should == "my avatar image"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -38,18 +38,18 @@ class StorageTest < Test::Unit::TestCase
|
|
38
38
|
@avatar.data = @data
|
39
39
|
@avatar.save
|
40
40
|
@avatar = Avatar.find(@avatar.id)
|
41
|
-
@avatar.data.
|
41
|
+
@avatar.data.data.should == "my avatar image"
|
42
42
|
end
|
43
43
|
|
44
44
|
should "store the file after saving" do
|
45
45
|
@avatar.put_file("an_avatar.png", @data)
|
46
46
|
@avatar.save
|
47
|
-
@avatar.fetch_file("an_avatar.png").
|
47
|
+
@avatar.fetch_file("an_avatar.png").data.should == "my avatar image"
|
48
48
|
end
|
49
49
|
|
50
50
|
should "not store the file if object is new" do
|
51
51
|
@avatar.put_file("an_avatar.png", @data)
|
52
|
-
@avatar.fetch_file("an_avatar.png").
|
52
|
+
@avatar.fetch_file("an_avatar.png").data.should be_nil
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -67,14 +67,14 @@ class StorageTest < Test::Unit::TestCase
|
|
67
67
|
@avatar.first_alternative = @alternative
|
68
68
|
@avatar.save
|
69
69
|
fromdb = @avatar.reload
|
70
|
-
fromdb.first_alternative.
|
70
|
+
fromdb.first_alternative.data.should == @data
|
71
71
|
end
|
72
72
|
|
73
73
|
should "store the file in the alternative list" do
|
74
74
|
@avatar.alternatives.put("an_alternative", @alternative)
|
75
75
|
@avatar.save
|
76
76
|
@avatar.reload
|
77
|
-
@avatar.alternatives.get("an_alternative").
|
77
|
+
@avatar.alternatives.get("an_alternative").data.should == @data
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/test/test_versioning.rb
CHANGED
@@ -6,10 +6,10 @@ class TestVersioning < Test::Unit::TestCase
|
|
6
6
|
BlogPost.delete_all
|
7
7
|
User.delete_all
|
8
8
|
|
9
|
-
@blogpost = BlogPost.create(:title => "operating systems",
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
@blogpost = BlogPost.create!(:title => "operating systems",
|
10
|
+
:body => "list of some operating systems",
|
11
|
+
:tags => %w[list windows freebsd osx linux],
|
12
|
+
:updated_by => User.create(:login => "foo"))
|
13
13
|
end
|
14
14
|
|
15
15
|
should "generate a new version" do
|
@@ -52,4 +52,4 @@ class TestVersioning < Test::Unit::TestCase
|
|
52
52
|
@blogpost.versions.count.should == 2
|
53
53
|
end
|
54
54
|
end
|
55
|
-
end
|
55
|
+
end
|
@@ -29,10 +29,10 @@ class TimestampTest < Test::Unit::TestCase
|
|
29
29
|
start_time = @start_time.tomorrow.tomorrow
|
30
30
|
end_time = start_time.tomorrow
|
31
31
|
|
32
|
-
@event2 = Event.create!(:start_date => start_time.utc, :
|
32
|
+
@event2 = Event.create!(:start_date => start_time.utc, :end_date => end_time.utc)
|
33
33
|
|
34
34
|
Event.count.should == 2
|
35
|
-
events = Event.
|
35
|
+
events = Event.where("this.start_date >= %d && this.start_date <= %d" % [@event.start_date.yesterday.to_i, @event2.start_date.yesterday.to_i])
|
36
36
|
|
37
37
|
events.should == [@event]
|
38
38
|
end
|
metadata
CHANGED
@@ -1,235 +1,267 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.1
|
5
4
|
prerelease:
|
5
|
+
version: 0.9.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David A. Cuadrado
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
16
|
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - ! '>='
|
20
19
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
20
|
+
version: '0'
|
21
|
+
name: mongoid
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
32
|
none: false
|
34
33
|
requirements:
|
35
34
|
- - ! '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: 2.1.1
|
37
|
+
name: uuidtools
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.1.1
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
48
|
none: false
|
50
49
|
requirements:
|
51
50
|
- - ! '>='
|
52
51
|
- !ruby/object:Gem::Version
|
53
52
|
version: '0'
|
53
|
+
name: i18n
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
none: false
|
66
65
|
requirements:
|
67
66
|
- - ! '>='
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '0'
|
69
|
+
name: tzinfo
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
|
-
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
80
|
none: false
|
82
81
|
requirements:
|
83
82
|
- - ! '>='
|
84
83
|
- !ruby/object:Gem::Version
|
85
84
|
version: 0.1.2
|
85
|
+
name: differ
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
|
-
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 0.1.2
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
96
|
none: false
|
98
97
|
requirements:
|
99
98
|
- - ~>
|
100
99
|
- !ruby/object:Gem::Version
|
101
100
|
version: 1.1.3
|
101
|
+
name: encryptor
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
|
-
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 1.1.3
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
112
|
none: false
|
114
113
|
requirements:
|
115
|
-
- -
|
114
|
+
- - ! '>='
|
116
115
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
118
|
-
|
116
|
+
version: '0'
|
117
|
+
name: rack
|
118
|
+
type: :runtime
|
119
119
|
prerelease: false
|
120
|
-
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0
|
125
|
+
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
name: mongoid-grid_fs
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
128
136
|
requirement: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
144
|
none: false
|
130
145
|
requirements:
|
131
146
|
- - ~>
|
132
147
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
148
|
+
version: 0.6.0
|
149
|
+
name: yard
|
134
150
|
type: :development
|
135
151
|
prerelease: false
|
136
|
-
|
152
|
+
requirement: !ruby/object:Gem::Requirement
|
137
153
|
none: false
|
138
154
|
requirements:
|
139
155
|
- - ~>
|
140
156
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
157
|
+
version: 0.6.0
|
142
158
|
- !ruby/object:Gem::Dependency
|
143
|
-
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
159
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
160
|
none: false
|
146
161
|
requirements:
|
147
162
|
- - ~>
|
148
163
|
- !ruby/object:Gem::Version
|
149
|
-
version: 1.
|
164
|
+
version: 1.8.4
|
165
|
+
name: jeweler
|
150
166
|
type: :development
|
151
167
|
prerelease: false
|
152
|
-
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
153
169
|
none: false
|
154
170
|
requirements:
|
155
171
|
- - ~>
|
156
172
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
173
|
+
version: 1.8.4
|
158
174
|
- !ruby/object:Gem::Dependency
|
159
|
-
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
175
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
176
|
none: false
|
162
177
|
requirements:
|
163
178
|
- - ~>
|
164
179
|
- !ruby/object:Gem::Version
|
165
180
|
version: 2.11.3
|
181
|
+
name: shoulda
|
166
182
|
type: :development
|
167
183
|
prerelease: false
|
168
|
-
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
169
185
|
none: false
|
170
186
|
requirements:
|
171
187
|
- - ~>
|
172
188
|
- !ruby/object:Gem::Version
|
173
189
|
version: 2.11.3
|
174
190
|
- !ruby/object:Gem::Dependency
|
175
|
-
|
176
|
-
requirement: !ruby/object:Gem::Requirement
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
192
|
none: false
|
178
193
|
requirements:
|
179
194
|
- - ~>
|
180
195
|
- !ruby/object:Gem::Version
|
181
196
|
version: '0.4'
|
197
|
+
name: jnunemaker-matchy
|
182
198
|
type: :development
|
183
199
|
prerelease: false
|
184
|
-
|
200
|
+
requirement: !ruby/object:Gem::Requirement
|
185
201
|
none: false
|
186
202
|
requirements:
|
187
203
|
- - ~>
|
188
204
|
- !ruby/object:Gem::Version
|
189
205
|
version: '0.4'
|
190
206
|
- !ruby/object:Gem::Dependency
|
191
|
-
|
192
|
-
requirement: !ruby/object:Gem::Requirement
|
207
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
208
|
none: false
|
194
209
|
requirements:
|
195
210
|
- - ~>
|
196
211
|
- !ruby/object:Gem::Version
|
197
212
|
version: 2.11.3
|
213
|
+
name: shoulda
|
198
214
|
type: :development
|
199
215
|
prerelease: false
|
200
|
-
|
216
|
+
requirement: !ruby/object:Gem::Requirement
|
201
217
|
none: false
|
202
218
|
requirements:
|
203
219
|
- - ~>
|
204
220
|
- !ruby/object:Gem::Version
|
205
221
|
version: 2.11.3
|
206
222
|
- !ruby/object:Gem::Dependency
|
207
|
-
|
208
|
-
requirement: !ruby/object:Gem::Requirement
|
223
|
+
version_requirements: !ruby/object:Gem::Requirement
|
209
224
|
none: false
|
210
225
|
requirements:
|
211
226
|
- - ~>
|
212
227
|
- !ruby/object:Gem::Version
|
213
|
-
version: 0.
|
228
|
+
version: 0.11.4
|
229
|
+
name: mocha
|
214
230
|
type: :development
|
215
231
|
prerelease: false
|
216
|
-
|
232
|
+
requirement: !ruby/object:Gem::Requirement
|
217
233
|
none: false
|
218
234
|
requirements:
|
219
235
|
- - ~>
|
220
236
|
- !ruby/object:Gem::Version
|
221
|
-
version: 0.
|
237
|
+
version: 0.11.4
|
222
238
|
- !ruby/object:Gem::Dependency
|
239
|
+
version_requirements: !ruby/object:Gem::Requirement
|
240
|
+
none: false
|
241
|
+
requirements:
|
242
|
+
- - ! '>='
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
223
245
|
name: timecop
|
246
|
+
type: :development
|
247
|
+
prerelease: false
|
224
248
|
requirement: !ruby/object:Gem::Requirement
|
225
249
|
none: false
|
226
250
|
requirements:
|
227
251
|
- - ! '>='
|
228
252
|
- !ruby/object:Gem::Version
|
229
253
|
version: '0'
|
254
|
+
- !ruby/object:Gem::Dependency
|
255
|
+
version_requirements: !ruby/object:Gem::Requirement
|
256
|
+
none: false
|
257
|
+
requirements:
|
258
|
+
- - ! '>='
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: '0'
|
261
|
+
name: pry
|
230
262
|
type: :development
|
231
263
|
prerelease: false
|
232
|
-
|
264
|
+
requirement: !ruby/object:Gem::Requirement
|
233
265
|
none: false
|
234
266
|
requirements:
|
235
267
|
- - ! '>='
|
@@ -283,6 +315,7 @@ files:
|
|
283
315
|
- mongoid_ext.gemspec
|
284
316
|
- test/helper.rb
|
285
317
|
- test/models.rb
|
318
|
+
- test/mongoid.yml
|
286
319
|
- test/support/custom_matchers.rb
|
287
320
|
- test/test_encryptor.rb
|
288
321
|
- test/test_filter.rb
|