seamless_database_pool 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ module SeamlessDatabasePool
2
+ class TestModel < ActiveRecord::Base
3
+ class << self
4
+ def database_configs
5
+ adapters = ENV['TEST_ADAPTERS'].blank? ? [] : ENV['TEST_ADAPTERS'].split(/\s+/)
6
+ configs = {}
7
+ YAML.load_file(File.expand_path("../database.yml", __FILE__)).each do |adapter_name, adapter_config|
8
+ configs[adapter_name] = adapter_config if adapters.include?(adapter_name)
9
+ end
10
+ configs
11
+ end
12
+
13
+ def use_database_connection (db_name)
14
+ establish_connection(database_configs[db_name.to_s])
15
+ end
16
+
17
+ def db_model (db_name)
18
+ model_class_name = db_name.classify
19
+ unless const_defined?(model_class_name)
20
+ klass = Class.new(self)
21
+ const_set(model_class_name, klass)
22
+ end
23
+ const_get(model_class_name)
24
+ end
25
+
26
+ def create_tables
27
+ connection.create_table(table_name) do |t|
28
+ t.column :name, :string
29
+ t.column :value, :integer
30
+ end unless table_exists?
31
+ end
32
+
33
+ def drop_tables
34
+ connection.drop_table(table_name)
35
+ end
36
+
37
+ def cleanup_database!
38
+ connection.disconnect!
39
+ sqlite3_config = database_configs['sqlite3']
40
+ if sqlite3_config && File.exist?(sqlite3_config['database'])
41
+ File.delete(sqlite3_config['database'])
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seamless_database_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 6
10
+ version: 1.0.6
5
11
  platform: ruby
6
12
  authors:
7
13
  - Brian Durand
@@ -9,39 +15,55 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-07 00:00:00 -06:00
18
+ date: 2010-10-20 00:00:00 -05:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: activerecord
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 2
33
+ - 2
23
34
  version: 2.2.2
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 13
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 9
33
50
  version: 1.2.9
34
- version:
51
+ type: :development
52
+ version_requirements: *id002
35
53
  - !ruby/object:Gem::Dependency
36
54
  name: jeweler
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - ">="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
43
64
  version: "0"
44
- version:
65
+ type: :development
66
+ version_requirements: *id003
45
67
  description:
46
68
  email: brian@embellishedvisions.com
47
69
  executables: []
@@ -51,23 +73,23 @@ extensions: []
51
73
  extra_rdoc_files:
52
74
  - README.rdoc
53
75
  files:
54
- - MIT-LICENSE
55
76
  - README.rdoc
56
77
  - Rakefile
57
- - VERSION
58
- - init.rb
59
78
  - lib/active_record/connection_adapters/seamless_database_pool_adapter.rb
60
79
  - lib/seamless_database_pool.rb
80
+ - lib/seamless_database_pool/arel_compiler.rb
61
81
  - lib/seamless_database_pool/connect_timeout.rb
62
82
  - lib/seamless_database_pool/connection_statistics.rb
63
83
  - lib/seamless_database_pool/controller_filter.rb
64
- - seamless_database_pool.gemspec
84
+ - spec/connection_adapters_spec.rb
65
85
  - spec/connection_statistics_spec.rb
86
+ - spec/database.yml
66
87
  - spec/filter_spec.rb
67
88
  - spec/seamless_database_pool_adapter_spec.rb
68
89
  - spec/seamless_database_pool_spec.rb
69
90
  - spec/spec_helper.rb
70
- - spec/test_models.rb
91
+ - spec/test_adapter/active_record/connection_adapters/read_only_adapter.rb
92
+ - spec/test_model.rb
71
93
  has_rdoc: true
72
94
  homepage: http://github.com/bdurand/seamless_database_pool
73
95
  licenses: []
@@ -78,28 +100,36 @@ rdoc_options:
78
100
  require_paths:
79
101
  - lib
80
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
81
104
  requirements:
82
105
  - - ">="
83
106
  - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
84
110
  version: "0"
85
- version:
86
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
87
113
  requirements:
88
114
  - - ">="
89
115
  - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
90
119
  version: "0"
91
- version:
92
120
  requirements: []
93
121
 
94
122
  rubyforge_project:
95
- rubygems_version: 1.3.5
123
+ rubygems_version: 1.3.7
96
124
  signing_key:
97
125
  specification_version: 3
98
126
  summary: Add support for master/slave database clusters in ActiveRecord to improve performance.
99
127
  test_files:
