rollbar 2.16.2 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +47 -0
  3. data/.travis.yml +182 -94
  4. data/Appraisals +10 -10
  5. data/Gemfile +45 -13
  6. data/README.md +20 -3
  7. data/Rakefile +0 -0
  8. data/data/rollbar.snippet.js +1 -1
  9. data/docs/configuration.md +15 -0
  10. data/gemfiles/rails30.gemfile +21 -14
  11. data/gemfiles/rails31.gemfile +21 -12
  12. data/gemfiles/rails32.gemfile +18 -8
  13. data/gemfiles/rails40.gemfile +18 -6
  14. data/gemfiles/rails41.gemfile +17 -6
  15. data/gemfiles/rails42.gemfile +24 -14
  16. data/gemfiles/rails50.gemfile +20 -11
  17. data/gemfiles/rails51.gemfile +20 -10
  18. data/gemfiles/rails52.gemfile +65 -0
  19. data/gemfiles/rails60.gemfile +67 -0
  20. data/lib/generators/rollbar/rollbar_generator.rb +1 -1
  21. data/lib/rails/rollbar_runner.rb +17 -2
  22. data/lib/rollbar.rb +2 -3
  23. data/lib/rollbar/capistrano.rb +71 -39
  24. data/lib/rollbar/capistrano3.rb +56 -1
  25. data/lib/rollbar/capistrano_tasks.rb +130 -0
  26. data/lib/rollbar/configuration.rb +95 -7
  27. data/lib/rollbar/delay/active_job.rb +17 -0
  28. data/lib/rollbar/delay/girl_friday.rb +2 -2
  29. data/lib/rollbar/delay/resque.rb +4 -6
  30. data/lib/rollbar/delay/shoryuken.rb +15 -9
  31. data/lib/rollbar/delay/sidekiq.rb +6 -8
  32. data/lib/rollbar/delay/sucker_punch.rb +17 -19
  33. data/lib/rollbar/delay/thread.rb +3 -3
  34. data/lib/rollbar/deploy.rb +90 -0
  35. data/lib/rollbar/encoding/encoder.rb +9 -9
  36. data/lib/rollbar/exception_reporter.rb +19 -5
  37. data/lib/rollbar/item.rb +62 -20
  38. data/lib/rollbar/item/backtrace.rb +4 -4
  39. data/lib/rollbar/item/frame.rb +7 -1
  40. data/lib/rollbar/item/locals.rb +56 -0
  41. data/lib/rollbar/json.rb +5 -51
  42. data/lib/rollbar/language_support.rb +4 -20
  43. data/lib/rollbar/lazy_store.rb +5 -5
  44. data/lib/rollbar/logger.rb +1 -0
  45. data/lib/rollbar/logger_proxy.rb +15 -2
  46. data/lib/rollbar/middleware/js.rb +110 -10
  47. data/lib/rollbar/middleware/js/json_value.rb +26 -0
  48. data/lib/rollbar/middleware/rack.rb +4 -1
  49. data/lib/rollbar/middleware/rails/rollbar.rb +10 -1
  50. data/lib/rollbar/notifier.rb +118 -49
  51. data/lib/rollbar/notifier/trace_with_bindings.rb +65 -0
  52. data/lib/rollbar/plugin.rb +54 -6
  53. data/lib/rollbar/plugins.rb +7 -1
  54. data/lib/rollbar/plugins/active_job.rb +5 -1
  55. data/lib/rollbar/plugins/basic_socket.rb +21 -6
  56. data/lib/rollbar/plugins/delayed_job/job_data.rb +3 -3
  57. data/lib/rollbar/plugins/delayed_job/plugin.rb +3 -3
  58. data/lib/rollbar/plugins/goalie.rb +11 -3
  59. data/lib/rollbar/plugins/rails/controller_methods.rb +17 -4
  60. data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -3
  61. data/lib/rollbar/plugins/rake.rb +2 -2
  62. data/lib/rollbar/plugins/sidekiq/plugin.rb +10 -6
  63. data/lib/rollbar/rake_tasks.rb +3 -86
  64. data/lib/rollbar/request_data_extractor.rb +35 -21
  65. data/lib/rollbar/rollbar_test.rb +147 -0
  66. data/lib/rollbar/scrubbers.rb +7 -3
  67. data/lib/rollbar/scrubbers/params.rb +38 -20
  68. data/lib/rollbar/scrubbers/url.rb +27 -13
  69. data/lib/rollbar/truncation.rb +9 -2
  70. data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
  71. data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
  72. data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
  73. data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
  74. data/lib/rollbar/truncation/strings_strategy.rb +3 -4
  75. data/lib/rollbar/util.rb +75 -45
  76. data/lib/rollbar/util/hash.rb +30 -6
  77. data/lib/rollbar/util/ip_anonymizer.rb +8 -7
  78. data/lib/rollbar/util/ip_obfuscator.rb +1 -1
  79. data/lib/rollbar/version.rb +1 -1
  80. data/lib/tasks/benchmark.rake +103 -0
  81. data/rollbar.gemspec +14 -8
  82. metadata +25 -277
  83. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -49
  84. data/lib/rollbar/json/default.rb +0 -11
  85. data/lib/rollbar/json/oj.rb +0 -16
  86. data/lib/rollbar/tasks/rollbar.cap +0 -47
  87. data/spec/cacert.pem +0 -3988
  88. data/spec/controllers/home_controller_spec.rb +0 -480
  89. data/spec/delay/sidekiq_spec.rb +0 -61
  90. data/spec/delay/sucker_punch_spec.rb +0 -25
  91. data/spec/delayed/backend/test.rb +0 -140
  92. data/spec/delayed/serialization/test.rb +0 -0
  93. data/spec/dummyapp/.gitignore +0 -73
  94. data/spec/dummyapp/Rakefile +0 -7
  95. data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
  96. data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
  97. data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
  98. data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
  99. data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
  100. data/spec/dummyapp/app/helpers/.gitkeep +0 -0
  101. data/spec/dummyapp/app/mailers/.gitkeep +0 -0
  102. data/spec/dummyapp/app/models/.gitkeep +0 -0
  103. data/spec/dummyapp/app/models/book.rb +0 -5
  104. data/spec/dummyapp/app/models/post.rb +0 -9
  105. data/spec/dummyapp/app/models/user.rb +0 -9
  106. data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
  107. data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
  108. data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
  109. data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
  110. data/spec/dummyapp/app/views/home/index.html.erb +0 -4
  111. data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
  112. data/spec/dummyapp/app/views/js/test.html.erb +0 -1
  113. data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
  114. data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
  115. data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
  116. data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
  117. data/spec/dummyapp/app/views/users/index.html.erb +0 -8
  118. data/spec/dummyapp/app/views/users/show.html.erb +0 -3
  119. data/spec/dummyapp/config.ru +0 -4
  120. data/spec/dummyapp/config/application.rb +0 -59
  121. data/spec/dummyapp/config/boot.rb +0 -10
  122. data/spec/dummyapp/config/database.yml +0 -25
  123. data/spec/dummyapp/config/environment.rb +0 -5
  124. data/spec/dummyapp/config/environments/development.rb +0 -37
  125. data/spec/dummyapp/config/environments/production.rb +0 -67
  126. data/spec/dummyapp/config/environments/test.rb +0 -37
  127. data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
  128. data/spec/dummyapp/config/initializers/inflections.rb +0 -15
  129. data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
  130. data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
  131. data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
  132. data/spec/dummyapp/config/initializers/session_store.rb +0 -8
  133. data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
  134. data/spec/dummyapp/config/locales/devise.en.yml +0 -58
  135. data/spec/dummyapp/config/locales/en.yml +0 -5
  136. data/spec/dummyapp/config/routes.rb +0 -17
  137. data/spec/dummyapp/config/secrets.yml +0 -2
  138. data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
  139. data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
  140. data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
  141. data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
  142. data/spec/dummyapp/db/schema.rb +0 -41
  143. data/spec/dummyapp/db/seeds.rb +0 -12
  144. data/spec/dummyapp/lib/assets/.gitkeep +0 -0
  145. data/spec/dummyapp/public/404.html +0 -26
  146. data/spec/dummyapp/public/422.html +0 -26
  147. data/spec/dummyapp/public/500.html +0 -25
  148. data/spec/dummyapp/public/favicon.ico +0 -0
  149. data/spec/dummyapp/script/rails +0 -6
  150. data/spec/fixtures/file1 +0 -1
  151. data/spec/fixtures/file2 +0 -1
  152. data/spec/fixtures/payloads/message.json +0 -25
  153. data/spec/fixtures/payloads/sample.trace.json +0 -275
  154. data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
  155. data/spec/fixtures/plugins/dummy1.rb +0 -5
  156. data/spec/fixtures/plugins/dummy2.rb +0 -5
  157. data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
  158. data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
  159. data/spec/requests/home_spec.rb +0 -49
  160. data/spec/rollbar/configuration_spec.rb +0 -46
  161. data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
  162. data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
  163. data/spec/rollbar/delay/resque_spec.rb +0 -37
  164. data/spec/rollbar/delay/thread_spec.rb +0 -27
  165. data/spec/rollbar/encoding/encoder_spec.rb +0 -63
  166. data/spec/rollbar/item/backtrace_spec.rb +0 -26
  167. data/spec/rollbar/item/frame_spec.rb +0 -267
  168. data/spec/rollbar/item_spec.rb +0 -736
  169. data/spec/rollbar/json/oj_spec.rb +0 -18
  170. data/spec/rollbar/json_spec.rb +0 -110
  171. data/spec/rollbar/lazy_store_spec.rb +0 -99
  172. data/spec/rollbar/logger_proxy_spec.rb +0 -50
  173. data/spec/rollbar/logger_spec.rb +0 -124
  174. data/spec/rollbar/middleware/js_spec.rb +0 -421
  175. data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
  176. data/spec/rollbar/notifier_spec.rb +0 -56
  177. data/spec/rollbar/plugin_spec.rb +0 -209
  178. data/spec/rollbar/plugins/active_job_spec.rb +0 -38
  179. data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
  180. data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
  181. data/spec/rollbar/plugins/rack_spec.rb +0 -152
  182. data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
  183. data/spec/rollbar/plugins/rake_spec.rb +0 -34
  184. data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
  185. data/spec/rollbar/plugins/sidekiq_spec.rb +0 -171
  186. data/spec/rollbar/plugins/validations_spec.rb +0 -56
  187. data/spec/rollbar/plugins_spec.rb +0 -68
  188. data/spec/rollbar/request_data_extractor_spec.rb +0 -270
  189. data/spec/rollbar/scrubbers/params_spec.rb +0 -314
  190. data/spec/rollbar/scrubbers/url_spec.rb +0 -136
  191. data/spec/rollbar/scrubbers_spec.rb +0 -31
  192. data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
  193. data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
  194. data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
  195. data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
  196. data/spec/rollbar/truncation_spec.rb +0 -27
  197. data/spec/rollbar/util/hash_spec.rb +0 -22
  198. data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
  199. data/spec/rollbar/util_spec.rb +0 -80
  200. data/spec/rollbar_bc_spec.rb +0 -380
  201. data/spec/rollbar_spec.rb +0 -1667
  202. data/spec/spec_helper.rb +0 -84
  203. data/spec/support/cause_exception.rb +0 -1
  204. data/spec/support/encoding_helpers.rb +0 -8
  205. data/spec/support/encodings/iso_8859_9 +0 -1
  206. data/spec/support/fixture_helpers.rb +0 -10
  207. data/spec/support/get_ip_raising.rb +0 -7
  208. data/spec/support/helpers.rb +0 -5
  209. data/spec/support/matchers.rb +0 -23
  210. data/spec/support/notifier_helpers.rb +0 -57
  211. data/spec/support/rollbar_api.rb +0 -57
  212. data/spec/support/shared_contexts.rb +0 -12
