arproxy 0.2.2 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/arproxy.rb +1 -4
- data/lib/arproxy/config.rb +21 -1
- data/lib/arproxy/version.rb +1 -1
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 60641c3f1965a76a0c1db42a2421c452a1bb24e86b7294d1ebf97f8121e90e1b
|
4
|
+
data.tar.gz: 2db239c2a83a87b7a6c82f6ca393627b8321ef046c1c812a73345d010de979cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a14ee492493067731519de3aa0afa254382e0f2dac5b2a270463b79e58bcc9111638d8f0610e60b153caaa54113f3b4ed1c11e7c79fa122d800c441ef43e97e
|
7
|
+
data.tar.gz: 5ff692aacaa53010fbe17ac1f9f435c2ec9bec275554438b48de1c4feba41e9b4c70f7be857512757d648c3c93a2f4ef1d9875c887cde375398585a59b10a254
|
data/lib/arproxy.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "logger"
|
2
|
-
require "active_record"
|
3
2
|
require "arproxy/base"
|
4
3
|
require "arproxy/config"
|
5
4
|
require "arproxy/proxy_chain"
|
@@ -7,6 +6,7 @@ require "arproxy/error"
|
|
7
6
|
require "arproxy/plugin"
|
8
7
|
|
9
8
|
module Arproxy
|
9
|
+
@config = @enabled = nil
|
10
10
|
|
11
11
|
module_function
|
12
12
|
def clear_configuration
|
@@ -28,9 +28,6 @@ module Arproxy
|
|
28
28
|
raise Arproxy::Error, "Arproxy should be configured"
|
29
29
|
end
|
30
30
|
|
31
|
-
# for lazy loading
|
32
|
-
::ActiveRecord::Base
|
33
|
-
|
34
31
|
@proxy_chain = ProxyChain.new @config
|
35
32
|
@proxy_chain.enable!
|
36
33
|
|
data/lib/arproxy/config.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "active_record/base"
|
3
|
+
|
1
4
|
module Arproxy
|
2
5
|
class Config
|
3
6
|
attr_accessor :adapter, :logger
|
@@ -5,6 +8,9 @@ module Arproxy
|
|
5
8
|
|
6
9
|
def initialize
|
7
10
|
@proxies = []
|
11
|
+
if defined?(Rails)
|
12
|
+
@adapter = Rails.application.config_for(:database)["adapter"]
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
def use(proxy_class, *options)
|
@@ -21,7 +27,6 @@ module Arproxy
|
|
21
27
|
raise Arproxy::Error, "config.adapter must be set" unless @adapter
|
22
28
|
case @adapter
|
23
29
|
when String, Symbol
|
24
|
-
camelized_adapter_name = @adapter.to_s.split("_").map(&:capitalize).join
|
25
30
|
eval "::ActiveRecord::ConnectionAdapters::#{camelized_adapter_name}Adapter"
|
26
31
|
when Class
|
27
32
|
@adapter
|
@@ -29,5 +34,20 @@ module Arproxy
|
|
29
34
|
raise Arproxy::Error, "unexpected config.adapter: #{@adapter}"
|
30
35
|
end
|
31
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def camelized_adapter_name
|
41
|
+
adapter_name = @adapter.to_s.split("_").map(&:capitalize).join
|
42
|
+
|
43
|
+
case adapter_name
|
44
|
+
when 'Sqlite3'
|
45
|
+
'SQLite3'
|
46
|
+
when 'Sqlserver'
|
47
|
+
'SQLServer'
|
48
|
+
else
|
49
|
+
adapter_name
|
50
|
+
end
|
51
|
+
end
|
32
52
|
end
|
33
53
|
end
|
data/lib/arproxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arproxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Issei Naruta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 2.5.1
|
116
|
+
rubygems_version: 3.0.3
|
118
117
|
signing_key:
|
119
118
|
specification_version: 4
|
120
119
|
summary: Proxy between ActiveRecord and DB adapter
|