multi_db 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -5
- data/lib/multi_db/active_record_extensions.rb +2 -2
- data/lib/multi_db/connection_proxy.rb +3 -3
- data/lib/multi_db/scheduler.rb +1 -1
- data/multi_db.gemspec +3 -2
- data/spec/connection_proxy_spec.rb +0 -2
- data/spec/spec_helper.rb +6 -2
- metadata +38 -15
data/README.rdoc
CHANGED
@@ -28,13 +28,15 @@ master database.
|
|
28
28
|
* works with activerecord 2.1, 2.2, 2.3, and 3.0
|
29
29
|
|
30
30
|
=== Install
|
31
|
+
==== Rails 2
|
32
|
+
gem install multi_db
|
31
33
|
|
32
|
-
|
33
|
-
gem
|
34
|
+
Then add this to your environment.rb:
|
35
|
+
config.gem 'multi_db', :lib => 'multi_db'
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
==== Rails 3
|
38
|
+
put this in your Gemfile
|
39
|
+
gem 'multi_db'
|
38
40
|
|
39
41
|
=== Setup
|
40
42
|
|
@@ -18,7 +18,7 @@ module MultiDb
|
|
18
18
|
|
19
19
|
module ClassMethods
|
20
20
|
# Make sure transactions always switch to the master
|
21
|
-
def transaction(&block)
|
21
|
+
def transaction(options = {}, &block)
|
22
22
|
if self.connection.kind_of?(ConnectionProxy)
|
23
23
|
super
|
24
24
|
else
|
@@ -51,4 +51,4 @@ module MultiDb
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
@@ -23,7 +23,7 @@ module MultiDb
|
|
23
23
|
|
24
24
|
class << self
|
25
25
|
|
26
|
-
# defaults to
|
26
|
+
# defaults to Rails.env if multi_db is used with Rails
|
27
27
|
# defaults to 'development' when used outside Rails
|
28
28
|
attr_accessor :environment
|
29
29
|
|
@@ -47,7 +47,7 @@ module MultiDb
|
|
47
47
|
# establishes the connections to the slaves.
|
48
48
|
def setup!(scheduler = Scheduler)
|
49
49
|
self.master_models ||= DEFAULT_MASTER_MODELS
|
50
|
-
self.environment ||= (defined?(
|
50
|
+
self.environment ||= (defined?(Rails) ? Rails.env : 'development')
|
51
51
|
self.sticky_slave ||= false
|
52
52
|
|
53
53
|
master = ActiveRecord::Base
|
@@ -218,4 +218,4 @@ module MultiDb
|
|
218
218
|
end
|
219
219
|
|
220
220
|
end
|
221
|
-
end
|
221
|
+
end
|
data/lib/multi_db/scheduler.rb
CHANGED
data/multi_db.gemspec
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
# -*- encoding: utf-8 -*-
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = %q{multi_db}
|
5
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.1"
|
6
7
|
|
7
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
9
|
s.authors = ["Maximilian Sch\303\266fmann"]
|
9
|
-
s.date = %q{
|
10
|
+
s.date = %q{2012-03-29}
|
10
11
|
s.description = "Connection proxy for ActiveRecord for single master / multiple slave database deployments"
|
11
12
|
s.email = "max@pragmatic-it.de"
|
12
13
|
s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
|
@@ -5,8 +5,6 @@ require MULTI_DB_SPEC_DIR + '/../lib/multi_db/observer_extensions'
|
|
5
5
|
require MULTI_DB_SPEC_DIR + '/../lib/multi_db/scheduler'
|
6
6
|
require MULTI_DB_SPEC_DIR + '/../lib/multi_db/connection_proxy'
|
7
7
|
|
8
|
-
RAILS_ROOT = MULTI_DB_SPEC_DIR
|
9
|
-
|
10
8
|
describe MultiDb::ConnectionProxy do
|
11
9
|
|
12
10
|
before(:all) do
|
data/spec/spec_helper.rb
CHANGED
@@ -2,10 +2,14 @@ require 'rubygems'
|
|
2
2
|
gem 'activerecord', '3.0.5'
|
3
3
|
%w[tlattr_accessors active_record yaml erb rspec logger].each {|lib| require lib}
|
4
4
|
|
5
|
-
|
5
|
+
module Rails
|
6
|
+
def self.env
|
7
|
+
ActiveSupport::StringInquirer.new("test")
|
8
|
+
end
|
9
|
+
end
|
6
10
|
|
7
11
|
MULTI_DB_SPEC_DIR = File.dirname(__FILE__)
|
8
12
|
MULTI_DB_SPEC_CONFIG = YAML::load(File.open(MULTI_DB_SPEC_DIR + '/config/database.yml'))
|
9
13
|
|
10
14
|
ActiveRecord::Base.logger = Logger.new(MULTI_DB_SPEC_DIR + "/debug.log")
|
11
|
-
ActiveRecord::Base.configurations = MULTI_DB_SPEC_CONFIG
|
15
|
+
ActiveRecord::Base.configurations = MULTI_DB_SPEC_CONFIG
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- "Maximilian Sch\xC3\xB6fmann"
|
@@ -9,29 +15,40 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2012-03-29 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: activerecord
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 11
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 1
|
32
|
+
- 0
|
23
33
|
version: 2.1.0
|
24
|
-
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: tlattr_accessors
|
27
|
-
|
28
|
-
|
29
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
30
41
|
requirements:
|
31
42
|
- - ">="
|
32
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 25
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
- 3
|
33
49
|
version: 0.0.3
|
34
|
-
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
35
52
|
description: Connection proxy for ActiveRecord for single master / multiple slave database deployments
|
36
53
|
email: max@pragmatic-it.de
|
37
54
|
executables: []
|
@@ -55,7 +72,6 @@ files:
|
|
55
72
|
- spec/scheduler_spec.rb
|
56
73
|
- spec/spec_helper.rb
|
57
74
|
- multi_db.gemspec
|
58
|
-
has_rdoc: true
|
59
75
|
homepage: http://github.com/schoefmax/multi_db
|
60
76
|
licenses: []
|
61
77
|
|
@@ -70,21 +86,28 @@ rdoc_options:
|
|
70
86
|
require_paths:
|
71
87
|
- lib
|
72
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
73
90
|
requirements:
|
74
91
|
- - ">="
|
75
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
94
|
+
segments:
|
95
|
+
- 0
|
76
96
|
version: "0"
|
77
|
-
version:
|
78
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
79
99
|
requirements:
|
80
100
|
- - ">="
|
81
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 11
|
103
|
+
segments:
|
104
|
+
- 1
|
105
|
+
- 2
|
82
106
|
version: "1.2"
|
83
|
-
version:
|
84
107
|
requirements: []
|
85
108
|
|
86
109
|
rubyforge_project: multi_db
|
87
|
-
rubygems_version: 1.
|
110
|
+
rubygems_version: 1.8.17
|
88
111
|
signing_key:
|
89
112
|
specification_version: 2
|
90
113
|
summary: Connection proxy for ActiveRecord for single master / multiple slave database deployments
|