@@ -2,22 +2,23 @@ require 'rubygems/version'
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
6
+ # new process is created during tests. (Testing rake tasks, for example.)
7
+ # This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
8
+ # We use the ||= assignment because Travis loads the gemfile twice, the second time
9
+ # with the wrong gemfile path.
10
+ ENV['CURRENT_GEMFILE'] ||= __FILE__
11
+
5
12
  is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
6
13
  is_not_jruby = !is_jruby
7
14
 
8
15
  gem 'appraisal'
9
16
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
10
17
  gem 'jruby-openssl', :platform => :jruby
11
- gem 'rails', '4.2.7.1'
18
+ gem 'rails', '4.2.8'
12
19
  gem 'rake'
13
20
  gem 'rspec-rails', '~> 3.4'
14
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
15
-
16
- if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
17
- gem 'sidekiq', '>= 2.13.0', '< 5.0'
18
- else
19
- gem 'sidekiq', '>= 2.13.0'
20
- end
21
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
21
22
 
22
23
  platforms :rbx do
23
24
  gem 'minitest'
@@ -26,17 +27,25 @@ platforms :rbx do
26
27
  gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
27
28
  end
28
29
 
29
- if RUBY_VERSION.start_with?('2.4') && is_not_jruby
30
- gem 'oj', '~> 2.16.0'
31
- elsif is_not_jruby
32
- gem 'oj', '~> 2.12.14'
30
+ if RUBY_VERSION < '2.2.2'
31
+ gem 'sidekiq', '~> 2.13.0'
32
+ else
33
+ gem 'sidekiq', '>= 2.13.0'
34
+ end
35
+
36
+ if RUBY_VERSION.start_with?('1.9')
37
+ gem 'capistrano', '<= 3.4.1', :require => false
38
+ gem 'shoryuken', '>= 4.0.0', '<= 4.0.2'
39
+ elsif RUBY_VERSION.start_with?('2')
40
+ gem 'capistrano', :require => false
41
+ gem 'shoryuken'
33
42
  end
