genghis 1.0.1 → 1.0.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.
Files changed (3) hide show
  1. data/README.rdoc +7 -2
  2. data/lib/genghis.rb +14 -4
  3. metadata +3 -3
@@ -1,8 +1,8 @@
1
1
  = Genghis - a MongoDB configuration and resilience
2
2
 
3
3
  == What is Genghis?
4
- * A configuration framework for mongoDB
5
- * A resilience framework when using MongoDB in replica pairs
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
 
@@ -4,11 +4,12 @@ require 'mongo'
4
4
  class Genghis
5
5
  include Mongo
6
6
 
7
- def self.environment=(environment = :development)
8
- base = File.dirname(__FILE__)
9
- base = Rails.root if defined?(Rails)
7
+ def self.config=(path)
8
+ puts "Setting config to #{path}"
9
+ @@config_file = path
10
+ end
10
11
 
11
- config_file = File.join(base,'config', 'mongodb.yml')
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
- - 1
9
- version: 1.0.1
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-15 00:00:00 -07:00
17
+ date: 2010-03-18 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency