db-charmer 1.7.0.pre5 → 1.7.0.pre6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /doc
2
+ /pkg
3
+ .DS_Store
data/README.rdoc CHANGED
@@ -292,8 +292,8 @@ send their reads to slaves. Example:
292
292
 
293
293
  3) <tt>force_slave_reads!</tt> +ActionController+ instance method, that could be used within
294
294
  your actions or in controller filters to temporarily switch your models to forced slave reads
295
- mode. This could be useful for cases when the same actions could be called by logged-in and
296
- anonymous users. Then you could authorize users in <tt>before_filter</tt> and call
295
+ mode. This method could be useful for cases when the same actions could be called by logged-in
296
+ and anonymous users. Then you could authorize users in <tt>before_filter</tt> and call
297
297
  <tt>force_slave_reads!</tt> method for anonymous page views.
298
298
 
299
299
  class ProfilesController < Application
@@ -303,6 +303,10 @@ anonymous users. Then you could authorize users in <tt>before_filter</tt> and ca
303
303
  ...
304
304
  end
305
305
 
306
+ Notice: Before using this method you need to enable +ActionController+ support in +DbCharmer+.
307
+ You need to call <tt>DbCharmer.enable_controller_magic!</tt> method from your project
308
+ initialization code.
309
+
306
310
  4) <tt>DbCharmer.force_slave_reads</tt> method that could be used with a block of ruby code
307
311
  and would enable forced slave reads mode until the end of the block execution. This is really
308
312
  powerful feature allowing high granularity in your control of forced slave reads mode. Example:
data/Rakefile CHANGED
@@ -1,22 +1,4 @@
1
- begin
2
- require 'jeweler'
3
- require './lib/db_charmer/version.rb'
1
+ require 'rake'
2
+ require 'bundler'
4
3
 
