Class: Rails::RollbarRunner
- Inherits:
-
Object
- Object
- Rails::RollbarRunner
- Defined in:
- lib/rails/rollbar_runner.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
- #eval_runner ⇒ Object
-
#initialize ⇒ RollbarRunner
constructor
A new instance of RollbarRunner.
- #legacy_runner ⇒ Object
- #prepare_environment ⇒ Object
- #rails5_runner ⇒ Object
- #railties_gem ⇒ Object
- #railties_gem_dir ⇒ Object
- #rollbar_managed ⇒ Object
- #run ⇒ Object
- #runner_path ⇒ Object
Constructor Details
#initialize ⇒ RollbarRunner
Returns a new instance of RollbarRunner.
16 17 18 |
# File 'lib/rails/rollbar_runner.rb', line 16 def initialize @command = ARGV[0] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
14 15 16 |
# File 'lib/rails/rollbar_runner.rb', line 14 def command @command end |
Instance Method Details
#eval_runner ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rails/rollbar_runner.rb', line 31 def eval_runner if Gem::Version.new(Rails.version) >= Gem::Version.new('5.1.0') rails5_runner else legacy_runner end end |
#legacy_runner ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/rails/rollbar_runner.rb', line 39 def legacy_runner string_to_eval = File.read(runner_path) ::Rails.module_eval(<<-FILE, __FILE__, __LINE__ + 1) #{string_to_eval} FILE end |
#prepare_environment ⇒ Object
26 27 28 29 |
# File 'lib/rails/rollbar_runner.rb', line 26 def prepare_environment require File.('../environment', APP_PATH) ::Rails.application.require_environment! end |
#rails5_runner ⇒ Object
47 48 49 50 51 |
# File 'lib/rails/rollbar_runner.rb', line 47 def rails5_runner require 'rails/command' Rails::Command.invoke 'runner', ARGV end |
#railties_gem ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/rails/rollbar_runner.rb', line 64 def railties_gem gem = Gem::Specification.find_by_name('railties') abort 'railties gem not found' unless gem gem end |
#railties_gem_dir ⇒ Object
72 73 74 |
# File 'lib/rails/rollbar_runner.rb', line 72 def railties_gem_dir railties_gem.gem_dir end |
#rollbar_managed ⇒ Object
53 54 55 56 57 58 |
# File 'lib/rails/rollbar_runner.rb', line 53 def yield rescue StandardError => e Rollbar.scope(:custom => { :command => command }).error(e) raise end |
#run ⇒ Object
20 21 22 23 24 |
# File 'lib/rails/rollbar_runner.rb', line 20 def run prepare_environment { eval_runner } end |
#runner_path ⇒ Object
60 61 62 |
# File 'lib/rails/rollbar_runner.rb', line 60 def runner_path "#{railties_gem_dir}/lib/rails/commands/runner.rb" end |