34
43
 
35
- gem 'codeclimate-test-reporter', :group => :test, :require => nil
36
44
  gem 'database_cleaner', '~> 1.0.0'
37
45
  gem 'delayed_job', :require => false
38
46
  gem 'generator_spec'
39
47
  gem 'girl_friday', '>= 0.11.1'
48
+ gem 'rspec-command'
40
49
  gem 'redis'
41
50
  gem 'resque'
42
51
  gem 'sinatra'
@@ -51,9 +60,10 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
51
60
  else
52
61
  gem 'sucker_punch', '~> 2.0'
53
62
  gem 'webmock', :require => false
63
+ gem 'codacy-coverage'
64
+ gem 'simplecov'
54
65
  end
55
66
 
56
67
  gem 'aws-sdk-sqs'
57
- gem 'shoryuken'
58
68
 
59
69
  gemspec :path => '../'
@@ -2,13 +2,20 @@ require 'rubygems/version'
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
6
+ # new process is created during tests. (Testing rake tasks, for example.)
7
+ # This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
8
+ # We use the ||= assignment because Travis loads the gemfile twice, the second time
9
+ # with the wrong gemfile path.
10
+ ENV['CURRENT_GEMFILE'] ||= __FILE__
11
+
5
12
  is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
6
13
 
7
14
  gem 'appraisal'
