Class: Rails::RollbarRunner
- Inherits:
-
Object
- Object
- Rails::RollbarRunner
show all
- Defined in:
- lib/rails/rollbar_runner.rb
Defined Under Namespace
Classes: GemResolver, LegacyGemResolver
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RollbarRunner.
23
24
25
|
# File 'lib/rails/rollbar_runner.rb', line 23
def initialize
@command = ARGV[0]
end
|
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
21
22
23
|
# File 'lib/rails/rollbar_runner.rb', line 21
def command
@command
end
|
Instance Method Details
#eval_runner ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/rails/rollbar_runner.rb', line 38
def eval_runner
string_to_eval = File.read(runner_path)
::Rails.module_eval(<<-EOL, __FILE__, __LINE__ + 2)
#{string_to_eval}
EOL
end
|
#prepare_environment ⇒ Object
33
34
35
36
|
# File 'lib/rails/rollbar_runner.rb', line 33
def prepare_environment
require File.expand_path('../environment', APP_PATH)
::Rails.application.require_environment!
end
|
#railties_gem ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/rails/rollbar_runner.rb', line 57
def railties_gem
resolver_class = Gem::Specification.respond_to?(:find_by_name) ? GemResolver : LegacyGemResolver
gem = resolver_class.new.railties_gem
abort 'railties gem not found' unless gem
gem
end
|
#railties_gem_dir ⇒ Object
66
67
68
|
# File 'lib/rails/rollbar_runner.rb', line 66
def railties_gem_dir
railties_gem.gem_dir
end
|
#rollbar_managed ⇒ Object
46
47
48
49
50
51
|
# File 'lib/rails/rollbar_runner.rb', line 46
def rollbar_managed
yield
rescue => e
Rollbar.scope(:custom => { :command => command }).error(e)
raise
end
|
#run ⇒ Object
27
28
29
30
31
|
# File 'lib/rails/rollbar_runner.rb', line 27
def run
prepare_environment
rollbar_managed { eval_runner }
end
|
#runner_path ⇒ Object
53
54
55
|
# File 'lib/rails/rollbar_runner.rb', line 53
def runner_path
railties_gem_dir + '/lib/rails/commands/runner.rb'
end
|