arproxy 0.2.3 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 823f964e61df08cc0217fd98aecab298e6708c1f
4
- data.tar.gz: c631d9478d47b428ee1430b8a7067ed7f0d55879
2
+ SHA256:
3
+ metadata.gz: 97417dad77bf18a6a058b5a7bf30cfd2118e70a2db8da4eb9574f5d6694b1119
4
+ data.tar.gz: 76361afc976b7fd086c702fb7dd0629b3d0ad85776667b1438d323db64173139
5
5
  SHA512:
6
- metadata.gz: 47e8a38ecc8632ef00fc5051a41a03eb5f6e2176dca681cdb9f7dbca42d5669c3a3fd18a9fbd2a3f655b62e1c516140d7d17db21d12c4f94b89a9841c60ef060
7
- data.tar.gz: 660612a5652d660c2d0ca64b6ef4578375b73ba4f29781de3e8862cc0eb35fa677b0febe4c19caeb29144f2f05e7ae0df85115f918bb68f141a8f033326e82ea
6
+ metadata.gz: 0515356f2ddafdb1f77bbb6dfb49769fbc4d08d1381bf2657f32210d3dd9841f3e29d5ca157f6e24e23392d219f0123dc703c0e1c34e083ee06ed58d3f09ec32
7
+ data.tar.gz: 95ce473dc91f7d5a38009eb105b35b3f8760f31f8fbb85b9fe45c66151864c98120585f6476363dc395f3a1d66a3d3433e4d2355c420b36dff4e392464c9c51d
data/lib/arproxy/base.rb CHANGED
@@ -2,8 +2,8 @@ module Arproxy
2
2
  class Base
3
3
  attr_accessor :proxy_chain, :next_proxy
4
4
 
5
- def execute(sql, name=nil)
6
- next_proxy.execute sql, name
5
+ def execute(sql, name=nil, **kwargs)
6
+ next_proxy.execute sql, name, **kwargs
7
7
  end
8
8
  end
9
9
  end
@@ -4,8 +4,8 @@ module Arproxy
4
4
  self.proxy_chain = proxy_chain
5
5
  end
6
6
 
7
- def execute(sql, name=nil)
8
- self.proxy_chain.connection.execute_without_arproxy sql, name
7
+ def execute(sql, name=nil, **kwargs)
8
+ self.proxy_chain.connection.execute_without_arproxy sql, name, **kwargs
9
9
  end
10
10
  end
11
11
  end
@@ -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
@@ -24,7 +27,6 @@ module Arproxy
24
27
  raise Arproxy::Error, "config.adapter must be set" unless @adapter
25
28
  case @adapter
26
29
  when String, Symbol
27
- camelized_adapter_name = @adapter.to_s.split("_").map(&:capitalize).join
28
30
  eval "::ActiveRecord::ConnectionAdapters::#{camelized_adapter_name}Adapter"
29
31
  when Class
30
32
  @adapter
@@ -32,5 +34,22 @@ module Arproxy
32
34
  raise Arproxy::Error, "unexpected config.adapter: #{@adapter}"
33
35
  end
34
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
+ when 'Postgresql'
49
+ 'PostgreSQL'
50
+ else
51
+ adapter_name
52
+ end
53
+ end
35
54
  end
36
55
  end
@@ -29,9 +29,9 @@ module Arproxy
29
29
 
30
30
  def enable!
31
31
  @config.adapter_class.class_eval do
32
- def execute_with_arproxy(sql, name=nil)
32
+ def execute_with_arproxy(sql, name=nil, **kwargs)
33
33
  ::Arproxy.proxy_chain.connection = self
34
- ::Arproxy.proxy_chain.head.execute sql, name
34
+ ::Arproxy.proxy_chain.head.execute sql, name, **kwargs
35
35
  end
36
36
  alias_method :execute_without_arproxy, :execute
37
37
  alias_method :execute, :execute_with_arproxy
@@ -1,3 +1,3 @@
1
1
  module Arproxy
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.9'
3
3
  end
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
 
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.3
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Issei Naruta
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-06 00:00:00.000000000 Z
11
+ date: 2022-03-18 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: '1.11'
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: '1.11'
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: '10.0'
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: '10.0'
54
+ version: 12.3.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ homepage: https://github.com/cookpad/arproxy
98
98
  licenses:
99
99
  - MIT
100
100
  metadata: {}
101
- post_install_message:
101
+ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
@@ -113,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.5.1
118
- signing_key:
116
+ rubygems_version: 3.2.22
117
+ signing_key:
119
118
  specification_version: 4
120
119
  summary: Proxy between ActiveRecord and DB adapter
121
120
  test_files: []