8
15
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
9
16
  gem 'jruby-openssl', :platform => :jruby
10
- gem 'rails', '~> 5.0.0'
11
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
17
+ gem 'rails', '~> 5.0.7'
18
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
12
19
 
13
20
  gem 'rspec-core', '~> 3.5.0.beta3'
14
21
  gem 'rspec-rails', '~> 3.5.0.beta3'
@@ -18,12 +25,7 @@ gem 'rspec-mocks', '~> 3.5.0.beta3'
18
25
 
19
26
  gem 'rake'
20
27
 
21
- gem 'oj', '~> 2.12.14' unless is_jruby
22
- if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
23
- gem 'sidekiq', '>= 2.13.0', '< 5.0'
24
- else
25
- gem 'sidekiq', '>= 2.13.0'
26
- end
28
+ gem 'sidekiq', '>= 2.13.0'
27
29
 
28
30
  platforms :rbx do
29
31
  gem 'minitest'
@@ -33,22 +35,29 @@ platforms :rbx do
33
35
  end
34
36
 
35
37
  if RUBY_VERSION.start_with?('1.9')
38
+ gem 'capistrano', '<= 3.4.1', :require => false
36
39
  gem 'sucker_punch', '~> 1.0'
37
40
  elsif RUBY_VERSION.start_with?('2')
41
+ gem 'capistrano', :require => false
38
42
  gem 'sucker_punch', '~> 2.0'
43
+ gem 'codacy-coverage'
44
+ gem 'simplecov'
39
45
  end
40
46
 
41
47
  # We need last sinatra that uses rack 2.x
42
48
  gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
43
-
44
- gem 'codeclimate-test-reporter', :group => :test, :require => nil
45
- gem 'database_cleaner', '~> 1.x'
49
+ gem 'database_cleaner'
46
50
  gem 'delayed_job', :require => false
47
51
  gem 'generator_spec'
48
52
  gem 'girl_friday', '>= 0.11.1'
49
53
  gem 'redis'
50
54
  gem 'resque'
51
55
 
56
+ unless is_jruby
57
+ # JRuby doesn't support fork, which is required for this test helper.
58
+ gem 'rspec-command'
59
+ end
60
+
52
61
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
53
62
  gem 'mime-types', '< 3.0'
54
63
  end
@@ -2,13 +2,20 @@ require 'rubygems/version'
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
6
+ # new process is created during tests. (Testing rake tasks, for example.)
7
+ # This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
8
+ # We use the ||= assignment because Travis loads the gemfile twice, the second time
9
+ # with the wrong gemfile path.
10
+ ENV['CURRENT_GEMFILE'] ||= __FILE__
11
+
5
12
  is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
6
13
 
7
14
  gem 'appraisal'
8
15
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
9
16
  gem 'jruby-openssl', :platform => :jruby
10
- gem 'rails', '~> 5.1.0'
11
- gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
17
+ gem 'rails', '~> 5.1.7'
18
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
12
19
 
13
20
  gem 'rspec-core', '~> 3.5.0.beta3'
14
21
  gem 'rspec-rails', '~> 3.5.0.beta3'
@@ -18,12 +25,7 @@ gem 'rspec-mocks', '~> 3.5.0.beta3'
18
25
 
19
26
  gem 'rake'
20
27
 
21
- gem 'oj', '~> 2.16.1' unless is_jruby
22
- if RUBY_VERSION > '1.8.7' && RUBY_VERSION < '2.2.2'
23
- gem 'sidekiq', '>= 2.13.0', '< 5.0'
24
- else
25
- gem 'sidekiq', '>= 2.13.0'
26
- end
28
+ gem 'sidekiq', '>= 2.13.0'
27
29
 
28
30
  platforms :rbx do
29
31
  gem 'minitest'
@@ -33,22 +35,30 @@ platforms :rbx do
33
35
  end
34
36
 
35
37
  if RUBY_VERSION.start_with?('1.9')
38
+ gem 'capistrano', '<= 3.4.1', :require => false
36
39
  gem 'sucker_punch', '~> 1.0'
37
40
  elsif RUBY_VERSION.start_with?('2')
41
+ gem 'capistrano', :require => false
38
42
  gem 'sucker_punch', '~> 2.0'
43
+ gem 'codacy-coverage'
44
+ gem 'simplecov'
39
45
  end
40
46
 
41
47
  # We need last sinatra that uses rack 2.x
42
48
  gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
43
49
 
44
- gem 'codeclimate-test-reporter', :group => :test, :require => nil
45
- gem 'database_cleaner', '~> 1.x'
50
+ gem 'database_cleaner'
46
51
  gem 'delayed_job', :require => false
47
52
  gem 'generator_spec'
48
53
  gem 'girl_friday', '>= 0.11.1'
49
54
  gem 'redis'
50
55
  gem 'resque'
51
56
 
57
+ unless is_jruby
58
+ # JRuby doesn't support fork, which is required for this test helper.
59
+ gem 'rspec-command'
60
+ end
61
+
52
62
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
53
63
  gem 'mime-types', '< 3.0'
54
64
  end
