mince_mongo_db 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/lib/mince_mongo_db/interface.rb +4 -0
- data/lib/mince_mongo_db/version.rb +2 -2
- data/spec/units/mince_mongo_db/interface_spec.rb +8 -1
- metadata +14 -38
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c07a984903dd24ed1d9352c859ee464d00a4838d
|
4
|
+
data.tar.gz: fd0f28283f1f484f43a50e8b66c86ece1e769e23
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a57db0d10f24192bcdb281c06b2b5fc929ee24cddec77e829a82c3fd6323c6869c57af908ad5402184bbf96c97ba41f1515b2aa0796956d765870a7d6cf86068
|
7
|
+
data.tar.gz: 5a5eeb539f7cd0eca447d9215d6901b4b174c2e45b4557936cb1cf811eea972dc59bfb0a66bd8f41717f70bbfed17f283731b9bc27ebd70ce6405c4f312d6fb2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2012 Asynchrony
|
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.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# MinceMongoDb
|
2
|
+
|
3
|
+
[![Travis CI](https://travis-ci.org/coffeencoke/mince_mongo_db.png)](https://travis-ci.org/#!/coffeencoke/mince_mongo_db)
|
4
|
+
|
5
|
+
MinceMongoDb is a ruby ORM to provide a quick way to develop with a MongoDB database in Ruby applications.
|
6
|
+
|
7
|
+
It is a database interface that abides to the [Mince](https://github.com/coffeencoke/mince/) interface API requirements and is officially supported by [Mince](https://github.com/coffeencoke/mince/).
|
8
|
+
|
9
|
+
# How to use it
|
10
|
+
|
11
|
+
View the [Mince Wiki](https://github.com/coffeencoke/mince/wiki) on details on how to use this gem.
|
12
|
+
|
13
|
+
Basically -
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install mince_mongo_db
|
17
|
+
```
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'mince_mongo_db'
|
21
|
+
|
22
|
+
interface = MinceMongoDb::Interface
|
23
|
+
interface.add 'tron_light_cycles', luminating_color: 'red', grid_locked: true, rezzed: false
|
24
|
+
interface.add 'tron_light_cycles', luminating_color: 'blue', grid_locked: true, rezzed: true
|
25
|
+
all = interface.find_all('tron_light_cycles')
|
26
|
+
# => <Mongo::Cursor:0x3fccb15d16b0 namespace='mince.tron_light_cycles' @selector={} @cursor_id=>
|
27
|
+
all.to_a
|
28
|
+
# => [{"_id"=>BSON::ObjectId('511af435d20cae9055000001'), "luminating_color"=>"red", "grid_locked"=>true, "rezzed"=>false}, {"_id"=>BSON::ObjectId('511af435d20cae9055000002'), "luminating_color"=>"blue", "grid_locked"=>true, "rezzed"=>true}]
|
29
|
+
interface.get_for_key_with_value('tron_light_cycles', :luminating_color, 'blue')
|
30
|
+
# => {"_id"=>BSON::ObjectId('511af435d20cae9055000002'), "luminating_color"=>"blue", "grid_locked"=>true, "rezzed"=>true}
|
31
|
+
```
|
32
|
+
|
33
|
+
Change some configs
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
MinceMongoDb::Config.database_name = 'foo' # Defaults to 'mince'
|
37
|
+
MinceMongoDb::Config.database_host = 'db.myapp.com' # Defaults to 'localhsot'
|
38
|
+
MinceMongoDb::Config.username = 'app_db_user' # Defaults to none
|
39
|
+
MinceMongoDb::Config.password = 'passw0rd' # Defaults to none
|
40
|
+
|
41
|
+
# Or
|
42
|
+
|
43
|
+
MinceMongoDb::Config.options = {
|
44
|
+
database_name: 'foo',
|
45
|
+
database_host: 'db.myapp.com',
|
46
|
+
username: 'app_db_user',
|
47
|
+
password: 'passw0rd'
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
# Links
|
52
|
+
|
53
|
+
* [API Docs](http://rdoc.info/github/coffeencoke/mince_mongo_db/master/frames)
|
54
|
+
* [Travis CI](https://travis-ci.org/#!/coffeencoke/mince_mongo_db)
|
55
|
+
* [Rubygems](https://rubygems.org/gems/mince_mongo_db)
|
56
|
+
* [Github](https://github.com/coffeencoke/mince_mongo_db)
|
57
|
+
* [Wiki](https://github.com/coffeencoke/mince_mongo_db/wiki)
|
58
|
+
* [Issues](https://github.com/coffeencoke/mince_mongo_db/issues)
|
59
|
+
* [Mince](https://github.com/coffeencoke/mince)
|
60
|
+
|
61
|
+
# Contribute
|
62
|
+
|
63
|
+
This gem is officially supported by [Mince](https://github.com/coffeencoke/mince/), please go there to learn how to contribute.
|
@@ -63,6 +63,10 @@ module MinceMongoDb
|
|
63
63
|
collection(collection_name).update({primary_key.to_s => identifying_value}, {'$pull' => {array_key.to_s => value_to_remove}})
|
64
64
|
end
|
65
65
|
|
66
|
+
def self.all_before(collection_name, key, value)
|
67
|
+
collection(collection_name).find({key.to_s => {"$lt" => value}})
|
68
|
+
end
|
69
|
+
|
66
70
|
def self.containing_any(collection_name, key, values)
|
67
71
|
collection(collection_name).find({key.to_s => {"$in" => values}})
|
68
72
|
end
|
@@ -82,7 +82,7 @@ describe MinceMongoDb::Interface do
|
|
82
82
|
|
83
83
|
interface.find_all(collection_name).should == return_data
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it 'can find a record by id' do
|
87
87
|
collection.should_receive(:find_one).with(primary_key.to_s => mock_id).and_return(return_data)
|
88
88
|
|
@@ -133,6 +133,13 @@ describe MinceMongoDb::Interface do
|
|
133
133
|
interface.containing_any(collection_name, "key1", [1,2,4]).should == return_data
|
134
134
|
end
|
135
135
|
|
136
|
+
it 'can get all records where a value is less than a given value' do
|
137
|
+
value = mock
|
138
|
+
collection.should_receive(:find).with({"key1" => { "$lt" => value } }).and_return(return_data)
|
139
|
+
|
140
|
+
interface.all_before(collection_name, "key1", value).should == return_data
|
141
|
+
end
|
142
|
+
|
136
143
|
it 'can get all records where the array includes a value' do
|
137
144
|
collection.should_receive(:find).with({"key" => "value"}).and_return(return_data)
|
138
145
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mince_mongo_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Simpson
|
@@ -11,12 +10,11 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: mongo
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
19
|
- - ~>
|
22
20
|
- !ruby/object:Gem::Version
|
@@ -24,7 +22,6 @@ dependencies:
|
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
26
|
- - ~>
|
30
27
|
- !ruby/object:Gem::Version
|
@@ -32,7 +29,6 @@ dependencies:
|
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: bson_ext
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
33
|
- - ~>
|
38
34
|
- !ruby/object:Gem::Version
|
@@ -40,7 +36,6 @@ dependencies:
|
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
40
|
- - ~>
|
46
41
|
- !ruby/object:Gem::Version
|
@@ -48,7 +43,6 @@ dependencies:
|
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
44
|
name: activesupport
|
50
45
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
46
|
requirements:
|
53
47
|
- - ~>
|
54
48
|
- !ruby/object:Gem::Version
|
@@ -56,7 +50,6 @@ dependencies:
|
|
56
50
|
type: :runtime
|
57
51
|
prerelease: false
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
54
|
- - ~>
|
62
55
|
- !ruby/object:Gem::Version
|
@@ -64,7 +57,6 @@ dependencies:
|
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: rake
|
66
59
|
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
60
|
requirements:
|
69
61
|
- - ~>
|
70
62
|
- !ruby/object:Gem::Version
|
@@ -72,7 +64,6 @@ dependencies:
|
|
72
64
|
type: :development
|
73
65
|
prerelease: false
|
74
66
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
68
|
- - ~>
|
78
69
|
- !ruby/object:Gem::Version
|
@@ -80,7 +71,6 @@ dependencies:
|
|
80
71
|
- !ruby/object:Gem::Dependency
|
81
72
|
name: rspec
|
82
73
|
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
74
|
requirements:
|
85
75
|
- - ~>
|
86
76
|
- !ruby/object:Gem::Version
|
@@ -88,7 +78,6 @@ dependencies:
|
|
88
78
|
type: :development
|
89
79
|
prerelease: false
|
90
80
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
81
|
requirements:
|
93
82
|
- - ~>
|
94
83
|
- !ruby/object:Gem::Version
|
@@ -96,7 +85,6 @@ dependencies:
|
|
96
85
|
- !ruby/object:Gem::Dependency
|
97
86
|
name: guard-rspec
|
98
87
|
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
88
|
requirements:
|
101
89
|
- - ~>
|
102
90
|
- !ruby/object:Gem::Version
|
@@ -104,7 +92,6 @@ dependencies:
|
|
104
92
|
type: :development
|
105
93
|
prerelease: false
|
106
94
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
95
|
requirements:
|
109
96
|
- - ~>
|
110
97
|
- !ruby/object:Gem::Version
|
@@ -112,7 +99,6 @@ dependencies:
|
|
112
99
|
- !ruby/object:Gem::Dependency
|
113
100
|
name: yard
|
114
101
|
requirement: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
102
|
requirements:
|
117
103
|
- - ~>
|
118
104
|
- !ruby/object:Gem::Version
|
@@ -120,7 +106,6 @@ dependencies:
|
|
120
106
|
type: :development
|
121
107
|
prerelease: false
|
122
108
|
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
109
|
requirements:
|
125
110
|
- - ~>
|
126
111
|
- !ruby/object:Gem::Version
|
@@ -128,7 +113,6 @@ dependencies:
|
|
128
113
|
- !ruby/object:Gem::Dependency
|
129
114
|
name: redcarpet
|
130
115
|
requirement: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
116
|
requirements:
|
133
117
|
- - ~>
|
134
118
|
- !ruby/object:Gem::Version
|
@@ -136,7 +120,6 @@ dependencies:
|
|
136
120
|
type: :development
|
137
121
|
prerelease: false
|
138
122
|
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
123
|
requirements:
|
141
124
|
- - ~>
|
142
125
|
- !ruby/object:Gem::Version
|
@@ -144,7 +127,6 @@ dependencies:
|
|
144
127
|
- !ruby/object:Gem::Dependency
|
145
128
|
name: debugger
|
146
129
|
requirement: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
130
|
requirements:
|
149
131
|
- - ~>
|
150
132
|
- !ruby/object:Gem::Version
|
@@ -152,7 +134,6 @@ dependencies:
|
|
152
134
|
type: :development
|
153
135
|
prerelease: false
|
154
136
|
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
137
|
requirements:
|
157
138
|
- - ~>
|
158
139
|
- !ruby/object:Gem::Version
|
@@ -160,23 +141,20 @@ dependencies:
|
|
160
141
|
- !ruby/object:Gem::Dependency
|
161
142
|
name: mince
|
162
143
|
requirement: !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
144
|
requirements:
|
165
145
|
- - ~>
|
166
146
|
- !ruby/object:Gem::Version
|
167
|
-
version: '2.
|
147
|
+
version: '2.2'
|
168
148
|
type: :development
|
169
149
|
prerelease: false
|
170
150
|
version_requirements: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
151
|
requirements:
|
173
152
|
- - ~>
|
174
153
|
- !ruby/object:Gem::Version
|
175
|
-
version: '2.
|
154
|
+
version: '2.2'
|
176
155
|
- !ruby/object:Gem::Dependency
|
177
156
|
name: rb-fsevent
|
178
157
|
requirement: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
158
|
requirements:
|
181
159
|
- - ~>
|
182
160
|
- !ruby/object:Gem::Version
|
@@ -184,7 +162,6 @@ dependencies:
|
|
184
162
|
type: :development
|
185
163
|
prerelease: false
|
186
164
|
version_requirements: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
165
|
requirements:
|
189
166
|
- - ~>
|
190
167
|
- !ruby/object:Gem::Version
|
@@ -197,43 +174,42 @@ executables: []
|
|
197
174
|
extensions: []
|
198
175
|
extra_rdoc_files: []
|
199
176
|
files:
|
200
|
-
- lib/mince_mongo_db.rb
|
201
177
|
- lib/mince_mongo_db/config.rb
|
202
178
|
- lib/mince_mongo_db/connection.rb
|
203
179
|
- lib/mince_mongo_db/data_store.rb
|
204
180
|
- lib/mince_mongo_db/interface.rb
|
205
181
|
- lib/mince_mongo_db/version.rb
|
182
|
+
- lib/mince_mongo_db.rb
|
183
|
+
- LICENSE
|
184
|
+
- README.md
|
206
185
|
- spec/integration/mince_interface_spec.rb
|
207
186
|
- spec/units/mince_mongo_db/config_spec.rb
|
208
187
|
- spec/units/mince_mongo_db/connection_spec.rb
|
209
188
|
- spec/units/mince_mongo_db/data_store_spec.rb
|
210
189
|
- spec/units/mince_mongo_db/interface_spec.rb
|
211
190
|
homepage: https://github.com/coffeencoke/mince_mongo_db
|
212
|
-
licenses:
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
metadata: {}
|
213
194
|
post_install_message:
|
214
195
|
rdoc_options: []
|
215
196
|
require_paths:
|
216
197
|
- lib
|
217
198
|
required_ruby_version: !ruby/object:Gem::Requirement
|
218
|
-
none: false
|
219
199
|
requirements:
|
220
|
-
- -
|
200
|
+
- - '>='
|
221
201
|
- !ruby/object:Gem::Version
|
222
202
|
version: 1.9.3
|
223
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
|
-
none: false
|
225
204
|
requirements:
|
226
|
-
- -
|
205
|
+
- - '>='
|
227
206
|
- !ruby/object:Gem::Version
|
228
207
|
version: '0'
|
229
|
-
segments:
|
230
|
-
- 0
|
231
|
-
hash: 3427043532124513554
|
232
208
|
requirements: []
|
233
209
|
rubyforge_project: mince_mongo_db
|
234
|
-
rubygems_version:
|
210
|
+
rubygems_version: 2.0.3
|
235
211
|
signing_key:
|
236
|
-
specification_version:
|
212
|
+
specification_version: 4
|
237
213
|
summary: Lightweight MongoDB ORM for Ruby.
|
238
214
|
test_files:
|
239
215
|
- spec/integration/mince_interface_spec.rb
|