Class: ScoutApm::DeployIntegrations::Capistrano3
- Inherits:
-
Object
- Object
- ScoutApm::DeployIntegrations::Capistrano3
- Defined in:
- lib/scout_apm/deploy_integrations/capistrano_3.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #branch ⇒ Object
- #current_revision ⇒ Object
- #deploy_data ⇒ Object
- #deployed_by ⇒ Object
- #env ⇒ Object
- #found? ⇒ Boolean
-
#initialize(logger) ⇒ Capistrano3
constructor
A new instance of Capistrano3.
- #install ⇒ Object
- #name ⇒ Object
- #present? ⇒ Boolean
- #report ⇒ Object
- #reporter ⇒ Object
- #root ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(logger) ⇒ Capistrano3
Returns a new instance of Capistrano3.
8 9 10 11 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 8 def initialize(logger) @logger = logger @cap = Rake.application rescue nil end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 6 def logger @logger end |
Instance Method Details
#branch ⇒ Object
68 69 70 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 68 def branch @cap.fetch(:branch) end |
#current_revision ⇒ Object
72 73 74 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 72 def current_revision @cap.fetch(:current_revision) || `git rev-list --max-count=1 --abbrev-commit --abbrev=12 #{branch}`.chomp end |
#deploy_data ⇒ Object
64 65 66 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 64 def deploy_data {:revision => current_revision, :branch => branch, :deployed_by => deployed_by} end |
#deployed_by ⇒ Object
76 77 78 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 76 def deployed_by ScoutApm::Agent.instance.config.value('deployed_by') end |
#env ⇒ Object
41 42 43 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 41 def env @cap.fetch(:stage).to_s end |
#found? ⇒ Boolean
45 46 47 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 45 def found? true end |
#install ⇒ Object
32 33 34 35 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 32 def install logger.debug "Initializing Capistrano3 Deploy Integration." load File.("../capistrano_3.cap", __FILE__) end |
#name ⇒ Object
13 14 15 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 13 def name :capistrano_3 end |
#present? ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 21 def present? if !@cap.nil? && @cap.is_a?(Capistrano::Application) require 'capistrano/version' defined?(Capistrano::VERSION) && Gem::Dependency.new('', '~> 3.0').match?('', Capistrano::VERSION.to_s) else return false end rescue return false end |
#report ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 49 def report if reporter.can_report? data = deploy_data logger.debug "Sending deploy hook data: #{data}" payload = ScoutApm::Serializers::DeploySerializer.serialize(data) reporter.report(payload, ScoutApm::Serializers::DeploySerializer::HTTP_HEADERS) else logger.warn "Unable to post deploy hook data" end end |
#reporter ⇒ Object
60 61 62 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 60 def reporter @reporter ||= ScoutApm::Reporter.new(:deploy_hook, ScoutApm::Agent.instance.config, @logger) end |
#root ⇒ Object
37 38 39 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 37 def root '.' end |
#version ⇒ Object
17 18 19 |
# File 'lib/scout_apm/deploy_integrations/capistrano_3.rb', line 17 def version present? ? Capistrano::VERSION : nil end |