mordor 0.2.20 → 0.3.0
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.
- checksums.yaml +15 -0
- data/.gitignore +2 -0
- data/.travis.yml +6 -5
- data/CHANGES.md +9 -0
- data/Gemfile +4 -14
- data/Guardfile +39 -0
- data/ext/mkrf_conf.rb +21 -0
- data/lib/mordor/config.rb +11 -2
- data/lib/mordor/resource.rb +70 -8
- data/lib/mordor/version.rb +1 -1
- data/mordor.gemspec +19 -18
- data/spec/mordor/collection_spec.rb +3 -3
- data/spec/mordor/connection_spec.rb +77 -30
- data/spec/spec_helper.rb +1 -9
- data/tasks/github-gem.rake +7 -7
- metadata +125 -149
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YmI5Mzc5YTZlMTZkYWE2YzBmNzA1NzBmMzJjOGU2MDQwNGMxNTkzOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDA3ODE3NDdiMjAwZGUxZjliMTY5Y2I4MjZkMmI5NTllMGI1NzI2OA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDdhZmNjM2FiNmJlYmE1Y2VhNThjMDBiM2JiNmEyMTYyMzE4OTNmNmFhZjVj
|
10
|
+
ODQzZWIzZWJlNmZmN2RjMGVkYzIyNDE4OWRlYzg1YWZlOTBhYzBlMGJlNTA3
|
11
|
+
N2ExMmU4NDM4YzExMGM5ZDNmYjMxYjA1NDhiOGQ3MDdlNmE0ZWM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTg4MGZjZGQ5NTg5M2IwOWNlNGUxYmQwY2ViYzk0MzU3NTA5Zjk5ZjUzMTVm
|
14
|
+
NjQ0NWZiMjdhYzQzNTE2YzdiZjc1YTg5OGI4YzFjZDVkNmFmNjRkMTUxNGQ0
|
15
|
+
YTA4M2QzMTYwYzY1MTk1ZmIyMmE0YWE2MzFhNjA3NWIwOTRlODg=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
bundler_args: --without optional
|
2
4
|
|
3
5
|
jdk:
|
4
6
|
- oraclejdk7
|
@@ -7,15 +9,14 @@ services:
|
|
7
9
|
- mongodb
|
8
10
|
|
9
11
|
rvm:
|
10
|
-
- 1.8.7
|
11
|
-
- 1.9.2
|
12
12
|
- 1.9.3
|
13
|
-
-
|
13
|
+
- 2.1.6
|
14
|
+
- 2.2.2
|
14
15
|
- jruby-19mode
|
15
|
-
- rbx-18mode
|
16
16
|
- rbx-19mode
|
17
|
+
- rbx-2.5.3
|
17
18
|
|
18
19
|
matrix:
|
19
20
|
allow_failures:
|
20
21
|
- rvm: rbx-19mode
|
21
|
-
- rvm: rbx-
|
22
|
+
- rvm: rbx-2.5.3
|
data/CHANGES.md
ADDED
data/Gemfile
CHANGED
@@ -1,17 +1,7 @@
|
|
1
|
-
source "
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source "https://rubygems.org"
|
5
2
|
|
6
|
-
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
gem "rake"
|
9
|
-
gem "extlib"
|
10
|
-
gem "mongo"
|
11
|
-
gem "bson_ext", :platforms => :ruby
|
12
|
-
gem "json"
|
3
|
+
gemspec
|
13
4
|
|
14
|
-
group :
|
15
|
-
gem
|
16
|
-
gem "rack-test"
|
5
|
+
group :optional do
|
6
|
+
gem 'guard-rspec'
|
17
7
|
end
|
data/Guardfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
36
|
+
watch(%r{^spec/.+_spec\.rb$})
|
37
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
38
|
+
watch('spec/spec_helper.rb') { "spec" }
|
39
|
+
end
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems/dependency_installer'
|
2
|
+
|
3
|
+
gdi = Gem::DependencyInstaller.new
|
4
|
+
|
5
|
+
begin
|
6
|
+
if RUBY_PLATFORM == 'java'
|
7
|
+
puts "Not installing bson_ext gem, because we're running on JRuby"
|
8
|
+
else
|
9
|
+
puts "Installing bson_ext"
|
10
|
+
gdi.install "bson_ext"
|
11
|
+
end
|
12
|
+
rescue => e
|
13
|
+
warn "#{$0}: #{e}"
|
14
|
+
|
15
|
+
exit!
|
16
|
+
end
|
17
|
+
|
18
|
+
# Write fake Rakefile for rake since Makefile isn't used
|
19
|
+
File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w') do |f|
|
20
|
+
f.write("task :default" + $/)
|
21
|
+
end
|
data/lib/mordor/config.rb
CHANGED
@@ -18,11 +18,17 @@ module Mordor
|
|
18
18
|
#
|
19
19
|
# :api: publicdef use
|
20
20
|
def use
|
21
|
-
@configuration ||=
|
21
|
+
@configuration ||= defaults
|
22
22
|
yield @configuration
|
23
23
|
nil
|
24
24
|
end
|
25
25
|
|
26
|
+
# Resets the configuration to its default state
|
27
|
+
#
|
28
|
+
def reset
|
29
|
+
setup
|
30
|
+
end
|
31
|
+
|
26
32
|
# Retrieve the value of a config entry.
|
27
33
|
#
|
28
34
|
# ==== Parameters
|
@@ -59,7 +65,10 @@ module Mordor
|
|
59
65
|
@defaults ||= {
|
60
66
|
:hostname => 'localhost',
|
61
67
|
:port => 27017,
|
62
|
-
:database => 'development'
|
68
|
+
:database => 'development',
|
69
|
+
:pool_size => nil,
|
70
|
+
:pool_timeout => nil,
|
71
|
+
:rs_refresh_mode => :sync,
|
63
72
|
}
|
64
73
|
end
|
65
74
|
|
data/lib/mordor/resource.rb
CHANGED
@@ -172,15 +172,12 @@ module Mordor
|
|
172
172
|
|
173
173
|
def database
|
174
174
|
unless @db
|
175
|
-
if
|
176
|
-
|
177
|
-
options[:rs_name] = Mordor::Config[:replica_set] if Mordor::Config[:replica_set]
|
178
|
-
connection = Mongo::MongoReplicaSetClient.new(hosts, options)
|
175
|
+
if connecting_to_replica_set?
|
176
|
+
client = new_replica_set_client
|
179
177
|
else
|
180
|
-
|
178
|
+
client = new_mongo_connection
|
181
179
|
end
|
182
|
-
@db =
|
183
|
-
@db.authenticate(Mordor::Config[:username], Mordor::Config[:password]) if Mordor::Config[:username]
|
180
|
+
@db = database_connection(client)
|
184
181
|
end
|
185
182
|
|
186
183
|
@db
|
@@ -265,7 +262,8 @@ module Mordor
|
|
265
262
|
EOS
|
266
263
|
end
|
267
264
|
|
268
|
-
|
265
|
+
private
|
266
|
+
|
269
267
|
def perform_collection_find(query, options = {})
|
270
268
|
ensure_indices
|
271
269
|
collection.find(query, options)
|
@@ -318,6 +316,70 @@ module Mordor
|
|
318
316
|
def day_to_query(day)
|
319
317
|
date_range_to_query( day_to_range(day) )
|
320
318
|
end
|
319
|
+
|
320
|
+
# Connection setup
|
321
|
+
|
322
|
+
def new_mongo_connection
|
323
|
+
Mongo::Connection.new(*mongo_connection_args)
|
324
|
+
end
|
325
|
+
|
326
|
+
def new_replica_set_client
|
327
|
+
Mongo::MongoReplicaSetClient.new(*replica_set_client_args)
|
328
|
+
end
|
329
|
+
|
330
|
+
def database_connection(client)
|
331
|
+
client.db(Mordor::Config[:database]).tap do |db|
|
332
|
+
db.authenticate(*authentication_args) if authentication_args.any?
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
# Connection arguments
|
337
|
+
|
338
|
+
def mongo_connection_args
|
339
|
+
args = [ Mordor::Config[:hostname], Mordor::Config[:port] ]
|
340
|
+
args << connection_pool_options if connection_pool_options.any?
|
341
|
+
args
|
342
|
+
end
|
343
|
+
|
344
|
+
def replica_set_client_args
|
345
|
+
[ replica_set_host_list, replica_set_options ]
|
346
|
+
end
|
347
|
+
|
348
|
+
def authentication_args
|
349
|
+
args = []
|
350
|
+
if user_name = Mordor::Config[:username]
|
351
|
+
args << user_name
|
352
|
+
args << Mordor::Config[:password] if Mordor::Config[:password]
|
353
|
+
end
|
354
|
+
args
|
355
|
+
end
|
356
|
+
|
357
|
+
# Connection options
|
358
|
+
|
359
|
+
def connection_pool_options
|
360
|
+
@connection_pool_options ||= Hash.new.tap do |hash|
|
361
|
+
hash[:pool_size] = Mordor::Config[:pool_size] if Mordor::Config[:pool_size]
|
362
|
+
hash[:pool_timeout] = Mordor::Config[:pool_timeout] if Mordor::Config[:pool_timeout]
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
def replica_set_options
|
367
|
+
@replica_set_options ||= connection_pool_options.tap do |hash|
|
368
|
+
hash[:refresh_mode] = Mordor::Config[:rs_refresh_mode]
|
369
|
+
hash[:rs_name] = Mordor::Config[:replica_set] if Mordor::Config[:replica_set]
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
# Replica set helpers
|
374
|
+
|
375
|
+
def replica_set_host_list
|
376
|
+
@replica_set_hosts ||= Mordor::Config[:hostname].split(',').map(&:strip).compact
|
377
|
+
end
|
378
|
+
|
379
|
+
def connecting_to_replica_set?
|
380
|
+
replica_set_host_list.size > 1
|
381
|
+
end
|
382
|
+
|
321
383
|
end
|
322
384
|
end
|
323
385
|
end
|
data/lib/mordor/version.rb
CHANGED
data/mordor.gemspec
CHANGED
@@ -1,32 +1,33 @@
|
|
1
|
+
require './lib/mordor/version'
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
|
-
s.name =
|
3
|
-
|
4
|
+
s.name = 'mordor'
|
5
|
+
|
4
6
|
# Do not set the version and date field manually, this is done by the release script
|
5
|
-
s.version =
|
6
|
-
s.date = "
|
7
|
+
s.version = Mordor::VERSION
|
8
|
+
s.date = "2015-05-15"
|
7
9
|
|
8
|
-
s.summary =
|
10
|
+
s.summary = 'mordor'
|
9
11
|
s.description = <<-eos
|
10
12
|
Small gem to add MongoDB Resources, resources have attributes that translate into document fields. When an attribute is declared, finders for the attribute are added to the Resource automatically
|
11
13
|
eos
|
12
14
|
|
13
|
-
s.add_development_dependency('rake')
|
14
|
-
s.add_development_dependency('rspec', '~> 2.0')
|
15
|
-
s.add_development_dependency('json')
|
16
|
-
|
17
|
-
s.add_development_dependency('extlib')
|
18
|
-
s.add_development_dependency('mongo')
|
19
|
-
|
20
|
-
s.add_runtime_dependency('extlib')
|
21
|
-
s.add_runtime_dependency('mongo')
|
22
|
-
s.add_runtime_dependency('json')
|
23
|
-
|
24
15
|
s.authors = ['Jan-Willem Koelewijn', 'Dirkjan Bussink']
|
25
16
|
s.email = ['janwillem.koelewijn@nedap.com', 'dirkjan.bussink@nedap.com']
|
26
17
|
s.homepage = 'http://www.nedap.com'
|
27
18
|
|
19
|
+
s.add_runtime_dependency 'extlib'
|
20
|
+
s.add_runtime_dependency 'json'
|
21
|
+
s.add_runtime_dependency 'mongo', '< 2.0'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rack-test'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'rspec', '~> 2.0', '< 2.99'
|
26
|
+
|
27
|
+
s.add_runtime_dependency 'bson_ext' unless RUBY_PLATFORM == 'java'
|
28
|
+
s.extensions << 'ext/mkrf_conf.rb'
|
29
|
+
|
28
30
|
# The files and test_files directives are set automatically by the release script.
|
29
31
|
# Do not change them by hand, but make sure to add the files to the git repository.
|
30
|
-
s.files = %w(.gitignore .travis.yml Gemfile LICENSE README.md Rakefile lib/mordor.rb lib/mordor/collection.rb lib/mordor/config.rb lib/mordor/resource.rb lib/mordor/version.rb mordor.gemspec spec/mordor/collection_spec.rb spec/mordor/connection_spec.rb spec/mordor/resource_spec.rb spec/spec.opts spec/spec_helper.rb tasks/github-gem.rake)
|
32
|
+
s.files = %w(.gitignore .travis.yml CHANGES.md Gemfile Guardfile LICENSE README.md Rakefile ext/mkrf_conf.rb lib/mordor.rb lib/mordor/collection.rb lib/mordor/config.rb lib/mordor/resource.rb lib/mordor/version.rb mordor.gemspec spec/mordor/collection_spec.rb spec/mordor/connection_spec.rb spec/mordor/resource_spec.rb spec/spec.opts spec/spec_helper.rb tasks/github-gem.rake)
|
31
33
|
end
|
32
|
-
|
@@ -19,7 +19,7 @@ describe "with respect to collections" do
|
|
19
19
|
before :each do
|
20
20
|
5.times do |index|
|
21
21
|
res = TestResource.new(:first => "#{index}_first", :second => "#{index}_second", :third => "#{index}_third")
|
22
|
-
res.save.should
|
22
|
+
res.save.should be true
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -40,7 +40,7 @@ describe "with respect to collections" do
|
|
40
40
|
before :each do
|
41
41
|
5.times do |index|
|
42
42
|
res = TestResource.new(:first => "#{index}_first", :second => "#{index}_second", :third => "#{index}_third")
|
43
|
-
res.save.should
|
43
|
+
res.save.should be true
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -78,7 +78,7 @@ describe "with respect to collections" do
|
|
78
78
|
before :each do
|
79
79
|
5.times do |index|
|
80
80
|
res = TestResource.new(:first => "#{index}_first", :second => "#{index}_second", :third => "#{index}_third")
|
81
|
-
res.save.should
|
81
|
+
res.save.should be true
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -7,15 +7,17 @@ describe "connecting to mongo" do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
describe 'database connection' do
|
11
|
+
it "should have a mongo database " do
|
12
|
+
TestResource.database.should be_instance_of(Mongo::DB)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
it "should select the correct database" do
|
16
|
+
database_name = "any_database_name"
|
17
|
+
Mordor::Config.use { |config| config[:database] = database_name }
|
17
18
|
|
18
|
-
|
19
|
+
TestResource.database.name.should == database_name
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
describe "when credentials are provided" do
|
@@ -27,8 +29,8 @@ describe "connecting to mongo" do
|
|
27
29
|
config[:password] = credentials[:password]
|
28
30
|
end
|
29
31
|
|
30
|
-
@mock_db =
|
31
|
-
Mongo::Connection.stub(:new).and_return(
|
32
|
+
@mock_db = double("db")
|
33
|
+
Mongo::Connection.stub(:new).and_return(double("connection", :db => @mock_db))
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should authenticate with username and password" do
|
@@ -39,58 +41,103 @@ describe "connecting to mongo" do
|
|
39
41
|
|
40
42
|
describe "the Mongo database connection" do
|
41
43
|
before :each do
|
42
|
-
@mock_connection =
|
44
|
+
@mock_connection = double("connection", :db => double("db"))
|
45
|
+
end
|
46
|
+
|
47
|
+
after :each do
|
48
|
+
TestResource.database
|
43
49
|
end
|
44
50
|
|
45
51
|
it "should connect with specified host" do
|
46
52
|
host = "any host IP or reachable hostname"
|
47
53
|
Mordor::Config.use { |config| config[:hostname] = host }
|
48
|
-
|
49
54
|
Mongo::Connection.should_receive(:new).with(host, anything).and_return(@mock_connection)
|
50
|
-
|
51
|
-
TestResource.database
|
52
55
|
end
|
53
56
|
|
54
57
|
it "should connect on specified port" do
|
55
58
|
port = rand(10000)
|
56
59
|
Mordor::Config.use { |config| config[:port] = port }
|
57
|
-
|
58
60
|
Mongo::Connection.should_receive(:new).with(anything, port).and_return(@mock_connection)
|
61
|
+
end
|
59
62
|
|
60
|
-
|
63
|
+
describe 'setting connection pool options' do
|
64
|
+
it 'supports setting pool size' do
|
65
|
+
Mordor::Config.use { |config| config[:pool_size] = 7 }
|
66
|
+
Mongo::Connection.should_receive(:new).with('localhost', 27017, pool_size: 7).and_return(@mock_connection)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'supports setting pool timeout' do
|
70
|
+
Mordor::Config.use { |config| config[:pool_timeout] = 8 }
|
71
|
+
Mongo::Connection.should_receive(:new).with('localhost', 27017, pool_timeout: 8).and_return(@mock_connection)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'supports setting both' do
|
75
|
+
Mordor::Config.use { |config|
|
76
|
+
config[:pool_size] = 9
|
77
|
+
config[:pool_timeout] = 10
|
78
|
+
}
|
79
|
+
Mongo::Connection.should_receive(:new).with('localhost', 27017, pool_size: 9, pool_timeout: 10).and_return(@mock_connection)
|
80
|
+
end
|
61
81
|
end
|
62
82
|
end
|
63
83
|
|
64
84
|
describe "replica sets" do
|
65
85
|
before :each do
|
66
|
-
@mock_connection =
|
86
|
+
@mock_connection = double("connection", :db => double("db"))
|
87
|
+
Mordor::Config.use { |config| config[:hostname] = host_string }
|
67
88
|
end
|
68
89
|
|
69
|
-
|
70
|
-
|
71
|
-
|
90
|
+
after :each do
|
91
|
+
TestResource.database
|
92
|
+
end
|
72
93
|
|
73
|
-
|
94
|
+
let(:host_string){ 'localhost:27017, localhost:27018 ' }
|
95
|
+
let(:hosts_array){ host_string.split(',').map(&:strip) }
|
96
|
+
let(:replica_set_string){ 'sample replica set' }
|
74
97
|
|
98
|
+
it "creates a mongo replica set client when multiple hosts are provided" do
|
75
99
|
Mongo::MongoReplicaSetClient.should_receive(:new).with(hosts_array, anything).and_return(@mock_connection)
|
76
|
-
|
77
|
-
TestResource.database
|
78
100
|
end
|
79
101
|
|
80
102
|
it "creates a mongo replica set client with the correct replica set name if given" do
|
81
|
-
hosts = "localhost:27017, localhost:27018 "
|
82
|
-
replica_set = "sample replica set"
|
83
|
-
|
84
103
|
Mordor::Config.use do |config|
|
85
|
-
config[:
|
86
|
-
config[:replica_set] = replica_set
|
104
|
+
config[:replica_set] = replica_set_string
|
87
105
|
end
|
88
|
-
|
89
|
-
options = {:rs_name => replica_set, :refresh_mode => :sync}
|
106
|
+
options = {:rs_name => replica_set_string, :refresh_mode => :sync}
|
90
107
|
|
91
108
|
Mongo::MongoReplicaSetClient.should_receive(:new).with(anything, options).and_return(@mock_connection)
|
109
|
+
end
|
92
110
|
|
93
|
-
|
111
|
+
describe 'setting connection pool options' do
|
112
|
+
it 'supports setting pool size' do
|
113
|
+
Mordor::Config.use do |config|
|
114
|
+
config[:pool_size] = 1
|
115
|
+
end
|
116
|
+
options = {:pool_size => 1, :refresh_mode => :sync}
|
117
|
+
|
118
|
+
Mongo::MongoReplicaSetClient.should_receive(:new).with(anything, options).and_return(@mock_connection)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'supports setting pool timeout' do
|
122
|
+
Mordor::Config.use do |config|
|
123
|
+
config[:pool_timeout] = 1
|
124
|
+
end
|
125
|
+
|
126
|
+
options = {:pool_timeout => 1, :refresh_mode => :sync}
|
127
|
+
Mongo::MongoReplicaSetClient.should_receive(:new).with(anything, options).and_return(@mock_connection)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'supports setting both' do
|
131
|
+
Mordor::Config.use do |config|
|
132
|
+
config[:pool_size] = 5
|
133
|
+
config[:pool_timeout] = 1
|
134
|
+
config[:replica_set] = replica_set_string
|
135
|
+
end
|
136
|
+
options = {:pool_size => 5, :pool_timeout => 1, :refresh_mode => :sync, :rs_name => replica_set_string}
|
137
|
+
|
138
|
+
Mongo::MongoReplicaSetClient.should_receive(:new).with(anything, options).and_return(@mock_connection)
|
139
|
+
end
|
94
140
|
end
|
141
|
+
|
95
142
|
end
|
96
143
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,13 +15,7 @@ RSpec.configure do |config|
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def reset_mordor_config
|
18
|
-
Mordor::Config.
|
19
|
-
config[:username] = nil
|
20
|
-
config[:password] = nil
|
21
|
-
config[:hostname] = '127.0.0.1'
|
22
|
-
config[:port] = 27017
|
23
|
-
config[:database] = 'test'
|
24
|
-
end
|
18
|
+
Mordor::Config.reset
|
25
19
|
end
|
26
20
|
|
27
21
|
def drop_db_collections
|
@@ -45,5 +39,3 @@ end
|
|
45
39
|
def test_class_names
|
46
40
|
[:TestResource, :TestResource2, :TestTimedResource]
|
47
41
|
end
|
48
|
-
|
49
|
-
|
data/tasks/github-gem.rake
CHANGED
@@ -135,7 +135,7 @@ module GithubGem
|
|
135
135
|
|
136
136
|
desc "Release a new version of the gem using the VERSION environment variable"
|
137
137
|
task(:release => release_tasks) { release_task }
|
138
|
-
|
138
|
+
|
139
139
|
namespace(:release) do
|
140
140
|
desc "Release the next version of the gem, by incrementing the last version segment by 1"
|
141
141
|
task(:next => [:next_version] + release_tasks) { release_task }
|
@@ -161,7 +161,7 @@ module GithubGem
|
|
161
161
|
task(:next_patch_version) { next_version_task(:patch) }
|
162
162
|
task(:next_minor_version) { next_version_task(:minor) }
|
163
163
|
task(:next_major_version) { next_version_task(:major) }
|
164
|
-
|
164
|
+
|
165
165
|
desc "Updates the gem release tasks with the latest version on Github"
|
166
166
|
task(:update_tasks) { update_tasks_task }
|
167
167
|
end
|
@@ -198,11 +198,11 @@ module GithubGem
|
|
198
198
|
when :major then 0
|
199
199
|
else next_version.length - 1
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
next_version[increment_index] ||= 0
|
203
203
|
next_version[increment_index] = next_version[increment_index].succ
|
204
204
|
((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
|
205
|
-
|
205
|
+
|
206
206
|
Gem::Version.new(next_version.join('.'))
|
207
207
|
end
|
208
208
|
|
@@ -258,7 +258,7 @@ module GithubGem
|
|
258
258
|
|
259
259
|
# Adds a tag for the released version
|
260
260
|
def tag_version_task
|
261
|
-
sh git, 'tag', '-a', "#{gemspec.
|
261
|
+
sh git, 'tag', '-a', "v#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
|
262
262
|
end
|
263
263
|
|
264
264
|
# Pushes the changes and tag to github
|
@@ -334,7 +334,7 @@ module GithubGem
|
|
334
334
|
|
335
335
|
# Reload the gemspec so the changes are incorporated
|
336
336
|
load_gemspec!
|
337
|
-
|
337
|
+
|
338
338
|
# Also mark the Gemfile.lock file as changed because of the new version.
|
339
339
|
modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
|
340
340
|
end
|
@@ -344,7 +344,7 @@ module GithubGem
|
|
344
344
|
def update_tasks_task
|
345
345
|
require 'net/https'
|
346
346
|
require 'uri'
|
347
|
-
|
347
|
+
|
348
348
|
uri = URI.parse('https://raw.github.com/wvanbergen/github-gem/master/tasks/github-gem.rake')
|
349
349
|
http = Net::HTTP.new(uri.host, uri.port)
|
350
350
|
http.use_ssl = true
|
metadata
CHANGED
@@ -1,154 +1,142 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mordor
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 20
|
10
|
-
version: 0.2.20
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Jan-Willem Koelewijn
|
14
8
|
- Dirkjan Bussink
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
33
|
-
prerelease: false
|
34
|
-
type: :development
|
35
|
-
requirement: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rspec
|
38
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 3
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 0
|
47
|
-
version: "2.0"
|
12
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: extlib
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
48
22
|
prerelease: false
|
49
|
-
|
50
|
-
|
51
|
-
- !
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
52
29
|
name: json
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
62
36
|
prerelease: false
|
63
|
-
|
64
|
-
|
65
|
-
- !
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: mongo
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - <
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :runtime
|
76
50
|
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - <
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rack-test
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
77
63
|
type: :development
|
78
|
-
requirement: *id004
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: mongo
|
81
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
hash: 3
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
90
64
|
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
91
77
|
type: :development
|
92
|
-
requirement: *id005
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
name: extlib
|
95
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
|
-
requirements:
|
98
|
-
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
hash: 3
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
version: "0"
|
104
78
|
prerelease: false
|
105
|
-
|
106
|
-
|
107
|
-
- !
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.0'
|
91
|
+
- - <
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.99'
|
94
|
+
type: :development
|
118
95
|
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ~>
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '2.0'
|
101
|
+
- - <
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.99'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: bson_ext
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
119
111
|
type: :runtime
|
120
|
-
requirement: *id007
|
121
|
-
- !ruby/object:Gem::Dependency
|
122
|
-
name: json
|
123
|
-
version_requirements: &id008 !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
|
-
requirements:
|
126
|
-
- - ">="
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
hash: 3
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
version: "0"
|
132
112
|
prerelease: false
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
description: ! ' Small gem to add MongoDB Resources, resources have attributes
|
119
|
+
that translate into document fields. When an attribute is declared, finders for
|
120
|
+
the attribute are added to the Resource automatically
|
121
|
+
|
122
|
+
'
|
123
|
+
email:
|
137
124
|
- janwillem.koelewijn@nedap.com
|
138
125
|
- dirkjan.bussink@nedap.com
|
139
126
|
executables: []
|
140
|
-
|
141
|
-
|
142
|
-
|
127
|
+
extensions:
|
128
|
+
- ext/mkrf_conf.rb
|
143
129
|
extra_rdoc_files: []
|
144
|
-
|
145
|
-
files:
|
130
|
+
files:
|
146
131
|
- .gitignore
|
147
132
|
- .travis.yml
|
133
|
+
- CHANGES.md
|
148
134
|
- Gemfile
|
135
|
+
- Guardfile
|
149
136
|
- LICENSE
|
150
137
|
- README.md
|
151
138
|
- Rakefile
|
139
|
+
- ext/mkrf_conf.rb
|
152
140
|
- lib/mordor.rb
|
153
141
|
- lib/mordor/collection.rb
|
154
142
|
- lib/mordor/config.rb
|
@@ -161,39 +149,27 @@ files:
|
|
161
149
|
- spec/spec.opts
|
162
150
|
- spec/spec_helper.rb
|
163
151
|
- tasks/github-gem.rake
|
164
|
-
has_rdoc: true
|
165
152
|
homepage: http://www.nedap.com
|
166
153
|
licenses: []
|
167
|
-
|
154
|
+
metadata: {}
|
168
155
|
post_install_message:
|
169
156
|
rdoc_options: []
|
170
|
-
|
171
|
-
require_paths:
|
157
|
+
require_paths:
|
172
158
|
- lib
|
173
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
none: false
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
hash: 3
|
188
|
-
segments:
|
189
|
-
- 0
|
190
|
-
version: "0"
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ! '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
191
169
|
requirements: []
|
192
|
-
|
193
170
|
rubyforge_project:
|
194
|
-
rubygems_version:
|
171
|
+
rubygems_version: 2.4.5
|
195
172
|
signing_key:
|
196
|
-
specification_version:
|
173
|
+
specification_version: 4
|
197
174
|
summary: mordor
|
198
175
|
test_files: []
|
199
|
-
|