Skip to content

Commit

Permalink
[tailor] Adjustment code style (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
n0ts authored and degemer committed Aug 19, 2016
1 parent c8c7ec5 commit 04bfed0
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 90 deletions.
24 changes: 12 additions & 12 deletions lib/capistrano/datadog.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "etc"
require "digest/md5"
require "timeout"
require 'etc'
require 'digest/md5'
require 'timeout'

require "dogapi"
require 'dogapi'

module Capistrano
module Datadog
Expand Down Expand Up @@ -30,10 +30,10 @@ def self.submit(api_key)
dog.emit_event event
end
else
puts "No api key set, not submitting to Datadog"
puts 'No api key set, not submitting to Datadog'
end
rescue Timeout::Error => e
puts "Could not submit to Datadog, request timed out."
puts 'Could not submit to Datadog, request timed out.'
rescue => e
puts "Could not submit to Datadog: #{e.inspect}\n#{e.backtrace.join("\n")}"
end
Expand Down Expand Up @@ -77,23 +77,23 @@ def report()
@tasks.map do |task|
name = task[:name]
roles = Array(task[:roles]).map(&:to_s).sort
tags = ["#capistrano"] + (roles.map { |t| '#role:' + t })
tags = ['#capistrano'] + (roles.map { |t| '#role:' + t })
if !task[:stage].nil? and !task[:stage].empty? then
tags << "#stage:#{task[:stage]}"
end
application = ''
if !task[:application].nil? and !task[:application].empty? then
application = ' for ' + task[:application]
end
title = "%s@%s ran %s%s on %s with capistrano in %.2f secs" % [user, hostname, name, application, roles.join(', '), task[:timing]]
type = "deploy"
alert_type = "success"
source_type = "capistrano"
title = '%s@%s ran %s%s on %s with capistrano in %.2f secs' % [user, hostname, name, application, roles.join(', '), task[:timing]]
type = 'deploy'
alert_type = 'success'
source_type = 'capistrano'
message_content = (@logging_output[name] || []).join('')
message = if !message_content.empty? then
# Strip out color control characters
message_content = sanitize_encoding(message_content).gsub(/\e\[(\d+)m/, '')
"@@@\n#{message_content}@@@" else "" end
"@@@\n#{message_content}@@@" else '' end

Dogapi::Event.new(message,
:msg_title => title,
Expand Down
10 changes: 5 additions & 5 deletions lib/capistrano/datadog/v2.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "benchmark"
require "delegate"
require 'benchmark'
require 'delegate'

# Capistrano v2

Expand All @@ -12,7 +12,7 @@ module Execution
# will be raised.
# Also, capture the time the task took to execute, and the logs it
# outputted for submission to Datadog
def find_and_execute_task(path, hooks = {})
def find_and_execute_task(path, hooks= {})
task = find_task(path) or raise NoSuchTaskError, "the task `#{path}' does not exist"
result = nil
reporter = Capistrano::Datadog.reporter
Expand Down Expand Up @@ -62,9 +62,9 @@ def puts(message)
logger.device = Datadog::LogCapture.new logger.device

# Trigger the Datadog submission once all the tasks have run
on :exit, "datadog:submit"
on :exit, 'datadog:submit'
namespace :datadog do
desc "Submit the tasks that have run to Datadog as events"
desc 'Submit the tasks that have run to Datadog as events'
task :submit do |ns|
Capistrano::Datadog.submit variables[:datadog_api_key]
end
Expand Down
6 changes: 3 additions & 3 deletions lib/capistrano/datadog/v3.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "benchmark"
require "sshkit/formatters/pretty"
require "sshkit/formatters/simple_text"
require 'benchmark'
require 'sshkit/formatters/pretty'
require 'sshkit/formatters/simple_text'

# Capistrano v3 uses Rake's DSL instead of its own

Expand Down
12 changes: 6 additions & 6 deletions lib/dogapi/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize(api_key, api_host=Dogapi.find_datadog_host)

# <b>DEPRECATED:</b> Going forward, use the newer APIService.
def connect
warn "[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services"
warn '[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services'
uri = URI.parse(@host)
session = Net::HTTP.new(uri.host, uri.port)
if 'https' == uri.scheme
Expand All @@ -41,7 +41,7 @@ def connect

# <b>DEPRECATED:</b> Going forward, use the newer APIService.
def request(method, url, params)
warn "[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services"
warn '[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services'
if !params.has_key? :api_key
params[:api_key] = @api_key
end
Expand Down Expand Up @@ -83,8 +83,8 @@ def connect
connection = Net::HTTP

# After ruby 2.0 Net::HTTP looks for the env variable but not ruby 1.9
if RUBY_VERSION < "2.0.0"
proxy = ENV["HTTPS_PROXY"] || ENV["https_proxy"] || ENV["HTTP_PROXY"] || ENV["http_proxy"]
if RUBY_VERSION < '2.0.0'
proxy = ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy']
if proxy
proxy_uri = URI.parse(proxy)
connection = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
Expand Down Expand Up @@ -166,7 +166,7 @@ def handle_response(resp)

def Dogapi.find_datadog_host
# allow env-based overriding, useful for tests
ENV["DATADOG_HOST"] || "https://app.datadoghq.com"
ENV['DATADOG_HOST'] || 'https://app.datadoghq.com'
end

# Memoize the hostname as a module variable
Expand All @@ -177,7 +177,7 @@ def Dogapi.find_localhost
# prefer hostname -f over Socket.gethostname
@@hostname ||= %x[hostname -f].strip
rescue
raise "Cannot determine local hostname via hostname -f"
raise 'Cannot determine local hostname via hostname -f'
end
end
end
8 changes: 4 additions & 4 deletions lib/dogapi/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Event
# :event_type => String
# :source_type_name => String
# :aggregation_key => String
def initialize(msg_text, options = {})
def initialize(msg_text, options= {})
defaults = {
:date_happened => Time.now.to_i,
:msg_title => '',
Expand Down Expand Up @@ -62,14 +62,14 @@ def to_hash
# removed in an upcoming release.
class EventService < Dogapi::Service

API_VERSION = "1.0.0"
API_VERSION = '1.0.0'
MAX_BODY_LENGTH = 4000
MAX_TITLE_LENGTH = 100

# <b>DEPRECATED:</b> Going forward, use the V1 services. This legacy service will be
# removed in an upcoming release.
def submit(api_key, event, scope=nil, source_type=nil)
warn "[DEPRECATION] Dogapi::EventService.submit() has been deprecated in favor of the newer V1 services"
warn '[DEPRECATION] Dogapi::EventService.submit() has been deprecated in favor of the newer V1 services'
scope = scope || Dogapi::Scope.new()
params = {
:api_key => api_key,
Expand Down Expand Up @@ -99,7 +99,7 @@ def submit(api_key, event, scope=nil, source_type=nil)
# <b>DEPRECATED:</b> Going forward, use the V1 services. This legacy service will be
# removed in an upcoming release.
def start(api_key, event, scope, source_type=nil)
warn "[DEPRECATION] Dogapi::EventService.start() has been deprecated in favor of the newer V1 services"
warn '[DEPRECATION] Dogapi::EventService.start() has been deprecated in favor of the newer V1 services'
response = submit api_key, event, scope, source_type
success = nil

Expand Down
Loading

0 comments on commit 04bfed0

Please sign in to comment.