genghis 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -2
- data/lib/genghis.rb +14 -4
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
= Genghis - a MongoDB configuration and resilience
|
2
2
|
|
3
3
|
== What is Genghis?
|
4
|
-
|
5
|
-
|
4
|
+
* A configuration framework for mongoDB
|
5
|
+
* A resilience framework when using MongoDB in replica pairs
|
6
6
|
|
7
7
|
== Getting started
|
8
8
|
|
@@ -64,6 +64,11 @@ Database names can then be used to configure mongo mapper or any other framework
|
|
64
64
|
|
65
65
|
MongoMapper.database = Genghis.databases['mongo_mapper']
|
66
66
|
|
67
|
+
Similarly you can retrieve the actual mongo database
|
68
|
+
|
69
|
+
db = Genghis.database('paperclip')
|
70
|
+
db.collections
|
71
|
+
...
|
67
72
|
|
68
73
|
== Resilience
|
69
74
|
|
data/lib/genghis.rb
CHANGED
@@ -4,11 +4,12 @@ require 'mongo'
|
|
4
4
|
class Genghis
|
5
5
|
include Mongo
|
6
6
|
|
7
|
-
def self.
|
8
|
-
|
9
|
-
|
7
|
+
def self.config=(path)
|
8
|
+
puts "Setting config to #{path}"
|
9
|
+
@@config_file = path
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
+
def self.environment=(environment = :development)
|
12
13
|
yaml = YAML.load_file(config_file)
|
13
14
|
@@config = yaml[environment.to_s]
|
14
15
|
@@config.each do |k, v|
|
@@ -32,6 +33,15 @@ class Genghis
|
|
32
33
|
|
33
34
|
private
|
34
35
|
|
36
|
+
def self.config_file
|
37
|
+
if defined? @@config_file
|
38
|
+
@@config_file
|
39
|
+
else
|
40
|
+
base = defined?(Rails) ? Rails.root : File.dirname(__FILE__)
|
41
|
+
File.join(base, 'config', 'mongodb.yml')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
35
45
|
def self.max_retries
|
36
46
|
connection_options
|
37
47
|
@@retries || 5
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 2
|
9
|
+
version: 1.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Steve Cohen
|
@@ -14,7 +14,7 @@ autorequire: genghis
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-18 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|