@@ -0,0 +1,65 @@
1
+ require 'rubygems/version'
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
6
+ # new process is created during tests. (Testing rake tasks, for example.)
7
+ # This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
8
+ # We use the ||= assignment because Travis loads the gemfile twice, the second time
9
+ # with the wrong gemfile path.
10
+ ENV['CURRENT_GEMFILE'] ||= __FILE__
11
+
12
+ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
13
+
14
+ gem 'appraisal'
15
+ gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
16
+ gem 'jruby-openssl', :platform => :jruby
17
+ gem 'rails', '~> 5.2.3'
18
+ gem 'sqlite3', '< 1.4.0', :platform => [:ruby, :mswin, :mingw]
19
+
20
+ gem 'rspec-core', '~> 3.8.0'
21
+ gem 'rspec-rails', '~> 3.8.0'
22
+ gem 'rspec-support', '~> 3.8.0'
23
+ gem 'rspec-expectations', '~> 3.8.0'
24
+ gem 'rspec-mocks', '~> 3.8.0'
25
+
26
+ gem 'rake'
27
+
28
+ gem 'sidekiq', '>= 2.13.0'
29
+
30
+ platforms :rbx do
31
+ gem 'minitest'
32
+ gem 'racc'
33
+ gem 'rubinius-developer_tools'
34
+ gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
35
+ end
36
+
37
+ gem 'sucker_punch', '~> 2.0'
38
+
39
+ # We need last sinatra that uses rack 2.x
40
+ gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
41
+
42
+ gem 'database_cleaner'
43
+ gem 'codacy-coverage'
44
+ gem 'delayed_job', :require => false
45
+ gem 'generator_spec'
46
+ gem 'girl_friday', '>= 0.11.1'
47
+ gem 'redis'
48
+ gem 'resque'
49
+ gem 'simplecov'
50
+
51
+ unless is_jruby
52
+ # JRuby doesn't support fork, which is required for this test helper.
53
+ gem 'rspec-command'
54
+ end
55
+
56
+ gem 'mime-types'
57
+
58
+ gem 'webmock', :require => false
59
+
60
+ gem 'aws-sdk-sqs'
61
+ gem 'shoryuken'
62
+
63
+ gem 'capistrano', :require => false
64
+
65
+ gemspec :path => '../'
@@ -0,0 +1,67 @@
1
+
2
+ require 'rubygems/version'
3
+
4
+ source 'https://rubygems.org'
5
+
6
+ # Used by spec/commands/rollbar_rails_runner_spec, and can be used whenever a
7
+ # new process is created during tests. (Testing rake tasks, for example.)
8
+ # This is a workaround for ENV['BUNDLE_GEMFILE'] not working as expected on Travis.
9
+ # We use the ||= assignment because Travis loads the gemfile twice, the second time
10
+ # with the wrong gemfile path.
11
+ ENV['CURRENT_GEMFILE'] ||= __FILE__
12
+
13
+ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
14
+
15
+ gem 'appraisal'
16
+ gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
17
+ gem 'jruby-openssl', :platform => :jruby
18
+ gem 'rails', '6.0.0.rc1'
19
+ gem 'sqlite3', '~> 1.4', :platform => [:ruby, :mswin, :mingw]
20
+
21
+ gem 'rspec-core', '~> 3.8.0'
22
+ gem 'rspec-support', '~> 3.8.0'
23
+ gem 'rspec-expectations', '~> 3.8.0'
24
+ gem 'rspec-mocks', '~> 3.8.0'
25
+ # TODO: update this when 4.x becomes available on Rubygems
26
+ gem 'rspec-rails', :git => 'https://github.com/rspec/rspec-rails', :ref => 'v4.0.0.beta2' # rubocop:disable Bundler/DuplicatedGem
27
+
28
+ gem 'rake'
29
+
30
+ gem 'sidekiq', '>= 2.13.0'
31
+
32
+ platforms :rbx do
33
+ gem 'minitest'
34
+ gem 'racc'
35
+ gem 'rubinius-developer_tools'
36
+ gem 'rubysl', '~> 2.0' unless RUBY_VERSION.start_with?('1')
37
+ end
38
+
39
+ gem 'sucker_punch', '~> 2.0'
40
+
41
+ # We need last sinatra that uses rack 2.x
42
+ gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
43
+
44
+ gem 'database_cleaner'
45
+ gem 'codacy-coverage'
46
+ gem 'delayed_job', '4.1.8.beta1', :require => false
47
+ gem 'generator_spec'
48
+ gem 'girl_friday', '>= 0.11.1'
49
+ gem 'redis'
50
+ gem 'resque'
51
+ gem 'simplecov'
52
+
53
+ unless is_jruby
54
+ # JRuby doesn't support fork, which is required for this test helper.
55
+ gem 'rspec-command'
56
+ end
57
+
58
+ gem 'mime-types'
59
+
60
+ gem 'webmock', :require => false
61
+
62
+ gem 'aws-sdk-sqs'
63
+ gem 'shoryuken'
64
+
65
+ gem 'capistrano', :require => false
66
+
67
+ gemspec :path => '../'
@@ -52,7 +52,7 @@ module Rollbar
52
52
  end
