advanced_connection 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +63 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +218 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +165 -0
- data/advanced_connection.gemspec +49 -0
- data/gemfiles/jruby/rails4_1.gemfile +7 -0
- data/gemfiles/jruby/rails4_2.gemfile +7 -0
- data/gemfiles/ruby/rails4_1.gemfile +7 -0
- data/gemfiles/ruby/rails4_2.gemfile +7 -0
- data/lib/advanced_connection/active_record_ext/abstract_adapter/statement_pooling.rb +121 -0
- data/lib/advanced_connection/active_record_ext/abstract_adapter.rb +48 -0
- data/lib/advanced_connection/active_record_ext/connection_pool/idle_manager.rb +271 -0
- data/lib/advanced_connection/active_record_ext/connection_pool/queues.rb +60 -0
- data/lib/advanced_connection/active_record_ext/connection_pool/statement_pooling.rb +42 -0
- data/lib/advanced_connection/active_record_ext/connection_pool/without_connection.rb +93 -0
- data/lib/advanced_connection/active_record_ext/connection_pool.rb +38 -0
- data/lib/advanced_connection/active_record_ext/without_connection.rb +30 -0
- data/lib/advanced_connection/active_record_ext.rb +59 -0
- data/lib/advanced_connection/config.rb +247 -0
- data/lib/advanced_connection/error.rb +27 -0
- data/lib/advanced_connection/railtie.rb +40 -0
- data/lib/advanced_connection/version.rb +29 -0
- data/lib/advanced_connection.rb +65 -0
- data/lib/generators/advanced_connection/install/USAGE +5 -0
- data/lib/generators/advanced_connection/install/install_generator.rb +30 -0
- data/lib/generators/advanced_connection/install/templates/advanced_connection.rb +142 -0
- data/lib/tasks/advanced_connection_tasks.rake +25 -0
- data/spec/config/database.yml +18 -0
- data/spec/config/database.yml.erb +54 -0
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/book.rb +2 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +17 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +48 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/advanced_connection.rb +142 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20160222045238_create_books.rb +10 -0
- data/spec/dummy/db/schema.rb +23 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/test.log +327 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/test/fixtures/books.yml +9 -0
- data/spec/dummy/test/models/book_test.rb +7 -0
- data/spec/idle_manager_spec.rb +16 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/db_config.rb +61 -0
- metadata +399 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 62f7a17e7ed43268b606a797d1caf063a7315655
|
4
|
+
data.tar.gz: e27f2b539440c06bb584c391823cffa513f07cb9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42ed8c6c57cc86e27c18536b1b122c635599be016d0ec01252f652b1f42a47b571d3612bc695923b95e7e269bff88f3bc074f00ecfa93cf3d17571b1e1584e1d
|
7
|
+
data.tar.gz: 7d54804ab6b0cd5c56c684d071608209f5a5cdc959ac121e8088b9eb0b145a4cbec7bbf7c02e4710ba48caf9eff5578bead5528d3982f2f8869ddc16b7d483c4
|
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
7
|
+
- 2.3.0
|
8
|
+
- ruby-head
|
9
|
+
- jruby-1.7
|
10
|
+
- jruby-9.0.5.0
|
11
|
+
- jruby-head
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/ruby/rails4_1.gemfile
|
15
|
+
- gemfiles/ruby/rails4_2.gemfile
|
16
|
+
- gemfiles/jruby/rails4_1.gemfile
|
17
|
+
- gemfiles/jruby/rails4_2.gemfile
|
18
|
+
before_script:
|
19
|
+
- bundle exec rake advanced_connection:db:reset
|
20
|
+
script: bundle exec rake spec
|
21
|
+
matrix:
|
22
|
+
exclude:
|
23
|
+
- rvm: 1.9.3
|
24
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
25
|
+
- rvm: 1.9.3
|
26
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
27
|
+
- rvm: 2.0.0
|
28
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
29
|
+
- rvm: 2.0.0
|
30
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
31
|
+
- rvm: 2.1
|
32
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
33
|
+
- rvm: 2.1
|
34
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
35
|
+
- rvm: 2.2
|
36
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
37
|
+
- rvm: 2.2
|
38
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
39
|
+
- rvm: 2.3
|
40
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
41
|
+
- rvm: 2.3
|
42
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
43
|
+
- rvm: ruby-head
|
44
|
+
gemfile: gemfiles/jruby/rails4_1.gemfile
|
45
|
+
- rvm: ruby-head
|
46
|
+
gemfile: gemfiles/jruby/rails4_2.gemfile
|
47
|
+
- rvm: jruby-1.7
|
48
|
+
gemfile: gemfiles/ruby/rails4_1.gemfile
|
49
|
+
- rvm: jruby-1.7
|
50
|
+
gemfile: gemfiles/ruby/rails4_2.gemfile
|
51
|
+
- rvm: jruby-9.0.5.0
|
52
|
+
gemfile: gemfiles/ruby/rails4_1.gemfile
|
53
|
+
- rvm: jruby-9.0.5.0
|
54
|
+
gemfile: gemfiles/ruby/rails4_2.gemfile
|
55
|
+
- rvm: jruby-head
|
56
|
+
gemfile: gemfiles/ruby/rails4_1.gemfile
|
57
|
+
- rvm: jruby-head
|
58
|
+
gemfile: gemfiles/ruby/rails4_2.gemfile
|
59
|
+
allow_failures:
|
60
|
+
- rvm: ruby-head
|
61
|
+
- rvm: jruby-head
|
62
|
+
sudo: false
|
63
|
+
cache: bundler
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
advanced_connection (0.5.1)
|
5
|
+
activerecord (>= 4.1.0, < 5.0)
|
6
|
+
activesupport (>= 4.1.0, < 5.0)
|
7
|
+
rails (>= 4.1.0, < 5.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (4.2.6)
|
13
|
+
actionpack (= 4.2.6)
|
14
|
+
actionview (= 4.2.6)
|
15
|
+
activejob (= 4.2.6)
|
16
|
+
mail (~> 2.5, >= 2.5.4)
|
17
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
18
|
+
actionpack (4.2.6)
|
19
|
+
actionview (= 4.2.6)
|
20
|
+
activesupport (= 4.2.6)
|
21
|
+
rack (~> 1.6)
|
22
|
+
rack-test (~> 0.6.2)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
25
|
+
actionview (4.2.6)
|
26
|
+
activesupport (= 4.2.6)
|
27
|
+
builder (~> 3.1)
|
28
|
+
erubis (~> 2.7.0)
|
29
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
+
activejob (4.2.6)
|
32
|
+
activesupport (= 4.2.6)
|
33
|
+
globalid (>= 0.3.0)
|
34
|
+
activemodel (4.2.6)
|
35
|
+
activesupport (= 4.2.6)
|
36
|
+
builder (~> 3.1)
|
37
|
+
activerecord (4.2.6)
|
38
|
+
activemodel (= 4.2.6)
|
39
|
+
activesupport (= 4.2.6)
|
40
|
+
arel (~> 6.0)
|
41
|
+
activesupport (4.2.6)
|
42
|
+
i18n (~> 0.7)
|
43
|
+
json (~> 1.7, >= 1.7.7)
|
44
|
+
minitest (~> 5.1)
|
45
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
46
|
+
tzinfo (~> 1.1)
|
47
|
+
arel (6.0.3)
|
48
|
+
builder (3.2.2)
|
49
|
+
charlock_holmes (0.7.3)
|
50
|
+
coderay (1.1.1)
|
51
|
+
concurrent-ruby (1.0.1)
|
52
|
+
concurrent-ruby (1.0.1-java)
|
53
|
+
copyright-header (1.0.15)
|
54
|
+
github-linguist (~> 2.6)
|
55
|
+
coveralls (0.8.13)
|
56
|
+
json (~> 1.8)
|
57
|
+
simplecov (~> 0.11.0)
|
58
|
+
term-ansicolor (~> 1.3)
|
59
|
+
thor (~> 0.19.1)
|
60
|
+
tins (~> 1.6.0)
|
61
|
+
diff-lcs (1.2.5)
|
62
|
+
docile (1.1.5)
|
63
|
+
erubis (2.7.0)
|
64
|
+
escape_utils (1.0.1)
|
65
|
+
ffi (1.9.10)
|
66
|
+
ffi (1.9.10-java)
|
67
|
+
formatador (0.2.5)
|
68
|
+
github-linguist (2.12.0)
|
69
|
+
charlock_holmes (~> 0.7.3)
|
70
|
+
escape_utils (~> 1.0.1)
|
71
|
+
mime-types (~> 1.19)
|
72
|
+
pygments.rb (~> 0.6.0)
|
73
|
+
globalid (0.3.6)
|
74
|
+
activesupport (>= 4.1.0)
|
75
|
+
guard (2.13.0)
|
76
|
+
formatador (>= 0.2.4)
|
77
|
+
listen (>= 2.7, <= 4.0)
|
78
|
+
lumberjack (~> 1.0)
|
79
|
+
nenv (~> 0.1)
|
80
|
+
notiffany (~> 0.0)
|
81
|
+
pry (>= 0.9.12)
|
82
|
+
shellany (~> 0.0)
|
83
|
+
thor (>= 0.18.1)
|
84
|
+
guard-compat (1.2.1)
|
85
|
+
guard-rspec (4.6.4)
|
86
|
+
guard (~> 2.1)
|
87
|
+
guard-compat (~> 1.1)
|
88
|
+
rspec (>= 2.99.0, < 4.0)
|
89
|
+
i18n (0.7.0)
|
90
|
+
json (1.8.3)
|
91
|
+
json (1.8.3-java)
|
92
|
+
listen (3.0.6)
|
93
|
+
rb-fsevent (>= 0.9.3)
|
94
|
+
rb-inotify (>= 0.9.7)
|
95
|
+
loofah (2.0.3)
|
96
|
+
nokogiri (>= 1.5.9)
|
97
|
+
lumberjack (1.0.10)
|
98
|
+
mail (2.6.4)
|
99
|
+
mime-types (>= 1.16, < 4)
|
100
|
+
method_source (0.8.2)
|
101
|
+
mime-types (1.25.1)
|
102
|
+
mini_portile2 (2.0.0)
|
103
|
+
minitest (5.8.4)
|
104
|
+
nenv (0.3.0)
|
105
|
+
nokogiri (1.6.7.2)
|
106
|
+
mini_portile2 (~> 2.0.0.rc2)
|
107
|
+
nokogiri (1.6.7.2-java)
|
108
|
+
notiffany (0.0.8)
|
109
|
+
nenv (~> 0.1)
|
110
|
+
shellany (~> 0.0)
|
111
|
+
pg (0.18.4)
|
112
|
+
posix-spawn (0.3.11)
|
113
|
+
pry (0.10.3)
|
114
|
+
coderay (~> 1.1.0)
|
115
|
+
method_source (~> 0.8.1)
|
116
|
+
slop (~> 3.4)
|
117
|
+
pry (0.10.3-java)
|
118
|
+
coderay (~> 1.1.0)
|
119
|
+
method_source (~> 0.8.1)
|
120
|
+
slop (~> 3.4)
|
121
|
+
spoon (~> 0.0)
|
122
|
+
pry-nav (0.2.4)
|
123
|
+
pry (>= 0.9.10, < 0.11.0)
|
124
|
+
pygments.rb (0.6.3)
|
125
|
+
posix-spawn (~> 0.3.6)
|
126
|
+
yajl-ruby (~> 1.2.0)
|
127
|
+
rack (1.6.4)
|
128
|
+
rack-test (0.6.3)
|
129
|
+
rack (>= 1.0)
|
130
|
+
rails (4.2.6)
|
131
|
+
actionmailer (= 4.2.6)
|
132
|
+
actionpack (= 4.2.6)
|
133
|
+
actionview (= 4.2.6)
|
134
|
+
activejob (= 4.2.6)
|
135
|
+
activemodel (= 4.2.6)
|
136
|
+
activerecord (= 4.2.6)
|
137
|
+
activesupport (= 4.2.6)
|
138
|
+
bundler (>= 1.3.0, < 2.0)
|
139
|
+
railties (= 4.2.6)
|
140
|
+
sprockets-rails
|
141
|
+
rails-deprecated_sanitizer (1.0.3)
|
142
|
+
activesupport (>= 4.2.0.alpha)
|
143
|
+
rails-dom-testing (1.0.7)
|
144
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
145
|
+
nokogiri (~> 1.6.0)
|
146
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
147
|
+
rails-html-sanitizer (1.0.3)
|
148
|
+
loofah (~> 2.0)
|
149
|
+
railties (4.2.6)
|
150
|
+
actionpack (= 4.2.6)
|
151
|
+
activesupport (= 4.2.6)
|
152
|
+
rake (>= 0.8.7)
|
153
|
+
thor (>= 0.18.1, < 2.0)
|
154
|
+
rake (10.5.0)
|
155
|
+
rb-fsevent (0.9.7)
|
156
|
+
rb-inotify (0.9.7)
|
157
|
+
ffi (>= 0.5.0)
|
158
|
+
rspec (3.4.0)
|
159
|
+
rspec-core (~> 3.4.0)
|
160
|
+
rspec-expectations (~> 3.4.0)
|
161
|
+
rspec-mocks (~> 3.4.0)
|
162
|
+
rspec-collection_matchers (1.1.2)
|
163
|
+
rspec-expectations (>= 2.99.0.beta1)
|
164
|
+
rspec-core (3.4.4)
|
165
|
+
rspec-support (~> 3.4.0)
|
166
|
+
rspec-expectations (3.4.0)
|
167
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
168
|
+
rspec-support (~> 3.4.0)
|
169
|
+
rspec-its (1.2.0)
|
170
|
+
rspec-core (>= 3.0.0)
|
171
|
+
rspec-expectations (>= 3.0.0)
|
172
|
+
rspec-mocks (3.4.1)
|
173
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
174
|
+
rspec-support (~> 3.4.0)
|
175
|
+
rspec-support (3.4.1)
|
176
|
+
shellany (0.0.1)
|
177
|
+
simplecov (0.11.2)
|
178
|
+
docile (~> 1.1.0)
|
179
|
+
json (~> 1.8)
|
180
|
+
simplecov-html (~> 0.10.0)
|
181
|
+
simplecov-html (0.10.0)
|
182
|
+
slop (3.6.0)
|
183
|
+
spoon (0.0.4)
|
184
|
+
ffi
|
185
|
+
sprockets (3.5.2)
|
186
|
+
concurrent-ruby (~> 1.0)
|
187
|
+
rack (> 1, < 3)
|
188
|
+
sprockets-rails (3.0.4)
|
189
|
+
actionpack (>= 4.0)
|
190
|
+
activesupport (>= 4.0)
|
191
|
+
sprockets (>= 3.0.0)
|
192
|
+
term-ansicolor (1.3.2)
|
193
|
+
tins (~> 1.0)
|
194
|
+
thor (0.19.1)
|
195
|
+
thread_safe (0.3.5)
|
196
|
+
thread_safe (0.3.5-java)
|
197
|
+
tins (1.6.0)
|
198
|
+
tzinfo (1.2.2)
|
199
|
+
thread_safe (~> 0.1)
|
200
|
+
yajl-ruby (1.2.1)
|
201
|
+
|
202
|
+
PLATFORMS
|
203
|
+
java
|
204
|
+
ruby
|
205
|
+
|
206
|
+
DEPENDENCIES
|
207
|
+
advanced_connection!
|
208
|
+
copyright-header (= 1.0.15)
|
209
|
+
coveralls (~> 0.8)
|
210
|
+
guard-rspec (~> 4.6)
|
211
|
+
pg (~> 0.18)
|
212
|
+
pry (~> 0.10)
|
213
|
+
pry-nav (~> 0.2)
|
214
|
+
rack (~> 1.6)
|
215
|
+
rake (~> 10.5)
|
216
|
+
rspec (~> 3.4)
|
217
|
+
rspec-collection_matchers (~> 1.1)
|
218
|
+
rspec-its (~> 1.2)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 Finalsite, LLC
|
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/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
Bundler.setup(:default, :development, :tests)
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
require "rspec"
|
11
|
+
require "rspec/core/rake_task"
|
12
|
+
require 'rdoc/task'
|
13
|
+
require 'rake/testtask'
|
14
|
+
|
15
|
+
RSpec::Core::RakeTask.new(:spec => %w{ db:copy_credentials db:test:prepare }) do |spec|
|
16
|
+
spec.pattern = "spec/**/*_spec.rb"
|
17
|
+
# spec.rspec_opts = '--order rand:16996'
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :spec do
|
21
|
+
[:tasks, :unit, :adapters, :integration].each do |type|
|
22
|
+
RSpec::Core::RakeTask.new(type => :spec) do |spec|
|
23
|
+
spec.pattern = "spec/#{type}/**/*_spec.rb"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
task :console do
|
29
|
+
require 'pry-nav'
|
30
|
+
require 'advanced_connection'
|
31
|
+
ARGV.clear
|
32
|
+
Pry.start
|
33
|
+
end
|
34
|
+
|
35
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
36
|
+
rdoc.rdoc_dir = 'rdoc'
|
37
|
+
rdoc.title = 'AdvancedConnection'
|
38
|
+
rdoc.options << '--line-numbers'
|
39
|
+
rdoc.rdoc_files.include('README.rdoc')
|
40
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
Rake::TestTask.new(:test) do |t|
|
45
|
+
t.libs << 'lib'
|
46
|
+
t.libs << 'test'
|
47
|
+
t.pattern = 'test/**/*_test.rb'
|
48
|
+
t.verbose = false
|
49
|
+
end
|
50
|
+
|
51
|
+
task default: :spec
|
52
|
+
|
53
|
+
def config
|
54
|
+
@config ||= begin
|
55
|
+
require Pathname.new(__FILE__).dirname.join('spec', 'support', 'db_config')
|
56
|
+
AdvancedConnection::Test::DbConfig.instance
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def pg_config
|
61
|
+
config.postgresql_config
|
62
|
+
end
|
63
|
+
|
64
|
+
def my_config
|
65
|
+
config.mysql_config
|
66
|
+
end
|
67
|
+
|
68
|
+
namespace :db do
|
69
|
+
namespace :test do
|
70
|
+
task :prepare => %w{postgres:drop_db postgres:build_db mysql:drop_db mysql:build_db}
|
71
|
+
end
|
72
|
+
|
73
|
+
config.each do |dbtype, data|
|
74
|
+
namespace(dbtype == 'postgresql' ? 'postgres' : dbtype) do
|
75
|
+
desc "copy over db config files for #{dbtype} if they don't already exist"
|
76
|
+
task :copy_credentials do
|
77
|
+
require 'fileutils'
|
78
|
+
base_db_file = 'spec/config/database.yml'
|
79
|
+
rails_db_file = 'spec/dummy/config/database.yml'
|
80
|
+
|
81
|
+
FileUtils.copy(base_db_file + '.erb', base_db_file, :verbose => true) unless File.exists?(base_db_file)
|
82
|
+
|
83
|
+
data = %w[ development test ].each_with_object({}) { |env, memo|
|
84
|
+
memo[env] = config.public_send("#{dbtype}_config")
|
85
|
+
}
|
86
|
+
$stdout.puts "generating #{rails_db_file}"
|
87
|
+
IO.write(rails_db_file, data.to_yaml)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace :copyright do
|
94
|
+
namespace :headers do
|
95
|
+
desc 'add copyright headers'
|
96
|
+
task :add do
|
97
|
+
require 'copyright_header'
|
98
|
+
|
99
|
+
args = {
|
100
|
+
license: 'MIT',
|
101
|
+
copyright_software: 'Advanced Connection',
|
102
|
+
copyright_software_description: "A Rails plugin providing an Idle Database Connection Manager",
|
103
|
+
copyright_holders: ['Finalsite, LLC', 'Carl P. Corliss <carl.corliss@finalsite.com>'],
|
104
|
+
copyright_years: ['2016'],
|
105
|
+
add_path: 'lib',
|
106
|
+
output_dir: '.'
|
107
|
+
}
|
108
|
+
|
109
|
+
command_line = CopyrightHeader::CommandLine.new( args )
|
110
|
+
command_line.execute
|
111
|
+
end
|
112
|
+
|
113
|
+
desc 'remove copyright headers'
|
114
|
+
task :remove do
|
115
|
+
require 'copyright_header'
|
116
|
+
|
117
|
+
args = {
|
118
|
+
license: 'MIT',
|
119
|
+
copyright_software: 'Advanced Connection',
|
120
|
+
copyright_software_description: "A Rails plugin providing an Idle Database Connection Manager",
|
121
|
+
copyright_holders: ['Finalsite, LLC', 'Carl P. Corliss <carl.corliss@finalsite.com>'],
|
122
|
+
copyright_years: ['2016'],
|
123
|
+
remove_path: 'lib',
|
124
|
+
output_dir: '.'
|
125
|
+
}
|
126
|
+
|
127
|
+
command_line = CopyrightHeader::CommandLine.new( args )
|
128
|
+
command_line.execute
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
namespace :postgres do
|
134
|
+
require 'active_record'
|
135
|
+
|
136
|
+
desc 'Build the PostgreSQL test databases'
|
137
|
+
task :build_db do
|
138
|
+
%x{ createdb -E UTF8 #{pg_config['database']} -U#{pg_config['username']} } rescue "test db already exists"
|
139
|
+
ActiveRecord::Base.establish_connection pg_config
|
140
|
+
ActiveRecord::Migrator.migrate('spec/dummy/db/migrate')
|
141
|
+
end
|
142
|
+
|
143
|
+
desc "drop the PostgreSQL test database"
|
144
|
+
task :drop_db do
|
145
|
+
puts "dropping database #{pg_config['database']}"
|
146
|
+
%x{ dropdb #{pg_config['database']} -U#{pg_config['username']} }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
namespace :mysql do
|
151
|
+
require 'active_record'
|
152
|
+
|
153
|
+
desc 'Build the MySQL test databases'
|
154
|
+
task :build_db do
|
155
|
+
%x{ mysqladmin -u #{my_config['username']} --password=#{my_config['password']} create #{my_config['database']} } rescue "test db already exists"
|
156
|
+
ActiveRecord::Base.establish_connection my_config
|
157
|
+
ActiveRecord::Migrator.migrate('spec/dummy/db/migrate')
|
158
|
+
end
|
159
|
+
|
160
|
+
desc "drop the MySQL test database"
|
161
|
+
task :drop_db do
|
162
|
+
puts "dropping database #{my_config['database']}"
|
163
|
+
%x{ mysqladmin -u #{my_config['username']} --password=#{my_config['password']} drop #{my_config['database']} --force}
|
164
|
+
end
|
165
|
+
end
|