cant_wait 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +65 -0
  5. data/Rakefile +18 -0
  6. data/cant_wait.gemspec +49 -0
  7. data/lib/cant_wait/cant_wait_railtie.rb +20 -0
  8. data/lib/cant_wait/version.rb +3 -0
  9. data/lib/cant_wait.rb +6 -0
  10. data/tasks/debugging.rake +108 -0
  11. data/tasks/publishing.rake +37 -0
  12. data/tasks/testing.rake +134 -0
  13. data/test/README.md +100 -0
  14. data/test/cant_wait_test.rb +127 -0
  15. data/test/database.yml +6 -0
  16. data/test/test_apps/Test_3_0_20/.gitignore +4 -0
  17. data/test/test_apps/Test_3_0_20/Gemfile +52 -0
  18. data/test/test_apps/Test_3_0_20/README +256 -0
  19. data/test/test_apps/Test_3_0_20/Rakefile +7 -0
  20. data/test/test_apps/Test_3_0_20/app/controllers/application_controller.rb +3 -0
  21. data/test/test_apps/Test_3_0_20/app/helpers/application_helper.rb +2 -0
  22. data/test/test_apps/Test_3_0_20/app/views/layouts/application.html.erb +14 -0
  23. data/test/test_apps/Test_3_0_20/config/application.rb +42 -0
  24. data/test/test_apps/Test_3_0_20/config/boot.rb +6 -0
  25. data/test/test_apps/Test_3_0_20/config/database.yml +6 -0
  26. data/test/test_apps/Test_3_0_20/config/environment.rb +5 -0
  27. data/test/test_apps/Test_3_0_20/config/environments/development.rb +26 -0
  28. data/test/test_apps/Test_3_0_20/config/environments/production.rb +49 -0
  29. data/test/test_apps/Test_3_0_20/config/environments/test.rb +35 -0
  30. data/test/test_apps/Test_3_0_20/config/initializers/backtrace_silencers.rb +7 -0
  31. data/test/test_apps/Test_3_0_20/config/initializers/inflections.rb +10 -0
  32. data/test/test_apps/Test_3_0_20/config/initializers/mime_types.rb +5 -0
  33. data/test/test_apps/Test_3_0_20/config/initializers/secret_token.rb +7 -0
  34. data/test/test_apps/Test_3_0_20/config/initializers/session_store.rb +8 -0
  35. data/test/test_apps/Test_3_0_20/config/locales/en.yml +5 -0
  36. data/test/test_apps/Test_3_0_20/config/routes.rb +58 -0
  37. data/test/test_apps/Test_3_0_20/config.ru +4 -0
  38. data/test/test_apps/Test_3_0_20/db/seeds.rb +7 -0
  39. data/test/test_apps/Test_3_0_20/lib/tasks/.gitkeep +0 -0
  40. data/test/test_apps/Test_3_0_20/public/404.html +26 -0
  41. data/test/test_apps/Test_3_0_20/public/422.html +26 -0
  42. data/test/test_apps/Test_3_0_20/public/500.html +26 -0
  43. data/test/test_apps/Test_3_0_20/public/favicon.ico +0 -0
  44. data/test/test_apps/Test_3_0_20/public/images/rails.png +0 -0
  45. data/test/test_apps/Test_3_0_20/public/index.html +239 -0
  46. data/test/test_apps/Test_3_0_20/public/javascripts/application.js +2 -0
  47. data/test/test_apps/Test_3_0_20/public/javascripts/controls.js +965 -0
  48. data/test/test_apps/Test_3_0_20/public/javascripts/dragdrop.js +974 -0
  49. data/test/test_apps/Test_3_0_20/public/javascripts/effects.js +1123 -0
  50. data/test/test_apps/Test_3_0_20/public/javascripts/prototype.js +6001 -0
  51. data/test/test_apps/Test_3_0_20/public/javascripts/rails.js +202 -0
  52. data/test/test_apps/Test_3_0_20/public/robots.txt +5 -0
  53. data/test/test_apps/Test_3_0_20/public/stylesheets/.gitkeep +0 -0
  54. data/test/test_apps/Test_3_0_20/script/rails +6 -0
  55. data/test/test_apps/Test_3_0_20/test/performance/browsing_test.rb +9 -0
  56. data/test/test_apps/Test_3_0_20/test/test_helper.rb +13 -0
  57. data/test/test_apps/Test_3_0_20/vendor/plugins/.gitkeep +0 -0
  58. data/test/test_apps/Test_3_0_3/.gitignore +4 -0
  59. data/test/test_apps/Test_3_0_3/Gemfile +52 -0
  60. data/test/test_apps/Test_3_0_3/README +256 -0
  61. data/test/test_apps/Test_3_0_3/Rakefile +7 -0
  62. data/test/test_apps/Test_3_0_3/app/controllers/application_controller.rb +3 -0
  63. data/test/test_apps/Test_3_0_3/app/helpers/application_helper.rb +2 -0
  64. data/test/test_apps/Test_3_0_3/app/views/layouts/application.html.erb +14 -0
  65. data/test/test_apps/Test_3_0_3/config/application.rb +42 -0
  66. data/test/test_apps/Test_3_0_3/config/boot.rb +13 -0
  67. data/test/test_apps/Test_3_0_3/config/database.yml +6 -0
  68. data/test/test_apps/Test_3_0_3/config/environment.rb +5 -0
  69. data/test/test_apps/Test_3_0_3/config/environments/development.rb +26 -0
  70. data/test/test_apps/Test_3_0_3/config/environments/production.rb +49 -0
  71. data/test/test_apps/Test_3_0_3/config/environments/test.rb +35 -0
  72. data/test/test_apps/Test_3_0_3/config/initializers/backtrace_silencers.rb +7 -0
  73. data/test/test_apps/Test_3_0_3/config/initializers/inflections.rb +10 -0
  74. data/test/test_apps/Test_3_0_3/config/initializers/mime_types.rb +5 -0
  75. data/test/test_apps/Test_3_0_3/config/initializers/secret_token.rb +7 -0
  76. data/test/test_apps/Test_3_0_3/config/initializers/session_store.rb +8 -0
  77. data/test/test_apps/Test_3_0_3/config/locales/en.yml +5 -0
  78. data/test/test_apps/Test_3_0_3/config/routes.rb +58 -0
  79. data/test/test_apps/Test_3_0_3/config.ru +4 -0
  80. data/test/test_apps/Test_3_0_3/db/seeds.rb +7 -0
  81. data/test/test_apps/Test_3_0_3/lib/tasks/.gitkeep +0 -0
  82. data/test/test_apps/Test_3_0_3/public/404.html +26 -0
  83. data/test/test_apps/Test_3_0_3/public/422.html +26 -0
  84. data/test/test_apps/Test_3_0_3/public/500.html +26 -0
  85. data/test/test_apps/Test_3_0_3/public/favicon.ico +0 -0
  86. data/test/test_apps/Test_3_0_3/public/images/rails.png +0 -0
  87. data/test/test_apps/Test_3_0_3/public/index.html +239 -0
  88. data/test/test_apps/Test_3_0_3/public/javascripts/application.js +2 -0
  89. data/test/test_apps/Test_3_0_3/public/javascripts/controls.js +965 -0
  90. data/test/test_apps/Test_3_0_3/public/javascripts/dragdrop.js +974 -0
  91. data/test/test_apps/Test_3_0_3/public/javascripts/effects.js +1123 -0
  92. data/test/test_apps/Test_3_0_3/public/javascripts/prototype.js +6001 -0
  93. data/test/test_apps/Test_3_0_3/public/javascripts/rails.js +175 -0
  94. data/test/test_apps/Test_3_0_3/public/robots.txt +5 -0
  95. data/test/test_apps/Test_3_0_3/public/stylesheets/.gitkeep +0 -0
  96. data/test/test_apps/Test_3_0_3/script/rails +6 -0
  97. data/test/test_apps/Test_3_0_3/test/performance/browsing_test.rb +9 -0
  98. data/test/test_apps/Test_3_0_3/test/test_helper.rb +13 -0
  99. data/test/test_apps/Test_3_0_3/vendor/plugins/.gitkeep +0 -0
  100. data/test/test_apps/Test_3_1_12/.gitignore +15 -0
  101. data/test/test_apps/Test_3_1_12/Gemfile +60 -0
  102. data/test/test_apps/Test_3_1_12/README +261 -0
  103. data/test/test_apps/Test_3_1_12/Rakefile +7 -0
  104. data/test/test_apps/Test_3_1_12/app/assets/images/rails.png +0 -0
  105. data/test/test_apps/Test_3_1_12/app/assets/javascripts/application.js +9 -0
  106. data/test/test_apps/Test_3_1_12/app/assets/stylesheets/application.css +7 -0
  107. data/test/test_apps/Test_3_1_12/app/controllers/application_controller.rb +3 -0
  108. data/test/test_apps/Test_3_1_12/app/helpers/application_helper.rb +2 -0
  109. data/test/test_apps/Test_3_1_12/app/mailers/.gitkeep +0 -0
  110. data/test/test_apps/Test_3_1_12/app/models/.gitkeep +0 -0
  111. data/test/test_apps/Test_3_1_12/app/views/layouts/application.html.erb +14 -0
  112. data/test/test_apps/Test_3_1_12/config/application.rb +48 -0
  113. data/test/test_apps/Test_3_1_12/config/boot.rb +6 -0
  114. data/test/test_apps/Test_3_1_12/config/database.yml +6 -0
  115. data/test/test_apps/Test_3_1_12/config/environment.rb +5 -0
  116. data/test/test_apps/Test_3_1_12/config/environments/development.rb +30 -0
  117. data/test/test_apps/Test_3_1_12/config/environments/production.rb +60 -0
  118. data/test/test_apps/Test_3_1_12/config/environments/test.rb +39 -0
  119. data/test/test_apps/Test_3_1_12/config/initializers/backtrace_silencers.rb +7 -0
  120. data/test/test_apps/Test_3_1_12/config/initializers/inflections.rb +10 -0
  121. data/test/test_apps/Test_3_1_12/config/initializers/mime_types.rb +5 -0
  122. data/test/test_apps/Test_3_1_12/config/initializers/secret_token.rb +7 -0
  123. data/test/test_apps/Test_3_1_12/config/initializers/session_store.rb +8 -0
  124. data/test/test_apps/Test_3_1_12/config/initializers/wrap_parameters.rb +14 -0
  125. data/test/test_apps/Test_3_1_12/config/locales/en.yml +5 -0
  126. data/test/test_apps/Test_3_1_12/config/routes.rb +58 -0
  127. data/test/test_apps/Test_3_1_12/config.ru +4 -0
  128. data/test/test_apps/Test_3_1_12/db/seeds.rb +7 -0
  129. data/test/test_apps/Test_3_1_12/lib/assets/.gitkeep +0 -0
  130. data/test/test_apps/Test_3_1_12/lib/tasks/.gitkeep +0 -0
  131. data/test/test_apps/Test_3_1_12/log/.gitkeep +0 -0
  132. data/test/test_apps/Test_3_1_12/public/404.html +26 -0
  133. data/test/test_apps/Test_3_1_12/public/422.html +26 -0
  134. data/test/test_apps/Test_3_1_12/public/500.html +26 -0
  135. data/test/test_apps/Test_3_1_12/public/favicon.ico +0 -0
  136. data/test/test_apps/Test_3_1_12/public/index.html +241 -0
  137. data/test/test_apps/Test_3_1_12/public/robots.txt +5 -0
  138. data/test/test_apps/Test_3_1_12/script/rails +6 -0
  139. data/test/test_apps/Test_3_1_12/test/fixtures/.gitkeep +0 -0
  140. data/test/test_apps/Test_3_1_12/test/functional/.gitkeep +0 -0
  141. data/test/test_apps/Test_3_1_12/test/integration/.gitkeep +0 -0
  142. data/test/test_apps/Test_3_1_12/test/performance/browsing_test.rb +12 -0
  143. data/test/test_apps/Test_3_1_12/test/test_helper.rb +13 -0
  144. data/test/test_apps/Test_3_1_12/test/unit/.gitkeep +0 -0
  145. data/test/test_apps/Test_3_1_12/vendor/assets/stylesheets/.gitkeep +0 -0
  146. data/test/test_apps/Test_3_1_12/vendor/plugins/.gitkeep +0 -0
  147. data/test/test_apps/Test_3_2_13/.gitignore +15 -0
  148. data/test/test_apps/Test_3_2_13/Gemfile +58 -0
  149. data/test/test_apps/Test_3_2_13/README.rdoc +261 -0
  150. data/test/test_apps/Test_3_2_13/Rakefile +7 -0
  151. data/test/test_apps/Test_3_2_13/app/assets/images/rails.png +0 -0
  152. data/test/test_apps/Test_3_2_13/app/assets/javascripts/application.js +15 -0
  153. data/test/test_apps/Test_3_2_13/app/assets/stylesheets/application.css +13 -0
  154. data/test/test_apps/Test_3_2_13/app/controllers/application_controller.rb +3 -0
  155. data/test/test_apps/Test_3_2_13/app/helpers/application_helper.rb +2 -0
  156. data/test/test_apps/Test_3_2_13/app/mailers/.gitkeep +0 -0
  157. data/test/test_apps/Test_3_2_13/app/models/.gitkeep +0 -0
  158. data/test/test_apps/Test_3_2_13/app/views/layouts/application.html.erb +14 -0
  159. data/test/test_apps/Test_3_2_13/config/application.rb +62 -0
  160. data/test/test_apps/Test_3_2_13/config/boot.rb +6 -0
  161. data/test/test_apps/Test_3_2_13/config/database.yml +6 -0
  162. data/test/test_apps/Test_3_2_13/config/environment.rb +5 -0
  163. data/test/test_apps/Test_3_2_13/config/environments/development.rb +37 -0
  164. data/test/test_apps/Test_3_2_13/config/environments/production.rb +67 -0
  165. data/test/test_apps/Test_3_2_13/config/environments/test.rb +37 -0
  166. data/test/test_apps/Test_3_2_13/config/initializers/backtrace_silencers.rb +7 -0
  167. data/test/test_apps/Test_3_2_13/config/initializers/inflections.rb +15 -0
  168. data/test/test_apps/Test_3_2_13/config/initializers/mime_types.rb +5 -0
  169. data/test/test_apps/Test_3_2_13/config/initializers/secret_token.rb +7 -0
  170. data/test/test_apps/Test_3_2_13/config/initializers/session_store.rb +8 -0
  171. data/test/test_apps/Test_3_2_13/config/initializers/wrap_parameters.rb +14 -0
  172. data/test/test_apps/Test_3_2_13/config/locales/en.yml +5 -0
  173. data/test/test_apps/Test_3_2_13/config/routes.rb +58 -0
  174. data/test/test_apps/Test_3_2_13/config.ru +4 -0
  175. data/test/test_apps/Test_3_2_13/db/seeds.rb +7 -0
  176. data/test/test_apps/Test_3_2_13/lib/assets/.gitkeep +0 -0
  177. data/test/test_apps/Test_3_2_13/lib/tasks/.gitkeep +0 -0
  178. data/test/test_apps/Test_3_2_13/log/.gitkeep +0 -0
  179. data/test/test_apps/Test_3_2_13/public/404.html +26 -0
  180. data/test/test_apps/Test_3_2_13/public/422.html +26 -0
  181. data/test/test_apps/Test_3_2_13/public/500.html +25 -0
  182. data/test/test_apps/Test_3_2_13/public/favicon.ico +0 -0
  183. data/test/test_apps/Test_3_2_13/public/index.html +241 -0
  184. data/test/test_apps/Test_3_2_13/public/robots.txt +5 -0
  185. data/test/test_apps/Test_3_2_13/script/rails +6 -0
  186. data/test/test_apps/Test_3_2_13/test/fixtures/.gitkeep +0 -0
  187. data/test/test_apps/Test_3_2_13/test/functional/.gitkeep +0 -0
  188. data/test/test_apps/Test_3_2_13/test/integration/.gitkeep +0 -0
  189. data/test/test_apps/Test_3_2_13/test/performance/browsing_test.rb +12 -0
  190. data/test/test_apps/Test_3_2_13/test/test_helper.rb +13 -0
  191. data/test/test_apps/Test_3_2_13/test/unit/.gitkeep +0 -0
  192. data/test/test_apps/Test_3_2_13/vendor/assets/javascripts/.gitkeep +0 -0
  193. data/test/test_apps/Test_3_2_13/vendor/assets/stylesheets/.gitkeep +0 -0
  194. data/test/test_apps/Test_3_2_13/vendor/plugins/.gitkeep +0 -0
  195. data/test/test_apps/Test_4_0_0_rc1/.gitignore +16 -0
  196. data/test/test_apps/Test_4_0_0_rc1/Gemfile +65 -0
  197. data/test/test_apps/Test_4_0_0_rc1/README.rdoc +28 -0
  198. data/test/test_apps/Test_4_0_0_rc1/Rakefile +6 -0
  199. data/test/test_apps/Test_4_0_0_rc1/app/assets/javascripts/application.js +16 -0
  200. data/test/test_apps/Test_4_0_0_rc1/app/assets/stylesheets/application.css +13 -0
  201. data/test/test_apps/Test_4_0_0_rc1/app/controllers/application_controller.rb +5 -0
  202. data/test/test_apps/Test_4_0_0_rc1/app/controllers/concerns/.keep +0 -0
  203. data/test/test_apps/Test_4_0_0_rc1/app/helpers/application_helper.rb +2 -0
  204. data/test/test_apps/Test_4_0_0_rc1/app/mailers/.keep +0 -0
  205. data/test/test_apps/Test_4_0_0_rc1/app/models/.keep +0 -0
  206. data/test/test_apps/Test_4_0_0_rc1/app/models/concerns/.keep +0 -0
  207. data/test/test_apps/Test_4_0_0_rc1/app/views/layouts/application.html.erb +14 -0
  208. data/test/test_apps/Test_4_0_0_rc1/bin/bundle +3 -0
  209. data/test/test_apps/Test_4_0_0_rc1/bin/rails +4 -0
  210. data/test/test_apps/Test_4_0_0_rc1/bin/rake +4 -0
  211. data/test/test_apps/Test_4_0_0_rc1/config/application.rb +23 -0
  212. data/test/test_apps/Test_4_0_0_rc1/config/boot.rb +4 -0
  213. data/test/test_apps/Test_4_0_0_rc1/config/database.yml +7 -0
  214. data/test/test_apps/Test_4_0_0_rc1/config/environment.rb +5 -0
  215. data/test/test_apps/Test_4_0_0_rc1/config/environments/development.rb +29 -0
  216. data/test/test_apps/Test_4_0_0_rc1/config/environments/production.rb +80 -0
  217. data/test/test_apps/Test_4_0_0_rc1/config/environments/test.rb +36 -0
  218. data/test/test_apps/Test_4_0_0_rc1/config/initializers/backtrace_silencers.rb +7 -0
  219. data/test/test_apps/Test_4_0_0_rc1/config/initializers/filter_parameter_logging.rb +4 -0
  220. data/test/test_apps/Test_4_0_0_rc1/config/initializers/inflections.rb +16 -0
  221. data/test/test_apps/Test_4_0_0_rc1/config/initializers/mime_types.rb +5 -0
  222. data/test/test_apps/Test_4_0_0_rc1/config/initializers/secret_token.rb +12 -0
  223. data/test/test_apps/Test_4_0_0_rc1/config/initializers/session_store.rb +3 -0
  224. data/test/test_apps/Test_4_0_0_rc1/config/initializers/wrap_parameters.rb +14 -0
  225. data/test/test_apps/Test_4_0_0_rc1/config/locales/en.yml +23 -0
  226. data/test/test_apps/Test_4_0_0_rc1/config/routes.rb +49 -0
  227. data/test/test_apps/Test_4_0_0_rc1/config.ru +4 -0
  228. data/test/test_apps/Test_4_0_0_rc1/db/seeds.rb +7 -0
  229. data/test/test_apps/Test_4_0_0_rc1/lib/assets/.keep +0 -0
  230. data/test/test_apps/Test_4_0_0_rc1/lib/tasks/.keep +0 -0
  231. data/test/test_apps/Test_4_0_0_rc1/log/.keep +0 -0
  232. data/test/test_apps/Test_4_0_0_rc1/public/404.html +58 -0
  233. data/test/test_apps/Test_4_0_0_rc1/public/422.html +58 -0
  234. data/test/test_apps/Test_4_0_0_rc1/public/500.html +57 -0
  235. data/test/test_apps/Test_4_0_0_rc1/public/favicon.ico +0 -0
  236. data/test/test_apps/Test_4_0_0_rc1/public/robots.txt +5 -0
  237. data/test/test_apps/Test_4_0_0_rc1/test/controllers/.keep +0 -0
  238. data/test/test_apps/Test_4_0_0_rc1/test/fixtures/.keep +0 -0
  239. data/test/test_apps/Test_4_0_0_rc1/test/helpers/.keep +0 -0
  240. data/test/test_apps/Test_4_0_0_rc1/test/integration/.keep +0 -0
  241. data/test/test_apps/Test_4_0_0_rc1/test/mailers/.keep +0 -0
  242. data/test/test_apps/Test_4_0_0_rc1/test/models/.keep +0 -0
  243. data/test/test_apps/Test_4_0_0_rc1/test/test_helper.rb +15 -0
  244. data/test/test_apps/Test_4_0_0_rc1/vendor/assets/javascripts/.keep +0 -0
  245. data/test/test_apps/Test_4_0_0_rc1/vendor/assets/stylesheets/.keep +0 -0
  246. data.tar.gz.sig +2 -0
  247. metadata +659 -0
  248. metadata.gz.sig +4 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .DS_Store
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Carlos A. Carro Duplá
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # cant_wait
2
+
3
+ This ruby gem allows to add a statement timeout for PostgreSQL databases within a Ruby on Rails application.
4
+
5
+ If any SQL statement takes more time than the timeout value (measured in milliseconds), its execution will be cancelled, and Active Record
6
+ would raise a PGError exception.
7
+
8
+ ActiveRecord::StatementInvalid: PGError: ERROR: canceling statement due to statement timeout
9
+
10
+ From the PostgreSQL documentation:
11
+
12
+ > statement_timeout (integer)
13
+ >
14
+ > Abort any statement that takes more than the specified number of milliseconds, starting from the time the command arrives at the server from the client. If log_min_error_statement is set to ERROR or lower, the statement that timed out will also be logged. A value of zero (the default) turns this off.
15
+ >
16
+ > Setting statement_timeout in postgresql.conf is not recommended because it would affect all sessions.
17
+ >
18
+ > (© 1996-2013 The PostgreSQL Global Development Group)
19
+
20
+ (Visit <http://www.postgresql.org/docs/devel/static/runtime-config-client.html> for more information)
21
+
22
+
23
+ The gem has been tested for ruby 1.9.2 and above, as well as with Rails 3.0.3 and above. Tested also with PostgreSQL 8 and 9, but it may work also in other versions supported by Active Record (see PostgreSQL documentation).
24
+
25
+ If you find any problems, please feel free to open any issues within the gem repository ([GitHub](https://github.com/CarlosCD/cant_wait)).
26
+
27
+
28
+ ## Installation
29
+
30
+ Add this line to your application's Gemfile:
31
+
32
+ gem 'cant_wait', '~> 0.0.1'
33
+
34
+ And then execute:
35
+
36
+ $ bundle
37
+
38
+
39
+ ## Usage
40
+
41
+ In the file config/database.yml, indicate a timeout in milliseconds for each environment:
42
+
43
+ production:
44
+ adapter: postgresql
45
+ timeout: 120_000 # 2 minutes
46
+ ...
47
+
48
+ Then restart the application to establish the new configuration parameter(s).
49
+
50
+
51
+ ## Development / Contributing
52
+
53
+ * Source hosted on [GitHub](https://github.com/CarlosCD/cant_wait)
54
+ * Details on the test setup are in the file Readme.md within the test folder. It includes details on testing in several Ruby and Rails versions.
55
+
56
+ Contributing:
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
63
+
64
+
65
+ May 2013
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ @gem_spec = eval(File.read(Dir['*.gemspec'].first))
2
+
3
+ Dir[File.join('tasks', '*.rake')].each do |file_name|
4
+ load file_name
5
+ end
6
+
7
+ task :default do
8
+ puts 'No default task defined. Please take a look to test/Readme.md for details.'
9
+ puts 'Here is what you can do:'
10
+ puts
11
+ system 'bundle exec rake -T'
12
+ end
13
+
14
+ private
15
+
16
+ def boolean_env_param(environment_var, *values)
17
+ ENV[environment_var] && values.include?(ENV[environment_var].strip.downcase)
18
+ end
data/cant_wait.gemspec ADDED
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cant_wait/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cant_wait'
8
+ spec.version = CantWait::VERSION
9
+ spec.authors = ['Carlos A. Carro Duplá']
10
+ spec.email = ['ccarrodupla@gmail.com']
11
+ spec.description = <<-EOF
12
+ Adds a timeout setting for PostgreSQL databases in a Ruby on Rails application.
13
+ If any SQL statement takes more time than the timeout value, it will be cancelled, and ActiveRecord
14
+ would raise a PGError exception.
15
+ In the config/database.yml file, indicate a timeout in milliseconds for each environment:
16
+ production:
17
+ adapter: postgresql
18
+ timeout: 120_000 # 2 minutes
19
+ ...
20
+ (see documentation for more details)
21
+ EOF
22
+ spec.summary = %q{Adds statement timeout for PostgreSQL databases in Ruby on Rails. Timeout is measured in milliseconds.}
23
+ spec.homepage = 'https://github.com/CarlosCD/cant_wait'
24
+ spec.license = 'MIT'
25
+ spec.signing_key = '/users/CarlosCD/.ssh/private_key.pem'
26
+ spec.cert_chain = ['/users/CarlosCD/.ssh/public_cert.pem']
27
+
28
+ spec.add_dependency 'rails', '>= 3.0.3'
29
+ spec.files = `git ls-files`.split($/)
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_development_dependency 'bundler', '~> 1.3'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ if RUBY_ENGINE == 'jruby' && RUBY_PLATFORM == 'java'
36
+ spec.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.2'
37
+ spec.add_development_dependency 'activerecord-jdbcpostgresql-adapter', '~> 1.2'
38
+ spec.add_development_dependency 'jdbc-postgres', '~> 9'
39
+ else
40
+ spec.add_development_dependency 'pg', '~> 0'
41
+ end
42
+ if RUBY_PLATFORM =~ /darwin/i
43
+ spec.add_development_dependency 'minitest-growl', '~> 0.0.3'
44
+ # minitest-growl small problem with minitest 5:
45
+ spec.add_development_dependency('minitest', '~> 4.7.4')
46
+ else
47
+ spec.add_development_dependency('minitest', '~> 5') if RUBY_VERSION < '1.9.3'
48
+ end
49
+ end
@@ -0,0 +1,20 @@
1
+ ##
2
+ # This class is a Railtie which adds an initializer to Rails
3
+ #
4
+ # It reads the database configuration timeout, and if the adapter is PostgreSQL,
5
+ # sets its value as the PostgreSQL statement_timeout.
6
+
7
+ class CantWaitRailtie < Rails::Railtie
8
+
9
+ initializer 'cant_wait.set_timeout' do
10
+ begin
11
+ database_config = Rails.configuration.database_configuration[Rails.env]
12
+ if (database_config['adapter'].downcase == 'postgresql') && database_config['timeout']
13
+ ActiveRecord::Base.connection.execute "set statement_timeout = #{database_config['timeout']}"
14
+ end
15
+ rescue Exception => e
16
+ puts "\n#{e.message}\n\n"
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module CantWait
2
+ VERSION = '0.0.1'
3
+ end
data/lib/cant_wait.rb ADDED
@@ -0,0 +1,6 @@
1
+ begin
2
+ require 'cant_wait/version'
3
+ require 'cant_wait/cant_wait_railtie' if defined? Rails
4
+ rescue LoadError
5
+ puts 'Some needed files are not accessible to the cant_wait gem, please check its integrity.'
6
+ end
@@ -0,0 +1,108 @@
1
+ # Development and debugging:
2
+ #
3
+ # rake debug:build # Temporarily builds the gem without committing files to git
4
+ # rake debug:try # Temporarily install the gem without committing files to git
5
+
6
+ namespace :debug do
7
+
8
+ # rake debug:build SLOW=y
9
+ # rake debug:build
10
+ desc 'Temporarily builds the gem without committing files to git'
11
+ # Creates the gem file, without installing it, to try it somewhere else.
12
+ # It doesn't alter the git repository, even if some things may not have been commited yet
13
+ # Argument (env.):
14
+ # SLOW=t Pauses or not in each step.
15
+ # Other possible values (meaning the same): t, true, y, yes, on, ok
16
+ # Default: no pause (no flag)
17
+ task :build do
18
+ pausing = boolean_env_param 'SLOW', 't', 'y', 'on', 'ok', 'yes', 'true'
19
+ use_gem_as_it_is @gem_spec, pausing, get_it_back: true
20
+ end
21
+
22
+ # rake debug:install SLOW=y
23
+ # rake debug:install
24
+ desc 'Temporarily install the gem without committing files to git'
25
+ # Install the gem as it is, during the development cycle, in order to try it out
26
+ # It doesn't alter the git repository, even if some things may not have been committed yet
27
+ # Argument (env.):
28
+ # SLOW=t Pauses or not in each step.
29
+ # Other possible values (meaning the same): t, true, y, yes, on, ok
30
+ # Default: no pause (no flag)
31
+ task :install do
32
+ pausing = boolean_env_param 'SLOW', 't', 'y', 'on', 'ok', 'yes', 'true'
33
+ use_gem_as_it_is @gem_spec, pausing, install_gem: true
34
+ end
35
+
36
+ private
37
+
38
+ # options = { get_it_back: false, install_gem: false }
39
+ def use_gem_as_it_is(gem_spec, pause=true, options={})
40
+
41
+ gem_name = gem_spec.name
42
+ gem_version = gem_spec.version
43
+ gem_pkg_directory = FileUtils.pwd+'/pkg'
44
+
45
+ little_step 'Removing previous test files from the /tmp folder', pause do
46
+ FileUtils.rm_rf "/tmp/#{gem_name}"
47
+ end
48
+
49
+ little_step 'Copying the gem folder to /tmp...', pause do
50
+ FileUtils.cp_r '.', "/tmp/#{gem_name}"
51
+ end
52
+
53
+ little_step "Changing work directory to /tmp/#{gem_name}", pause do
54
+ FileUtils.cd "/tmp/#{gem_name}"
55
+ puts "And now the folder is (pwd): #{FileUtils.pwd}"
56
+ end
57
+
58
+ little_step 'Commiting changes to GIT', pause do
59
+ system 'git add .'
60
+ system 'git commit -m "Just testing"'
61
+ end
62
+
63
+ # Note: This may have issues with Ruby 2.0.0
64
+ little_step 'Changing permisions in the gem files to make them world-readeable', pause do
65
+ gem_spec.files.each do |file_name|
66
+ FileUtils.chmod(File.stat(file_name).mode | 444, file_name, { verbose: true }) if (File.stat(file_name).mode & 444) != 444
67
+ end
68
+ end
69
+
70
+ little_step 'Building the gem', pause do
71
+ system "gem build #{gem_name}.gemspec"
72
+ end
73
+
74
+ # Now do something with the new gem:
75
+
76
+ if options[:get_it_back]
77
+ little_step 'Copying the gem file to the initial folder', pause do
78
+ FileUtils.mkdir gem_pkg_directory rescue nil
79
+ FileUtils.cp "#{gem_name}-#{gem_version}.gem", gem_pkg_directory
80
+ end
81
+ end
82
+
83
+ if options[:install_gem]
84
+ little_step 'Installing the gem locally (rvm-dependent)', pause do
85
+ system "rvm current"
86
+ system "gem install #{gem_name}-#{gem_version}.gem"
87
+ end
88
+ end
89
+
90
+ little_step 'Cleaning up temporary files', pause do
91
+ FileUtils.rm_rf "/tmp/#{gem_name}"
92
+ end
93
+
94
+ end
95
+
96
+ def little_step (message, pause=true)
97
+ puts "#{message}..."
98
+ yield if block_given?
99
+ wait_for_input if pause
100
+ puts '---'
101
+ end
102
+
103
+ def wait_for_input(message='Press [enter] to continue')
104
+ puts message
105
+ STDIN.gets
106
+ end
107
+
108
+ end
@@ -0,0 +1,37 @@
1
+ # Gem building and publication:
2
+ #
3
+ # rake gemspec_valid # Validate the gemspec
4
+ #
5
+ # rake build # Build cant_wait-0.0.1.gem into the pkg directory.
6
+ # rake clean # Clean automatically generated gem files (removes the pkg folder).
7
+ #
8
+ # rake install # Build and install cant_wait-0.0.1.gem into system gems.
9
+ #
10
+ # rake push # Push pkg/cant_wait-0.0.1.gem to rubygems, if it exists.
11
+ # rake release # Create tag v0.0.1 and build and push cant_wait-0.0.1.gem to Rubygems
12
+
13
+ begin
14
+ require 'bundler/gem_tasks' # Adds these tasks: build, install and release
15
+ rescue LoadError
16
+ puts 'You may need Bundler to build this gem.'
17
+ end
18
+
19
+ desc 'Validate the gemspec'
20
+ # It calls the instance method Gem::Specification.validate
21
+ # It checks that the specification contains all required fields, and does a very basic sanity check.
22
+ # It raises InvalidSpecificationException if the spec does not pass the checks...
23
+ # Otherwise outputs nothing
24
+ # See http://rubygems.rubyforge.org/rubygems-update/Gem/Specification.html
25
+ task :gemspec_valid do
26
+ @gem_spec.validate
27
+ end
28
+
29
+ desc 'Clean automatically generated gem files (removes the pkg folder).'
30
+ task :clean do
31
+ FileUtils.rm_rf 'pkg'
32
+ end
33
+
34
+ desc "Push pkg/#{@gem_spec.name}-#{@gem_spec.version}.gem to rubygems, if it exists."
35
+ task :push do
36
+ system "gem push pkg/#{@gem_spec.name}-#{@gem_spec.version}.gem"
37
+ end
@@ -0,0 +1,134 @@
1
+ # Testing:
2
+ #
3
+ # rake test:bundle # Installs gems needed for the test apps (Bundle Install for each Rails app's Gemfile)
4
+ # rake test:run # Tests the gem's behavior, using 5 test rails apps of different versions, and random timeouts
5
+
6
+ namespace :test do
7
+
8
+ TEST_RAILS_APP = [{ version: '3.0.3', rails_root: 'test/test_apps/Test_3_0_3'},
9
+ { version: '3.0.20', rails_root: 'test/test_apps/Test_3_0_20'},
10
+ { version: '3.1.12', rails_root: 'test/test_apps/Test_3_1_12'},
11
+ { version: '3.2.13', rails_root: 'test/test_apps/Test_3_2_13'},
12
+ { version: '4.0.0.rc1', rails_root: 'test/test_apps/Test_4_0_0_rc1'}]
13
+
14
+ # Argument (env.):
15
+ # VERBOSE=t Gives more information about what's going on
16
+ # Other possible values (meaning the same): t, true, y, yes, on, ok
17
+ # Default: no verbose (no flag)
18
+ desc "Tests the gem's behavior, using 5 test rails apps of different versions, and random timeouts"
19
+ task :run do
20
+ # Verbose setting:
21
+ verbose = boolean_env_param 'VERBOSE', 't', 'y', 'on', 'ok', 'yes', 'true'
22
+ if verbose
23
+ puts '------------------------------------------------'
24
+ puts 'VERBOSE mode ON'
25
+ print 'rvm setting (if rvm is being used): '
26
+ system 'rvm current'
27
+ puts "We'll run 5 times the test #1 (5 rails versions)"
28
+ puts "Gem's ENV['BUNDLE_GEMFILE']='#{ENV['BUNDLE_GEMFILE']}'"
29
+ end
30
+ can_wait_bundle_gemfile = ENV['BUNDLE_GEMFILE']
31
+ 5.times do |num|
32
+ puts "====TESTING Rails version #{TEST_RAILS_APP[num][:version]}================="
33
+ if (TEST_RAILS_APP[num][:version] >= '4') && (RUBY_VERSION < '1.9.3')
34
+ puts 'At least Ruby 1.9.3 is required for rails 4 or above...'
35
+ else
36
+ # Uses Gemfile for the given version of rails
37
+ gemfile_path = escape_filename_espaces TEST_RAILS_APP[num][:rails_root]
38
+ gemfile = gemfile_path<<'/Gemfile'
39
+ ENV['BUNDLE_GEMFILE'] = gemfile
40
+ if verbose
41
+ puts "Gemfile to be used in this case (ENV['BUNDLE_GEMFILE']): '#{ENV['BUNDLE_GEMFILE']}'"
42
+ print 'echo $BUNDLE_GEMFILE: '
43
+ system 'echo $BUNDLE_GEMFILE'
44
+ end
45
+ # We check the Gemfile and bundle install:
46
+ puts 'bundle check' if verbose
47
+ if system("bundle check --gemfile='#{gemfile_path}' > /dev/null")
48
+ if verbose
49
+ puts "The Gemfile's dependencies are satisfied"
50
+ puts 'Testing....'
51
+ end
52
+ # Run several timeouts test for that version of rails (bundle exec...)
53
+ # Only the last argument (V) is optional here:
54
+ system "bundle exec ruby test/cant_wait_test.rb #{num} #{@gem_spec.version} #{'V' if verbose}"
55
+ else
56
+ puts ' bundle check and bundle failed! Check your rails test app Gemfile.'
57
+ puts ' If there are missing gems, run rake test:bundle_apps'
58
+ end
59
+ end
60
+ end
61
+ puts '------------------------------------------------'
62
+ ENV['BUNDLE_GEMFILE'] = can_wait_bundle_gemfile
63
+ if verbose
64
+ puts "Finally set again the gem ENV['BUNDLE_GEMFILE'] as:"
65
+ puts " '#{ENV['BUNDLE_GEMFILE']}'"
66
+ end
67
+ end
68
+
69
+ # Arguments (env.):
70
+ # VERBOSE=t It gives more information about what's going on
71
+ # REBUILD=t It removes the Gemfile.lock, so it forces a clean bundle install
72
+ # Other possible values (meaning the same): t, true, y, yes, on, ok
73
+ # Default: no verbose (no flags)
74
+ # Example:
75
+ # $ rake test:bundle_apps REBUILD=y
76
+ desc "Installs gems needed for the test apps (Bundle Install for each Rails app's Gemfile)"
77
+ task :bundle do
78
+ # Rebuild setting:
79
+ rebuild = boolean_env_param 'REBUILD', 't', 'y', 'on', 'ok', 'yes', 'true'
80
+ # Verbose setting:
81
+ verbose = boolean_env_param 'VERBOSE', 't', 'y', 'on', 'ok', 'yes', 'true'
82
+ if verbose
83
+ puts "We'll bundle install for each of the 5 test rails apps"
84
+ puts '============================================================'
85
+ print ' rvm setting (if rvm is being used): '
86
+ system 'rvm current'
87
+ puts " Gem's ENV['BUNDLE_GEMFILE']='#{ENV['BUNDLE_GEMFILE']}'" if verbose
88
+ end
89
+ can_wait_bundle_gemfile = ENV['BUNDLE_GEMFILE']
90
+ initial_directory = FileUtils.pwd
91
+ puts " Initial task directory: #{initial_directory}" if verbose
92
+ 5.times do |num|
93
+ if (TEST_RAILS_APP[num][:version] >= '4') && (RUBY_VERSION < '1.9.3')
94
+ puts 'At least Ruby 1.9.3 is required for rails 4 or above...'
95
+ else
96
+ puts "====Rails app for Rails v. #{TEST_RAILS_APP[num][:version]}================"
97
+ if verbose
98
+ puts " Present directory (pwd): #{FileUtils.pwd}"
99
+ puts " Changing to the app root..."
100
+ end
101
+ FileUtils.cd escape_filename_espaces TEST_RAILS_APP[num][:rails_root]
102
+ puts " Now present directory (pwd) is: #{FileUtils.pwd}" if verbose
103
+ app_root = escape_filename_espaces FileUtils.pwd
104
+ puts " App Root: #{app_root}" if verbose
105
+ # Rebuilding the Gemfile.lock installs missing gems
106
+ if rebuild
107
+ puts 'Removing Gemfile.lock by installing any missing gems' if verbose
108
+ FileUtils.rm 'Gemfile.lock' rescue nil
109
+ end
110
+ # Uses the Gemfile for the given version of rails
111
+ ENV['BUNDLE_GEMFILE'] = 'Gemfile'
112
+ puts " Gemfile used in this case: (ENV['BUNDLE_GEMFILE']): '#{ENV['BUNDLE_GEMFILE']}'" if verbose
113
+ # Bundle install this Gemfile:
114
+ puts 'Bundle install failed! Check your rails test app' unless system('bundle')
115
+ # Back to where we were:
116
+ puts " Changing to the initial directory..." if verbose
117
+ FileUtils.cd initial_directory
118
+ end
119
+ end
120
+ puts '------------------------------------------------'
121
+ ENV['BUNDLE_GEMFILE'] = can_wait_bundle_gemfile
122
+ if verbose
123
+ puts "Finally set again the gem ENV['BUNDLE_GEMFILE'] as:"
124
+ puts " '#{ENV['BUNDLE_GEMFILE']}'"
125
+ end
126
+ end
127
+
128
+ private
129
+
130
+ def escape_filename_espaces(filename)
131
+ filename.gsub(' ', '\ ')
132
+ end
133
+
134
+ end
data/test/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # cant_wait
2
+ # Development and Test
3
+
4
+
5
+ ## Test preferences and setup
6
+
7
+ - Minitest, to keep things simple.
8
+ - PostgreSQL database server (localhost or not).
9
+ - I used rvm (not a need if other ruby version manager is preferred).
10
+
11
+
12
+ ## Test strategy: different Rails apps with random timeouts
13
+
14
+ The approach of using minimal Rails components (ActiveRecord, Railties) is problematic due to the amount of code that Rails loads and of how it changes in the default behavior of Ruby. Running several Rails apps at the same time, and even if it is done in different threads, may result in:
15
+
16
+ RuntimeError: You cannot have more than one Rails::Application
17
+
18
+ This approach also makes the test cases too distant to the real conditions you may encounter in isolated Rails applications. I finally choose to test several versions of Rails/ActiveRecord independently.
19
+
20
+ I created 5 simple Rails apps in the folder test/test_apps. Then I modified their Gemfile by adding gems for PostgreSQL, Minitest and Growl:
21
+
22
+ if RUBY_ENGINE == 'jruby' && RUBY_PLATFORM == 'java'
23
+ gem 'activerecord-jdbc-adapter', '~> 1.2'
24
+ gem 'activerecord-jdbcpostgresql-adapter', '~> 1.2'
25
+ gem 'jdbc-postgres', '~> 9'
26
+ else
27
+ gem 'pg', '~> 0'
28
+ end
29
+
30
+ if RUBY_PLATFORM =~ /darwin/i
31
+ gem 'minitest-growl', '~> 0.0.3'
32
+ gem 'minitest', '~> 4.7.4'
33
+ else
34
+ gem('minitest', '~> 5') if RUBY_VERSION < '1.9.3'
35
+ end
36
+
37
+ gem 'cant_wait', path: File.expand_path('../../../..', __FILE__)
38
+
39
+ The rails apps require bundle install, specially when changing the version of Ruby to be used. To make it easier, I added a rake task (rake test:bundle).
40
+
41
+ The test is run through the rake test:run command. Due to the complex setup needed, I choose not to use the rake default to run the test.
42
+
43
+ The test (rake test:run) goes over each rails app in sequence and:
44
+
45
+ 1. It sets Bundle to use the test app's Gemfile
46
+ 2. It creates the app's config/database.yml with a random timeout
47
+ 3. It starts Rails
48
+ 4. It checks the version of Rails and ActiveRecord running.
49
+ 5. It checks that the PostgreSQL connection's statement_timeout is the expected.
50
+
51
+
52
+ ## The Testing process
53
+
54
+ After cloning the gem, you can start testing it by following these steps:
55
+
56
+ 1. Choose the version of Ruby you want to use.
57
+ For example, if you have a rvm 1.9.3 installed, and a gemset called mygemset:
58
+
59
+ rvm use 1.9.3@mygemset
60
+
61
+ 2. Optional: if you are using Mac OS, get Growl
62
+
63
+ 3. Get the gem's dependencies:
64
+
65
+ bundle
66
+
67
+ 4. Set up your PostgreSQL test database and edit accordingly the file test/database.yml
68
+
69
+ 5. Get the Rails gems used by the test rails apps included:
70
+
71
+ rake test:bundle
72
+
73
+ 6. You are now done setting all up. To run the tests:
74
+
75
+ rake test:run
76
+
77
+ If so wanted, run the tests several times. The tests use different random timeout scenarios, so each run may be a bit different.
78
+
79
+
80
+ ## Tested for
81
+
82
+ * Versions of Ruby:
83
+
84
+ jruby 1.7.4
85
+ 1.9.2-p320 (MRI's last patchlevel of 1.9.2)
86
+ 1.9.3-p429 (MRI last patchlevel of 1.9.3)
87
+ 2.0.0-p195 (MRI last patchlevel of 2.0.0)
88
+
89
+ * Versions of Rails:
90
+
91
+ Rails 3.0.3 First version using Bundler 1.3.5 (incompatible with Bundler 1.0.X)
92
+ Rails 3.0.20 Last patchlevel of Rails 3.0 (at this moment)
93
+ Rails 3.1.12 Last patchlevel of Rails 3.1
94
+ Rails 3.2.13 Last patchlevel of Rails 3.2 (many security fixes, last stable version)
95
+ Rails 4.0.0.rc1 Last Release candidate for Rails 4, the most stable version at this point in time.
96
+
97
+ * PostgreSQL versions 8.3.6 and 9.2.4.
98
+
99
+
100
+ June 2013