53
53
 
54
54
  def access_token_configured?
55
- File.exists?('config/initializers/rollbar.rb')
55
+ File.exist?('config/initializers/rollbar.rb')
56
56
  end
57
57
  end
58
58
  end
@@ -1,7 +1,10 @@
1
1
  require 'rails'
2
2
  require 'rollbar'
3
3
 
4
- APP_PATH = File.expand_path('config/application', Dir.pwd)
4
+ # Rails.root is not present here.
5
+ # RSpec needs ENV['DUMMYAPP_PATH'] in order to have a valid path.
6
+ # Dir.pwd is used in normal operation.
7
+ APP_PATH = File.expand_path('config/application', (ENV['DUMMYAPP_PATH'] || Dir.pwd))
5
8
 
6
9
  module Rails
7
10
  class RollbarRunner
@@ -36,6 +39,14 @@ module Rails
36
39
  end
37
40
 
38
41
  def eval_runner
42
+ if Rails.version >= '5.1.0'
43
+ rails5_runner
44
+ else
45
+ legacy_runner
46
+ end
47
+ end
48
+
49
+ def legacy_runner
39
50
  string_to_eval = File.read(runner_path)
40
51
 
41
52
  ::Rails.module_eval(<<-EOL, __FILE__, __LINE__ + 2)
@@ -43,9 +54,13 @@ module Rails
43
54
  EOL
44
55
  end
45
56
 
57
+ def rails5_runner
58
+ Rails::Command.invoke 'runner', ARGV
59
+ end
60
+
46
61
  def rollbar_managed
47
62
  yield
48
- rescue => e
63
+ rescue StandardError => e
49
64
  Rollbar.scope(:custom => { :command => command }).error(e)
50
65
  raise
51
66
  end
data/lib/rollbar.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'net/protocol'
2
2
  require 'net/https'
3
3
  require 'socket'
4
- require 'thread'
5
4
  require 'uri'
6
5
  require 'open-uri'
7
6
  require 'forwardable'
@@ -22,10 +21,10 @@ require 'rollbar/notifier'
22
21
  # The Rollbar module. It stores a Rollbar::Notifier per thread and
23
22
  # provides some module methods in order to use the current thread notifier.
24
23
  module Rollbar
25
- PUBLIC_NOTIFIER_METHODS = %w(debug info warn warning error critical log logger
24
+ PUBLIC_NOTIFIER_METHODS = %w[debug info warn warning error critical log logger
26
25
  process_item process_from_async_handler scope
27
26
  send_failsafe log_info log_debug log_warning
28
- log_error silenced scope_object).freeze
27
+ log_error silenced scope_object].freeze
29
28
 
30
29
  class << self
31
30
  extend Forwardable
@@ -1,43 +1,77 @@
1
+ # This is a tasks file to use with Capistrano 2
2
+
1
3
  require 'capistrano'
4
+ require 'rollbar/deploy'
5
+ require 'net/http'
6
+ require 'rubygems'
7
+ require 'json'
8
+ require 'rollbar/capistrano_tasks'
2
9
 
3
10
  module Rollbar
