db-charmer 1.7.0.pre3 → 1.7.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/db-charmer.gemspec +36 -37
- data/lib/db_charmer.rb +26 -14
- data/lib/db_charmer/sharding.rb +4 -1
- data/lib/db_charmer/sharding/method.rb +10 -0
- data/lib/db_charmer/version.rb +1 -1
- metadata +6 -6
- data/.gitignore +0 -2
data/db-charmer.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{db-charmer}
|
8
|
-
s.version = "1.7.0.
|
8
|
+
s.version = "1.7.0.pre4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alexey Kovyrin"]
|
@@ -14,45 +14,44 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = %q{alexey@kovyrin.net}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
20
|
+
"CHANGES",
|
21
|
+
"LICENSE",
|
22
|
+
"Makefile",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"db-charmer.gemspec",
|
26
|
+
"init.rb",
|
27
|
+
"lib/db_charmer.rb",
|
28
|
+
"lib/db_charmer/abstract_adapter/log_formatting.rb",
|
29
|
+
"lib/db_charmer/action_controller/force_slave_reads.rb",
|
30
|
+
"lib/db_charmer/active_record/association_preload.rb",
|
31
|
+
"lib/db_charmer/active_record/class_attributes.rb",
|
32
|
+
"lib/db_charmer/active_record/connection_switching.rb",
|
33
|
+
"lib/db_charmer/active_record/db_magic.rb",
|
34
|
+
"lib/db_charmer/active_record/finder_overrides.rb",
|
35
|
+
"lib/db_charmer/active_record/migration/multi_db_migrations.rb",
|
36
|
+
"lib/db_charmer/active_record/multi_db_proxy.rb",
|
37
|
+
"lib/db_charmer/active_record/named_scope/scope_proxy.rb",
|
38
|
+
"lib/db_charmer/active_record/sharding.rb",
|
39
|
+
"lib/db_charmer/connection_factory.rb",
|
40
|
+
"lib/db_charmer/connection_proxy.rb",
|
41
|
+
"lib/db_charmer/core_extensions.rb",
|
42
|
+
"lib/db_charmer/force_slave_reads.rb",
|
43
|
+
"lib/db_charmer/sharding.rb",
|
44
|
+
"lib/db_charmer/sharding/connection.rb",
|
45
|
+
"lib/db_charmer/sharding/method.rb",
|
46
|
+
"lib/db_charmer/sharding/method/db_block_group_map.rb",
|
47
|
+
"lib/db_charmer/sharding/method/db_block_map.rb",
|
48
|
+
"lib/db_charmer/sharding/method/hash_map.rb",
|
49
|
+
"lib/db_charmer/sharding/method/range.rb",
|
50
|
+
"lib/db_charmer/sharding/stub_connection.rb",
|
51
|
+
"lib/db_charmer/version.rb",
|
52
|
+
"lib/tasks/databases.rake"
|
53
53
|
]
|
54
54
|
s.homepage = %q{http://github.com/kovyrin/db-charmer}
|
55
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
56
55
|
s.require_paths = ["lib"]
|
57
56
|
s.rubygems_version = %q{1.6.2}
|
58
57
|
s.summary = %q{ActiveRecord Connections Magic}
|
data/lib/db_charmer.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module DbCharmer
|
2
|
+
# Accessors
|
2
3
|
@@connections_should_exist = true
|
3
4
|
mattr_accessor :connections_should_exist
|
4
5
|
|
@@ -66,25 +67,30 @@ require 'db_charmer/connection_proxy'
|
|
66
67
|
require 'db_charmer/force_slave_reads'
|
67
68
|
|
68
69
|
# Add our custom class-level attributes to AR models
|
69
|
-
|
70
|
+
require 'db_charmer/active_record/class_attributes'
|
71
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::ClassAttributes)
|
70
72
|
|
71
73
|
# Enable connections switching in AR
|
72
|
-
|
74
|
+
require 'db_charmer/active_record/connection_switching'
|
75
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::ConnectionSwitching)
|
73
76
|
|
74
77
|
# Enable misc AR extensions
|
75
|
-
|
78
|
+
require 'db_charmer/abstract_adapter/log_formatting'
|
79
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, DbCharmer::AbstractAdapter::LogFormatting)
|
76
80
|
|
77
81
|
# Enable connection proxy in AR
|
78
|
-
|
79
|
-
|
80
|
-
|
82
|
+
require 'db_charmer/active_record/multi_db_proxy'
|
83
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::MultiDbProxy::ClassMethods)
|
84
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::MultiDbProxy::MasterSlaveClassMethods)
|
85
|
+
ActiveRecord::Base.send(:include, DbCharmer::ActiveRecord::MultiDbProxy::InstanceMethods)
|
81
86
|
|
82
87
|
# Enable connection proxy for scopes
|
83
|
-
|
88
|
+
require 'db_charmer/active_record/named_scope/scope_proxy'
|
89
|
+
ActiveRecord::NamedScope::Scope.send(:include, DbCharmer::ActiveRecord::NamedScope::ScopeProxy)
|
84
90
|
|
85
91
|
# Enable connection proxy for associations
|
86
92
|
# WARNING: Inject methods to association class right here (they proxy include calls somewhere else, so include does not work)
|
87
|
-
module
|
93
|
+
module ActiveRecord
|
88
94
|
module Associations
|
89
95
|
class AssociationProxy
|
90
96
|
def proxy?
|
@@ -108,16 +114,21 @@ module ::ActiveRecord
|
|
108
114
|
end
|
109
115
|
|
110
116
|
# Enable multi-db migrations
|
111
|
-
|
117
|
+
require 'db_charmer/active_record/migration/multi_db_migrations'
|
118
|
+
ActiveRecord::Migration.extend(DbCharmer::ActiveRecord::Migration::MultiDbMigrations)
|
112
119
|
|
113
120
|
# Enable the magic
|
114
|
-
|
121
|
+
require 'db_charmer/active_record/finder_overrides'
|
122
|
+
require 'db_charmer/active_record/sharding'
|
123
|
+
require 'db_charmer/active_record/db_magic'
|
124
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::DbMagic)
|
115
125
|
|
116
126
|
# Setup association preload magic
|
117
|
-
|
127
|
+
require 'db_charmer/active_record/association_preload'
|
128
|
+
ActiveRecord::Base.extend(DbCharmer::ActiveRecord::AssociationPreload)
|
118
129
|
|
119
130
|
# Open up really useful API method
|
120
|
-
|
131
|
+
ActiveRecord::AssociationPreload::ClassMethods.send(:public, :preload_associations)
|
121
132
|
|
122
133
|
class ::ActiveRecord::Base
|
123
134
|
class << self
|
@@ -133,5 +144,6 @@ end
|
|
133
144
|
|
134
145
|
#-----------------------------------------------------------------------------------------------------------------------
|
135
146
|
# Extend ActionController to support forcing slave reads
|
136
|
-
|
137
|
-
|
147
|
+
require 'db_charmer/action_controller/force_slave_reads'
|
148
|
+
ActionController::Base.extend(DbCharmer::ActionController::ForceSlaveReads::ClassMethods)
|
149
|
+
ActionController::Base.send(:include, DbCharmer::ActionController::ForceSlaveReads::InstanceMethods)
|
data/lib/db_charmer/sharding.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module DbCharmer
|
2
2
|
module Sharding
|
3
|
+
autoload :Connection, 'db_charmer/sharding/connection'
|
4
|
+
autoload :StubConnection, 'db_charmer/sharding/stub_connection'
|
5
|
+
autoload :Method, 'db_charmer/sharding/method'
|
6
|
+
|
3
7
|
@@sharded_connections = {}
|
4
8
|
|
5
9
|
def self.register_connection(config)
|
@@ -12,4 +16,3 @@ module DbCharmer
|
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
15
|
-
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module DbCharmer
|
2
|
+
module Sharding
|
3
|
+
module Method
|
4
|
+
autoload :Range, 'db_charmer/sharding/method/range'
|
5
|
+
autoload :HashMap, 'db_charmer/sharding/method/hash_map'
|
6
|
+
autoload :DbBlockMap, 'db_charmer/sharding/method/db_block_map'
|
7
|
+
autoload :DbBlockGroupMap, 'db_charmer/sharding/method/db_block_group_map'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/db_charmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-charmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923832049
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 1.7.0.
|
11
|
+
- 4
|
12
|
+
version: 1.7.0.pre4
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Alexey Kovyrin
|
@@ -75,7 +75,6 @@ extra_rdoc_files:
|
|
75
75
|
- LICENSE
|
76
76
|
- README.rdoc
|
77
77
|
files:
|
78
|
-
- .gitignore
|
79
78
|
- CHANGES
|
80
79
|
- LICENSE
|
81
80
|
- Makefile
|
@@ -101,6 +100,7 @@ files:
|
|
101
100
|
- lib/db_charmer/force_slave_reads.rb
|
102
101
|
- lib/db_charmer/sharding.rb
|
103
102
|
- lib/db_charmer/sharding/connection.rb
|
103
|
+
- lib/db_charmer/sharding/method.rb
|
104
104
|
- lib/db_charmer/sharding/method/db_block_group_map.rb
|
105
105
|
- lib/db_charmer/sharding/method/db_block_map.rb
|
106
106
|
- lib/db_charmer/sharding/method/hash_map.rb
|
@@ -113,8 +113,8 @@ homepage: http://github.com/kovyrin/db-charmer
|
|
113
113
|
licenses: []
|
114
114
|
|
115
115
|
post_install_message:
|
116
|
-
rdoc_options:
|
117
|
-
|
116
|
+
rdoc_options: []
|
117
|
+
|
118
118
|
require_paths:
|
119
119
|
- lib
|
120
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/.gitignore
DELETED