128
+ - spec/connection_adapters_spec.rb
100
129
  - spec/connection_statistics_spec.rb
101
130
  - spec/filter_spec.rb
102
131
  - spec/seamless_database_pool_adapter_spec.rb
103
132
  - spec/seamless_database_pool_spec.rb
104
133
  - spec/spec_helper.rb
105
- - spec/test_models.rb
134
+ - spec/test_adapter/active_record/connection_adapters/read_only_adapter.rb
135
+ - spec/test_model.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 Brian Durand
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.5
data/init.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'seamless_database_pool'
2
-
@@ -1,69 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{seamless_database_pool}
8
- s.version = "1.0.5"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Brian Durand"]
12
- s.date = %q{2010-02-07}
13
- s.email = %q{brian@embellishedvisions.com}
14
- s.extra_rdoc_files = [
15
- "README.rdoc"
16
- ]
17
- s.files = [
18
- "MIT-LICENSE",
19
- "README.rdoc",
20
- "Rakefile",
21
- "VERSION",
22
- "init.rb",
23
- "lib/active_record/connection_adapters/seamless_database_pool_adapter.rb",
24
- "lib/seamless_database_pool.rb",
25
- "lib/seamless_database_pool/connect_timeout.rb",
26
- "lib/seamless_database_pool/connection_statistics.rb",
27
- "lib/seamless_database_pool/controller_filter.rb",
28
- "seamless_database_pool.gemspec",
29
- "spec/connection_statistics_spec.rb",
30
- "spec/filter_spec.rb",
31
- "spec/seamless_database_pool_adapter_spec.rb",
32
- "spec/seamless_database_pool_spec.rb",
33
- "spec/spec_helper.rb",
34
- "spec/test_models.rb"
35
- ]
36
- s.homepage = %q{http://github.com/bdurand/seamless_database_pool}
37
- s.rdoc_options = ["--charset=UTF-8"]
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.5}
40
- s.summary = %q{Add support for master/slave database clusters in ActiveRecord to improve performance.}
41
- s.test_files = [
42
- "spec/connection_statistics_spec.rb",
43
- "spec/filter_spec.rb",
44
- "spec/seamless_database_pool_adapter_spec.rb",
45
- "spec/seamless_database_pool_spec.rb",
46
- "spec/spec_helper.rb",
47
- "spec/test_models.rb"
48
- ]
49
-
50
- if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
- s.specification_version = 3
53
-
54
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<activerecord>, [">= 2.2.2"])
56
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
57
- s.add_development_dependency(%q<jeweler>, [">= 0"])
58
- else
59
- s.add_dependency(%q<activerecord>, [">= 2.2.2"])
60
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
62
- end
63
- else
64
- s.add_dependency(%q<activerecord>, [">= 2.2.2"])
65
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
- s.add_dependency(%q<jeweler>, [">= 0"])
67
- end
68
- end
69
-
data/spec/test_models.rb DELETED
@@ -1,35 +0,0 @@
1
- module SeamlessDatabasePool
2
- class Test < ActiveRecord::Base
3
- def self.create_tables
4
- db_dir = File.expand_path(File.join(__FILE__, '..', 'tmp'))
5
- Dir.mkdir(db_dir) unless File.exist?(db_dir)
6
- db = File.join(db_dir, 'test_SeamlessDatabasePool.sqlite3')
7
- establish_connection("adapter" => "sqlite3", "database" => db)
8
-
9
- connection.create_table(Thing.table_name) do |t|
10
- t.column :name, :string
11
- t.column :model_id, :integer
12
- end unless Thing.table_exists?
13
-
14
- connection.create_table(Model.table_name) do |t|
15
- t.column :name, :string
16
- end unless Model.table_exists?
17
- end
18
-
19
- def self.drop_tables
20
- db_dir = File.expand_path(File.join(__FILE__, '..', 'tmp'))
21
- db = File.join(db_dir, 'test_SeamlessDatabasePool.sqlite3')
22
- connection.disconnect!
23
- File.delete(db) if File.exist?(db)
24
- Dir.delete(db_dir) if File.exist?(db_dir) and Dir.entries(db_dir).reject{|f| f.match(/^\.+$/)}.empty?
25
- end
26
-
27
- class Thing < Test
28
- belongs_to :model, :class_name => "SeamlessDatabasePool::Test::Model"
29
- end
30
-
31
- class Model < Test
32
- has_many :things, :class_name => "SeamlessDatabasePool::Test::Thing"
33
- end
34
- end
35
- end