5
- Jeweler::Tasks.new do |gemspec|
6
- gemspec.name = 'db-charmer'
7
- gemspec.summary = 'ActiveRecord Connections Magic'
8
- gemspec.description = 'ActiveRecord Connections Magic (slaves, multiple connections, etc)'
9
- gemspec.email = 'alexey@kovyrin.net'
10
- gemspec.homepage = 'http://github.com/kovyrin/db-charmer'
11
- gemspec.authors = ['Alexey Kovyrin']
12
-
13
- gemspec.version = DbCharmer::Version::STRING
14
-
15
- gemspec.add_dependency('activesupport', '~> 2.2')
16
- gemspec.add_dependency('activerecord', '~> 2.2')
17
- gemspec.add_dependency('actionpack', '~> 2.2')
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts 'Jeweler not available. Install it with: sudo gem install jeweler'
22
- end
4
+ Bundler::GemHelper.install_tasks
data/db-charmer.gemspec CHANGED
@@ -1,77 +1,30 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'db_charmer/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{db-charmer}
8
- s.version = "1.7.0.pre5"
6
+ s.name = 'db-charmer'
7
+ s.version = DbCharmer::Version::STRING
8
+ s.platform = Gem::Platform::RUBY
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Alexey Kovyrin"]
12
- s.date = %q{2011-06-21}
13
- s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
14
- s.email = %q{alexey@kovyrin.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
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
- ]
54
- s.homepage = %q{http://github.com/kovyrin/db-charmer}
55
- s.require_paths = ["lib"]
56
- s.rubygems_version = %q{1.6.2}
57
- s.summary = %q{ActiveRecord Connections Magic}
10
+ s.authors = [ 'Alexey Kovyrin' ]
11
+ s.email = 'alexey@kovyrin.net'
12
+ s.homepage = 'http://github.com/kovyrin/db-charmer'
13
+ s.summary = 'ActiveRecord Connections Magic (slaves, multiple connections, etc)'
14
+ s.description = 'DbCharmer is a Rails plugin (and gem) that could be used to manage AR model connections, implement master/slave query schemes, sharding and other magic features many high-scale applications need.'
58
15
 
59
- if s.respond_to? :specification_version then
60
- s.specification_version = 3
16
+ s.rdoc_options = [ '--charset=UTF-8' ]
61
17
 
62
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
- s.add_runtime_dependency(%q<activesupport>, ["~> 2.2"])
64
- s.add_runtime_dependency(%q<activerecord>, ["~> 2.2"])
65
- s.add_runtime_dependency(%q<actionpack>, ["~> 2.2"])
66
- else
67
- s.add_dependency(%q<activesupport>, ["~> 2.2"])
68
- s.add_dependency(%q<activerecord>, ["~> 2.2"])
69
- s.add_dependency(%q<actionpack>, ["~> 2.2"])
70
- end
71
- else
72
- s.add_dependency(%q<activesupport>, ["~> 2.2"])
73
- s.add_dependency(%q<activerecord>, ["~> 2.2"])
74
- s.add_dependency(%q<actionpack>, ["~> 2.2"])
75
- end
18
+ s.add_development_dependency 'rspec'
19
+ s.add_development_dependency 'yard'
20
+ s.add_development_dependency 'actionpack'
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.require_paths = [ 'lib' ]
24
+ s.extra_rdoc_files = [ 'LICENSE', 'README.rdoc' ]
25
+
26
+ # Dependencies
27
+ s.add_dependency 'activesupport', '~> 2.2'
28
+ s.add_dependency 'activerecord', '~> 2.2'
76
29
  end
77
30
 
data/lib/db_charmer.rb CHANGED
@@ -2,6 +2,9 @@ module DbCharmer
2
2
  # Configure autoload
3
3
  autoload :Sharding, 'db_charmer/sharding'
4
4
  autoload :Version, 'db_charmer/version'
5
+ module ActionController
6
+ autoload :ForceSlaveReads, 'db_charmer/action_controller/force_slave_reads'
7
+ end
5
8
 
6
9
  # Accessors
7
10
  @@connections_should_exist = true
@@ -23,6 +26,12 @@ module DbCharmer
23
26
  !! connections_should_exist
24
27
  end
25
28
 
29
+ # Extend ActionController to support forcing slave reads
30
+ def self.enable_controller_magic!
31
+ ::ActionController::Base.extend(DbCharmer::ActionController::ForceSlaveReads::ClassMethods)
32
+ ::ActionController::Base.send(:include, DbCharmer::ActionController::ForceSlaveReads::InstanceMethods)
33
+ end
34
+
26
35
  def self.logger
27
36
  return Rails.logger if defined?(Rails)
28
37
  @logger ||= Logger.new(STDERR)
@@ -145,9 +154,3 @@ class ::ActiveRecord::Base
145
154
  alias_method_chain :inherited, :hijacking
146
155
  end
147
156
  end
148
-
149
- #-----------------------------------------------------------------------------------------------------------------------
150
- # Extend ActionController to support forcing slave reads
151
- require 'db_charmer/action_controller/force_slave_reads'
152
- ActionController::Base.extend(DbCharmer::ActionController::ForceSlaveReads::ClassMethods)
153
- ActionController::Base.send(:include, DbCharmer::ActionController::ForceSlaveReads::InstanceMethods)
@@ -3,7 +3,7 @@ module DbCharmer
3
3
  MAJOR = 1
4
4
  MINOR = 7
5
5
  PATCH = 0
6
- BUILD = 'pre5'
6
+ BUILD = 'pre6'
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
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: 1923832051
4
+ hash: 1923832053
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
9
  - 0
10
10
  - pre
11
- - 5
12
- version: 1.7.0.pre5
11
+ - 6
12
+ version: 1.7.0.pre6
13
13
  platform: ruby
14
14
  authors:
15
15
  - Alexey Kovyrin
@@ -17,28 +17,55 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-06-21 00:00:00 -04:00
20
+ date: 2011-06-27 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- name: activesupport
24
+ name: rspec
25
25
  prerelease: false
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ~>
29
+ - - ">="
30
30
  - !ruby/object:Gem::Version
31
- hash: 7
31
+ hash: 3
32
32
  segments:
33
- - 2
34
- - 2
35
- version: "2.2"
36
- type: :runtime
33
+ - 0
34
+ version: "0"
35
+ type: :development
37
36
  version_requirements: *id001
38
37
  - !ruby/object:Gem::Dependency
39
- name: activerecord
38
+ name: yard
40
39
  prerelease: false
41
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: actionpack
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: activesupport
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
42
69
  none: false
43
70
  requirements:
44
71
  - - ~>
@@ -49,11 +76,11 @@ dependencies:
49
76
  - 2
50
77
  version: "2.2"
51
78
  type: :runtime
52
- version_requirements: *id002
79
+ version_requirements: *id004
53
80
  - !ruby/object:Gem::Dependency
54
- name: actionpack
81
+ name: activerecord
55
82
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
57
84
  none: false
58
85
  requirements:
59
86
  - - ~>
@@ -64,8 +91,8 @@ dependencies:
64
91
  - 2
65
92
  version: "2.2"
66
93
  type: :runtime
67
- version_requirements: *id003
68
- description: ActiveRecord Connections Magic (slaves, multiple connections, etc)
94
+ version_requirements: *id005
95
+ description: DbCharmer is a Rails plugin (and gem) that could be used to manage AR model connections, implement master/slave query schemes, sharding and other magic features many high-scale applications need.
69
96
  email: alexey@kovyrin.net
70
97
  executables: []
71
98
 
@@ -75,6 +102,7 @@ extra_rdoc_files:
75
102
  - LICENSE
76
103
  - README.rdoc
77
104
  files:
105
+ - .gitignore
78
106
  - CHANGES
79
107
  - LICENSE
80
108
  - Makefile
@@ -113,8 +141,8 @@ homepage: http://github.com/kovyrin/db-charmer
113
141
  licenses: []
114
142
 
115
143
  post_install_message:
116
- rdoc_options: []
117
-
144
+ rdoc_options:
145
+ - --charset=UTF-8
118
146
  require_paths:
119
147
  - lib
120
148
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -143,6 +171,6 @@ rubyforge_project:
143
171
  rubygems_version: 1.6.2
144
172
  signing_key:
145
173
  specification_version: 3
146
- summary: ActiveRecord Connections Magic
174
+ summary: ActiveRecord Connections Magic (slaves, multiple connections, etc)
147
175
  test_files: []
148
176