4
- module Capistrano
5
- def self.load_into(configuration)
6
- configuration.load do
7
- after 'deploy', 'rollbar:deploy'
8
- after 'deploy:migrations', 'rollbar:deploy'
9
- after 'deploy:cold', 'rollbar:deploy'
10
-
11
- namespace :rollbar do
12
- desc 'Send the deployment notification to Rollbar.'
13
- task :deploy, :except => { :no_release => true } do
14
- require 'net/http'
15
- require 'rubygems'
16
- require 'json'
17
-
18
- _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
19
- _cset(:rollbar_env) { fetch(:rails_env, 'production') }
20
- _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
21
-
22
- unless configuration.dry_run
23
- uri = URI.parse('https://api.rollbar.com/api/1/deploy/')
24
-
25
- params = {
26
- :local_username => rollbar_user,
27
- :access_token => rollbar_token,
28
- :environment => rollbar_env,
29
- :revision => current_revision
30
- }
31
-
32
- request = Net::HTTP::Post.new(uri.request_uri)
33
- request.body = ::JSON.dump(params)
34
-
35
- Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
36
- http.request(request)
37
- end
38
- end
11
+ # Module for loading Rollbar Capistrano tasks into Capistrano 2
12
+ module Capistrano2
13
+ class << self
14
+ def load_into(configuration)
15
+ load_tasks(configuration)
16
+ load_tasks_flow(configuration)
17
+ load_properties(configuration)
18
+ end
19
+
20
+ private
21
+
22
+ def load_tasks_flow(configuration)
23
+ configuration.load do
24
+ before 'deploy', 'rollbar:deploy_started'
25
+
26
+ after 'deploy', 'rollbar:deploy_succeeded'
27
+ after 'deploy:migrations', 'rollbar:deploy_succeeded'
28
+ after 'deploy:cold', 'rollbar:deploy_succeeded'
29
+ end
30
+ end
31
+
32
+ def load_properties(configuration)
33
+ configuration.load do
34
+ _cset(:rollbar_role) { :app }
35
+ _cset(:rollbar_user) { ENV['USER'] || ENV['USERNAME'] }
36
+ _cset(:rollbar_env) { fetch(:rails_env, 'production') }
37
+ _cset(:rollbar_token) { abort("Please specify the Rollbar access token, set :rollbar_token, 'your token'") }
38
+ _cset(:rollbar_revision) { current_revision }
39
+ _cset(:rollbar_comment) { nil }
40
+ end
41
+ end
39
42
 
40
- logger.info('Rollbar notification complete')
43
+ def load_tasks(configuration)
44
+ load_deploy_started(configuration)
45
+ load_deploy_succeeded(configuration)
46
+ end
47
+
48
+ def load_deploy_started(configuration)
49
+ load_task(
50
+ :desc => 'Send deployment started notification to Rollbar.',
51
+ :task => :deploy_started,
52
+ :configuration => configuration
53
+ ) do
54
+ ::Rollbar::CapistranoTasks.deploy_started(configuration, configuration.logger, configuration.dry_run)
55
+ end
56
+ end
57
+
58
+ def load_deploy_succeeded(configuration)
59
+ load_task(
60
+ :desc => 'Send deployment succeeded notification to Rollbar.',
61
+ :task => :deploy_succeeded,
62
+ :configuration => configuration
63
+ ) do
64
+ ::Rollbar::CapistranoTasks.deploy_succeeded(configuration, configuration.logger, configuration.dry_run)
65
+ end
66
+ end
67
+
68
+ def load_task(configuration:, desc:, task:)
69
+ configuration.load do
70
+ namespace :rollbar do
71
+ desc(desc)
72
+ task(task) do
73
+ yield
74
+ end
41
75
  end
42
76
  end
43
77
  end
@@ -45,6 +79,4 @@ module Rollbar
45
79
  end
46
80
  end
47
81
 
48
- if Capistrano::Configuration.instance
49
- Rollbar::Capistrano.load_into(Capistrano::Configuration.instance)
50
- end
82
+ Rollbar::Capistrano2.load_into(Capistrano::Configuration.instance) if Capistrano::Configuration.instance