ebisu_connection 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +0 -3
- data/ebisu_connection.gemspec +6 -6
- data/gemfiles/rails3.gemfile +0 -1
- data/gemfiles/rails40.gemfile +0 -1
- data/gemfiles/rails41.gemfile +0 -1
- data/lib/ebisu_connection/conf_file.rb +5 -3
- data/lib/ebisu_connection/version.rb +1 -1
- data/spec/database.yml +10 -0
- data/spec/db_schema.sql +95 -0
- data/spec/prepare.rb +13 -0
- data/spec/slaves.yaml +7 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/ebisu_connection_spec.rb +15 -0
- metadata +42 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce03246ed6e2fdd861e08fda5c26ac5055dfd93
|
4
|
+
data.tar.gz: 39ef771e7f321a9d48067054ac454c049497af48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f97f3d8eff3282cdf4a200ba1da8d65a3d6c23b1bcd81dddcba2d1472ed6d9e03b83b19730556a8297871b58226e635b20898df0b38c4988808b951ca93f254
|
7
|
+
data.tar.gz: b239dfdb465fe2c4eee2ea400b9e732777600e7e9b56452cac780dea29198bfe9a3a83b0bb89beac53185520b90182ee317a35ed10803226c43969337cd53b78
|
data/Appraisals
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
appraise "rails3" do
|
2
2
|
gem "activerecord", "~> 3.2.0"
|
3
3
|
gem "activesupport", "~> 3.2.0"
|
4
|
-
gem "railties", "~> 3.2.0"
|
5
4
|
end
|
6
5
|
|
7
6
|
appraise "rails40" do
|
8
7
|
gem "activerecord", "~> 4.0.0"
|
9
8
|
gem "activesupport", "~> 4.0.0"
|
10
|
-
gem "railties", "~> 4.0.0"
|
11
9
|
end
|
12
10
|
|
13
11
|
appraise "rails41" do
|
14
12
|
gem "activerecord", "~> 4.1.0"
|
15
13
|
gem "activesupport", "~> 4.1.0"
|
16
|
-
gem "railties", "~> 4.1.0"
|
17
14
|
end
|
data/ebisu_connection.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'fresh_connection', '~> 0.2.0'
|
21
|
+
spec.add_dependency 'fresh_connection', '~> 0.2.0', '>= 0.2.2'
|
22
|
+
spec.add_dependency 'mysql2', '~> 0.3'
|
22
23
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
24
|
-
spec.add_development_dependency "rake", '
|
25
|
-
spec.add_development_dependency "rspec", '
|
26
|
-
spec.add_development_dependency '
|
27
|
-
spec.add_development_dependency 'appraisal', '>= 1.0.0'
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", '~> 10.0'
|
26
|
+
spec.add_development_dependency "rspec", '~> 2.14'
|
27
|
+
spec.add_development_dependency 'appraisal', '~> 1.0'
|
28
28
|
end
|
data/gemfiles/rails3.gemfile
CHANGED
data/gemfiles/rails40.gemfile
CHANGED
data/gemfiles/rails41.gemfile
CHANGED
@@ -29,7 +29,9 @@ module EbisuConnection
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def slaves_file
|
32
|
-
@slaves_file
|
32
|
+
return @slaves_file if @slaves_file
|
33
|
+
raise "nothing slaves_file. You have to set a file path using EbisuConnection.slaves_file= method" unless defined?(Rails)
|
34
|
+
File.join(Rails.root, "config/slave.yaml")
|
33
35
|
end
|
34
36
|
|
35
37
|
def check_interval
|
@@ -55,11 +57,11 @@ module EbisuConnection
|
|
55
57
|
def get_slaves_conf
|
56
58
|
@file_mtime = File.mtime(slaves_file)
|
57
59
|
conf = YAML.load_file(slaves_file)
|
58
|
-
conf[
|
60
|
+
conf[FreshConnection.env.to_s] || {}
|
59
61
|
end
|
60
62
|
|
61
63
|
def get_spec
|
62
|
-
ActiveRecord::Base.configurations[
|
64
|
+
ActiveRecord::Base.configurations[FreshConnection.env]
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
data/spec/database.yml
ADDED
data/spec/db_schema.sql
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
-- MySQL dump 10.13 Distrib 5.6.19, for osx10.9 (x86_64)
|
2
|
+
--
|
3
|
+
-- Host: localhost Database: ebisu_connection_test_master
|
4
|
+
-- ------------------------------------------------------
|
5
|
+
-- Server version 5.6.19
|
6
|
+
|
7
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
8
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
9
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
10
|
+
/*!40101 SET NAMES utf8 */;
|
11
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
12
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
13
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
14
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
15
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
16
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
17
|
+
|
18
|
+
--
|
19
|
+
-- Current Database: `ebisu_connection_test_master`
|
20
|
+
--
|
21
|
+
|
22
|
+
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ebisu_connection_test_master` /*!40100 DEFAULT CHARACTER SET utf8 */;
|
23
|
+
|
24
|
+
USE `ebisu_connection_test_master`;
|
25
|
+
|
26
|
+
--
|
27
|
+
-- Table structure for table `users`
|
28
|
+
--
|
29
|
+
|
30
|
+
DROP TABLE IF EXISTS `users`;
|
31
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
32
|
+
/*!40101 SET character_set_client = utf8 */;
|
33
|
+
CREATE TABLE `users` (
|
34
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
35
|
+
`name` varchar(255) NOT NULL DEFAULT '',
|
36
|
+
`created_at` datetime DEFAULT NULL,
|
37
|
+
`updated_at` datetime DEFAULT NULL,
|
38
|
+
PRIMARY KEY (`id`)
|
39
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
40
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
41
|
+
|
42
|
+
--
|
43
|
+
-- Dumping data for table `users`
|
44
|
+
--
|
45
|
+
|
46
|
+
LOCK TABLES `users` WRITE;
|
47
|
+
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
48
|
+
INSERT INTO `users` VALUES (1,'Tsukasa (master)','2014-04-10 07:24:16','2014-04-10 07:24:16');
|
49
|
+
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
50
|
+
UNLOCK TABLES;
|
51
|
+
|
52
|
+
--
|
53
|
+
-- Current Database: `ebisu_connection_test_slave`
|
54
|
+
--
|
55
|
+
|
56
|
+
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `ebisu_connection_test_slave` /*!40100 DEFAULT CHARACTER SET utf8 */;
|
57
|
+
|
58
|
+
USE `ebisu_connection_test_slave`;
|
59
|
+
|
60
|
+
--
|
61
|
+
-- Table structure for table `users`
|
62
|
+
--
|
63
|
+
|
64
|
+
DROP TABLE IF EXISTS `users`;
|
65
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
66
|
+
/*!40101 SET character_set_client = utf8 */;
|
67
|
+
CREATE TABLE `users` (
|
68
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
69
|
+
`name` varchar(255) NOT NULL DEFAULT '',
|
70
|
+
`created_at` datetime DEFAULT NULL,
|
71
|
+
`updated_at` datetime DEFAULT NULL,
|
72
|
+
PRIMARY KEY (`id`)
|
73
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
74
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
75
|
+
|
76
|
+
--
|
77
|
+
-- Dumping data for table `users`
|
78
|
+
--
|
79
|
+
|
80
|
+
LOCK TABLES `users` WRITE;
|
81
|
+
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
82
|
+
INSERT INTO `users` VALUES (1,'Tsukasa (slave)','2014-04-10 07:24:16','2014-04-10 07:24:16');
|
83
|
+
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
84
|
+
UNLOCK TABLES;
|
85
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
86
|
+
|
87
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
88
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
89
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
90
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
91
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
92
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
93
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
94
|
+
|
95
|
+
-- Dump completed on 2014-06-16 21:22:37
|
data/spec/prepare.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
system("mysql -uroot < spec/db_schema.sql")
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
class Base
|
7
|
+
self.configurations = YAML.load_file(File.join(File.dirname(__FILE__), "database.yml"))
|
8
|
+
establish_connection(configurations["test"])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class User < ActiveRecord::Base
|
13
|
+
end
|
data/spec/slaves.yaml
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -3,3 +3,6 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
require 'ebisu_connection'
|
4
4
|
|
5
5
|
FreshConnection::Initializer.extend_active_record
|
6
|
+
FreshConnection.env = "test"
|
7
|
+
EbisuConnection.slaves_file = File.join(File.dirname(__FILE__), "slaves.yaml")
|
8
|
+
require File.join(File.dirname(__FILE__), "prepare.rb")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EbisuConnection do
|
4
|
+
context "access to slave" do
|
5
|
+
it "select from User is to access to slave" do
|
6
|
+
expect(User.first.name).to be_include("slave")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
context "access to master" do
|
11
|
+
it "specify readonly(false)" do
|
12
|
+
expect(User.readonly(false).first.name).to be_include("master")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebisu_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tsukasaoishi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fresh_connection
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.2.0
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.2.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,76 +27,79 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.2.0
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.2.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
34
|
+
name: mysql2
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
39
|
+
version: '0.3'
|
40
|
+
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '0.3'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: '1.6'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: '1.6'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
67
|
+
version: '10.0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: '10.0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: rspec
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
81
|
+
version: '2.14'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- - "
|
86
|
+
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
88
|
+
version: '2.14'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: appraisal
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- - "
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0
|
95
|
+
version: '1.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- - "
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0
|
102
|
+
version: '1.0'
|
97
103
|
description: EbisuConnection supports to connect with Mysql slave servers. It doesn't
|
98
104
|
need Load Balancer.
|
99
105
|
email:
|
@@ -119,7 +125,12 @@ files:
|
|
119
125
|
- lib/ebisu_connection/slave.rb
|
120
126
|
- lib/ebisu_connection/slave_group.rb
|
121
127
|
- lib/ebisu_connection/version.rb
|
128
|
+
- spec/database.yml
|
129
|
+
- spec/db_schema.sql
|
130
|
+
- spec/prepare.rb
|
131
|
+
- spec/slaves.yaml
|
122
132
|
- spec/spec_helper.rb
|
133
|
+
- spec/unit/ebisu_connection_spec.rb
|
123
134
|
- spec/unit/greatest_common_divisor_spec.rb
|
124
135
|
- spec/unit/slave_group_spec.rb
|
125
136
|
- spec/unit/slave_spec.rb
|
@@ -143,12 +154,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
154
|
version: '0'
|
144
155
|
requirements: []
|
145
156
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.2.
|
157
|
+
rubygems_version: 2.2.2
|
147
158
|
signing_key:
|
148
159
|
specification_version: 4
|
149
160
|
summary: EbisuConnection supports to connect with Mysql slave servers.
|
150
161
|
test_files:
|
162
|
+
- spec/database.yml
|
163
|
+
- spec/db_schema.sql
|
164
|
+
- spec/prepare.rb
|
165
|
+
- spec/slaves.yaml
|
151
166
|
- spec/spec_helper.rb
|
167
|
+
- spec/unit/ebisu_connection_spec.rb
|
152
168
|
- spec/unit/greatest_common_divisor_spec.rb
|
153
169
|
- spec/unit/slave_group_spec.rb
|
154
170
|
- spec/unit/slave_spec.rb
|