mongoo 0.2.1 → 0.2.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.
- data/CHANGELOG +10 -0
- data/README.rdoc +14 -0
- data/Rakefile +6 -0
- data/VERSION +1 -1
- data/lib/mongoo.rb +4 -2
- data/lib/mongoo/async.rb +29 -34
- data/mongoo.gemspec +2 -1
- data/test/helper.rb +3 -3
- data/test/test_async.rb +41 -0
- metadata +4 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
== Changelog
|
2
2
|
|
3
|
+
=== 0.2.2
|
4
|
+
|
5
|
+
* async mode works again, but now you have to manually require:
|
6
|
+
|
7
|
+
require "mongoo/async"
|
8
|
+
Mongoo.conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :timeout => 5)
|
9
|
+
Mongoo.db_name = "mongoo-test"
|
10
|
+
|
11
|
+
see test_async.rb for an example.
|
12
|
+
|
3
13
|
=== 0.2.1
|
4
14
|
|
5
15
|
* Identity Map now also stores results from find.to_a, find.each and find.next
|
data/README.rdoc
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
|
3
3
|
== Changelog
|
4
4
|
|
5
|
+
=== 0.2.2
|
6
|
+
|
7
|
+
* async mode works again, but now you have to manually require:
|
8
|
+
|
9
|
+
require "mongoo/async"
|
10
|
+
Mongoo.conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :timeout => 5)
|
11
|
+
Mongoo.db_name = "mongoo-test"
|
12
|
+
|
13
|
+
see test_async.rb for an example.
|
14
|
+
|
15
|
+
=== 0.2.1
|
16
|
+
|
17
|
+
* Identity Map now also stores results from find.to_a, find.each and find.next
|
18
|
+
|
5
19
|
=== 0.2.0
|
6
20
|
|
7
21
|
* Depends on mongo gem >= 1.3.1
|
data/Rakefile
CHANGED
@@ -33,6 +33,12 @@ Rake::TestTask.new(:test) do |test|
|
|
33
33
|
test.verbose = true
|
34
34
|
end
|
35
35
|
|
36
|
+
Rake::TestTask.new(:test_async) do |test|
|
37
|
+
test.libs << 'lib' << 'test'
|
38
|
+
test.pattern = 'test/**/test_async*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
|
36
42
|
require 'rcov/rcovtask'
|
37
43
|
Rcov::RcovTask.new do |test|
|
38
44
|
test.libs << 'test'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/mongoo.rb
CHANGED
@@ -4,14 +4,16 @@ module Mongoo
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
attr_accessor :conn, :db_name, :verbose_debug
|
7
|
+
|
8
|
+
def mode
|
9
|
+
:sync
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
10
14
|
require "forwardable"
|
11
15
|
require "mongo"
|
12
16
|
|
13
|
-
require "mongoo/async"
|
14
|
-
|
15
17
|
require "active_support/core_ext"
|
16
18
|
require "active_model"
|
17
19
|
|
data/lib/mongoo/async.rb
CHANGED
@@ -1,41 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "em-synchrony/tcpsocket"
|
4
|
-
module Mongo
|
5
|
-
class Connection
|
6
|
-
EMTCPSocket = ::EventMachine::Synchrony::TCPSocket
|
1
|
+
require "em-synchrony"
|
2
|
+
require "em-synchrony/tcpsocket"
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ensure
|
18
|
-
socket.close if socket
|
19
|
-
end
|
4
|
+
module Mongoo
|
5
|
+
def self.suppress_warnings
|
6
|
+
original_verbosity = $VERBOSE
|
7
|
+
$VERBOSE = nil
|
8
|
+
result = yield
|
9
|
+
$VERBOSE = original_verbosity
|
10
|
+
return result
|
11
|
+
end
|
12
|
+
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
module Mongoo
|
15
|
+
def self.mode
|
16
|
+
:async
|
24
17
|
end
|
18
|
+
end
|
25
19
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
20
|
+
module Mongo
|
21
|
+
class Pool
|
22
|
+
Mongoo.suppress_warnings { TCPSocket = ::EventMachine::Synchrony::TCPSocket }
|
30
23
|
end
|
24
|
+
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def self.mode
|
36
|
-
:sync
|
37
|
-
end
|
26
|
+
module Mongo
|
27
|
+
class Connection
|
28
|
+
Mongoo.suppress_warnings { TCPSocket = ::EventMachine::Synchrony::TCPSocket }
|
38
29
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
if ENV["MONGOO_DEBUG"] == "1"
|
33
|
+
puts "* Mongoo Running in Asynchronous Mode"
|
34
|
+
puts " ==> Mongo::Pool::TCPSocket: #{Mongo::Pool::TCPSocket.to_s}"
|
35
|
+
puts " ==> Mongo::Connection::TCPSocket: #{Mongo::Pool::TCPSocket.to_s}"
|
36
|
+
end
|
data/mongoo.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoo}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Myles"]
|
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
|
|
52
52
|
s.test_files = [
|
53
53
|
"test/helper.rb",
|
54
54
|
"test/test_activemodel.rb",
|
55
|
+
"test/test_async.rb",
|
55
56
|
"test/test_identity_map.rb",
|
56
57
|
"test/test_mongohash.rb",
|
57
58
|
"test/test_mongoo.rb"
|
data/test/helper.rb
CHANGED
@@ -2,7 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'bundler'
|
3
3
|
begin
|
4
4
|
groups = [:default, :development]
|
5
|
-
|
5
|
+
|
6
|
+
if ENV["MONGOO_ASYNC"]
|
6
7
|
groups << :async
|
7
8
|
else
|
8
9
|
groups << :sync
|
@@ -20,7 +21,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
20
21
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
21
22
|
require 'mongoo'
|
22
23
|
|
23
|
-
#Mongoo.config = {host: "127.0.0.1", port: 27017, db: 'mongoo-test'}
|
24
24
|
Mongoo.conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :timeout => 5)
|
25
25
|
Mongoo.db_name = "mongoo-test"
|
26
26
|
|
@@ -65,4 +65,4 @@ class TvShow < Mongoo::Base
|
|
65
65
|
end
|
66
66
|
|
67
67
|
class Test::Unit::TestCase
|
68
|
-
end
|
68
|
+
end
|
data/test/test_async.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
if ENV["MONGOO_ASYNC"]
|
2
|
+
|
3
|
+
require 'helper'
|
4
|
+
require "mongoo/async"
|
5
|
+
|
6
|
+
class TestAsync < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
EM.synchrony do
|
10
|
+
Mongoo.conn = Mongo::Connection.new("localhost", 27017, :pool_size => 5, :timeout => 5)
|
11
|
+
Mongoo.db_name = "mongoo-test"
|
12
|
+
|
13
|
+
[Person, TvShow, SearchIndex].each do |obj|
|
14
|
+
obj.drop
|
15
|
+
obj.create_indexes
|
16
|
+
end
|
17
|
+
EventMachine.stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
should "set and get attributes" do
|
22
|
+
EM.synchrony do
|
23
|
+
p = Person.new("name" => "Ben")
|
24
|
+
assert_equal "Ben", p.g(:name)
|
25
|
+
assert_equal "Ben", p.get(:name)
|
26
|
+
assert_equal "Ben", p.get_attribute(:name)
|
27
|
+
p.set("location.city", "San Francisco")
|
28
|
+
assert_equal "San Francisco", p.get("location.city")
|
29
|
+
p.sets({"location.demographics.crime_rate" => :high, "location.demographics.education_quality" => :low})
|
30
|
+
assert_equal({"name"=>"Ben",
|
31
|
+
"location.demographics.crime_rate"=>:high}, p.gets(%w(name location.demographics.crime_rate)))
|
32
|
+
assert_raise(Mongoo::UnknownAttributeError) { p.set("idontexist", "foo") }
|
33
|
+
assert_raise(Mongoo::UnknownAttributeError) { p.get("idontexist") }
|
34
|
+
assert_raise(NoMethodError) { p.idontexist }
|
35
|
+
assert_raise(NoMethodError) { p.idontexist = "val" }
|
36
|
+
EventMachine.stop
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mongoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Myles
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- test/test_identity_map.rb
|
149
149
|
- test/test_mongohash.rb
|
150
150
|
- test/test_mongoo.rb
|
151
|
+
- test/test_async.rb
|
151
152
|
has_rdoc: true
|
152
153
|
homepage: http://github.com/benmyles/mongoo
|
153
154
|
licenses:
|
@@ -162,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
163
|
requirements:
|
163
164
|
- - ">="
|
164
165
|
- !ruby/object:Gem::Version
|
165
|
-
hash:
|
166
|
+
hash: -1642084642686495680
|
166
167
|
segments:
|
167
168
|
- 0
|
168
169
|
version: "0"
|
@@ -182,6 +183,7 @@ summary: Object mapper for MongoDB
|
|
182
183
|
test_files:
|
183
184
|
- test/helper.rb
|
184
185
|
- test/test_activemodel.rb
|
186
|
+
- test/test_async.rb
|
185
187
|
- test/test_identity_map.rb
|
186
188
|
- test/test_mongohash.rb
|
187
189
|
- test/test_mongoo.rb
|