capistrano-graphite 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 512c233bfce7e7036369cb49ecb2d46213bd649f
4
- data.tar.gz: 6c3f94242c0c73749664c5b0eee45e0488a01d17
3
+ metadata.gz: e48e072f4581052d43f423aff3686390a62f5774
4
+ data.tar.gz: b6410e0f760ea3dc98964fdab0c1ba8aa9c864ec
5
5
  SHA512:
6
- metadata.gz: c38dfb78e037082feabc4b35e81d2885b9eabf6f6f858527f4d1dbf3c3f7e5ad5f3dd2ad65a9c834d247843dcbbd8a7aa83cb2c174f90ddfc437c5d86f6a6168
7
- data.tar.gz: 9c82781ebabcdf39ef5807ba2cf634a94dff97984009fb4874c3f964aac1bd5616bcb211aca24065abf72b246486f55eccb0b4b37e1bd60d988f47e945836138
6
+ metadata.gz: a1c2b44eb0bbeca70d4d99a1e1c839a9123c5c62c6d29434ba098b80268fa2e7278155fe41e4e754bde2eb3749b5b04287d21d4f5bcd86027e1684faed673d86
7
+ data.tar.gz: 7957822f6df17e1f3ff350c0a21eb5328bc3453ee7708a569a030fb55e8b7c379f7604ab03368b6ff1ad41a9cc4fe2a598283d1c309faf867b445d6c005bee2f
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Capistrano::Graphite
2
2
  [![Gem Version](http://img.shields.io/gem/v/capistrano-graphite.svg)][gem]
3
- [![Dependency Status](http://img.shields.io/gemnasium/scottsuch/capistrano-graphite.svg)][gemnasium]
4
3
  [![Build Status](http://img.shields.io/travis/scottsuch/capistrano-graphite.svg)][travis]
4
+ [![Dependency Status](http://img.shields.io/gemnasium/scottsuch/capistrano-graphite.svg)][gemnasium]
5
5
  [![Code Climate](http://img.shields.io/codeclimate/github/scottsuch/capistrano-graphite.svg)][codeclimate]
6
6
 
7
7
  [gem]: https://rubygems.org/gems/capistrano-graphite
8
- [gemnasium]: https://gemnasium.com/scottsuch/capistrano-graphite
9
8
  [travis]: http://travis-ci.org/scottsuch/capistrano-graphite
9
+ [gemnasium]: https://gemnasium.com/scottsuch/capistrano-graphite
10
10
  [codeclimate]: https://codeclimate.com/github/scottsuch/capistrano-graphite
11
11
  This gem works with Capistrano v3.1.0 and above and was based off the work on [this gem](https://github.com/hellvinz/graphite-notify) which works with Capistrano v2.x.
12
12
 
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_dependency "capistrano", "~> 3.0"
27
+ spec.add_development_dependency "bundler", "~> 1.3"
27
28
  spec.add_development_dependency "rake"
28
29
  spec.add_development_dependency "rspec"
29
30
  end
@@ -1,24 +1,25 @@
1
1
  require 'capistrano'
2
2
  require 'net/http'
3
3
  require 'uri'
4
+ require 'sshkit'
5
+ require 'sshkit/dsl'
4
6
 
5
7
  set :local_user, ENV['USER']
6
8
 
7
9
  class GraphiteInterface
8
- def self.events_enabled
10
+ def self.events_enabled(action)
9
11
  if fetch(:graphite_enable_events).to_i == 1
12
+ # We only post an event if graphite_enable_events was set to 1
13
+ GraphiteInterface.new.post_event(action)
10
14
  return 1
11
15
  elsif fetch(:graphite_enable_events).to_i == 0
12
- puts "Not sending an event: graphite_enable_events was set to 0."
13
16
  return 0
14
17
  else
15
- warn "Not sending an event: graphite_enable_events was assigned an "\
16
- "invalid value."
17
- return 0
18
+ return -1
18
19
  end
19
20
  end
20
21
 
21
- def self.post_event(action)
22
+ def post_event(action)
22
23
  uri = URI::parse("#{fetch(:graphite_url)}")
23
24
  req = Net::HTTP::Post.new(uri.path)
24
25
  req.basic_auth(uri.user, uri.password) if uri.user
@@ -30,21 +31,32 @@ class GraphiteInterface
30
31
  end
31
32
  end
32
33
 
33
-
34
34
  namespace :deploy do
35
35
  desc 'notify graphite that a deployment occured'
36
36
  task :graphite_deploy do
37
- if GraphiteInterface.events_enabled == 1
37
+ on roles(:all) do |host|
38
38
  action = "deploy"
39
- GraphiteInterface.post_event(action)
39
+ if GraphiteInterface.events_enabled(action) == 1
40
+ info("#{action.capitalize} event posted to graphite.")
41
+ elsif GraphiteInterface.events_enabled(action) == 0
42
+ info("No event posted: graphite_enable_events set to 0.")
43
+ else
44
+ warn("No event posted: graphite_enable_events set to invalid variable.")
45
+ end
40
46
  end
41
47
  end
42
48
 
43
49
  desc 'notify graphite that a rollback occured'
44
50
  task :graphite_rollback do
45
- if GraphiteIntervace.events_enabled == 1
46
- action = "rollback"
47
- GraphiteInterface.post_event(action)
51
+ on roles(:all) do |host|
52
+ action = "deploy"
53
+ if GraphiteInterface.events_enabled(action) == 1
54
+ info("#{action.capitalize} event posted to graphite.")
55
+ elsif GraphiteInterface.events_enabled(action) == 0
56
+ info("No event posted: graphite_enable_events set to 0.")
57
+ else
58
+ warn("No event posted: graphite_enable_events set to invalid variable.")
59
+ end
48
60
  end
49
61
  end
50
62
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Graphite
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - scottsuch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement