capistrano-graphite 1.0.0 → 1.0.1

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: 2c337353592f855999c6be4c8db8599556225dfb
4
- data.tar.gz: 9a654504efff0eb61d7a25fbe95280f76d6d0710
3
+ metadata.gz: 60c9b97e320cf08d4938903692509edd5461c6ff
4
+ data.tar.gz: 5e029a18828420df084a31025e61b7b873cc5791
5
5
  SHA512:
6
- metadata.gz: ca92e6af6cd0905bc516d4fa47c2604486187e7759ae10b72a0b5d82410deec18d0a4dcaa0835d6bf415ed7692870e4802cc0daeae63652ad43683b6822c8648
7
- data.tar.gz: 55162d1d21751b205ed8362f9265476b4d560f56e7d47203fd719ab9ddf767f8bceb78ce4139d6674dabc1ebfb4995c4650a47d075ade22ed59e2e723913008b
6
+ metadata.gz: 1a05c0951e1e3fe085c9c4799a2df0664164a77004d7fa6e4382a105337d90decc57ed25449ec746a8d9e17b90d437f6b37b49ba6a47aa7b3ce555db6c969a1b
7
+ data.tar.gz: bb2277b64bd8650b695686bd1ef3b81a8b93c5e60c7e44e43eead5564b241ff7e47c09410ecc69b1941970432afea2a926a06b9602bca868b4ddbbe58a927b37
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ # This is the configuration used to check the capistrano-graphite source code.
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+
5
+ Style/Encoding:
6
+ Enabled: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,14 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-11-18 14:45:57 -0500 using RuboCop version 0.27.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Metrics/AbcSize:
10
+ Max: 20
11
+
12
+ # Offense count: 2
13
+ Style/RegexpLiteral:
14
+ MaxSlashes: 0
data/.travis.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
- - 2.1.0
4
- - 2.0.0
5
4
  - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+
8
+ script:
9
+ - bundle exec rspec
10
+ - bundle exec rubocop
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ ## 1.0.1
2
+
3
+ BUG FIXES:
4
+
5
+ - Fix bug where multiple events were sent to graphite. [GH-18]
6
+
7
+ IMPROVEMENTS:
8
+
9
+ - Update test command example in README.md. [GH-19]
10
+ - Lint entire project with RuboCop. [GH-17]
11
+ - Add `rake` task to lint with RuboCop when Travis is run. [GH-17]
12
+
13
+ ## Previous Versions
14
+
15
+ Sorry, no true documentation was kept prior to 1.0.1.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in capistrano-graphite.gemspec
data/README.md CHANGED
@@ -1,16 +1,11 @@
1
1
  # Capistrano::Graphite
2
- [![Gem Version](http://img.shields.io/gem/v/capistrano-graphite.svg)][gem]
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
- [![Coverage Status](http://img.shields.io/coveralls/scottsuch/capistrano-graphite.svg)][coveralls]
6
- [![Code Climate](http://img.shields.io/codeclimate/github/scottsuch/capistrano-graphite.svg)][codeclimate]
7
-
8
- [gem]: https://rubygems.org/gems/capistrano-graphite
9
- [travis]: http://travis-ci.org/scottsuch/capistrano-graphite
10
- [gemnasium]: https://gemnasium.com/scottsuch/capistrano-graphite
11
- [coveralls]: https://coveralls.io/r/scottsuch/capistrano-graphite
12
- [codeclimate]: https://codeclimate.com/github/scottsuch/capistrano-graphite
13
- 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.
2
+ [![Gem Version](http://img.shields.io/gem/v/capistrano-graphite.svg)](https://rubygems.org/gems/capistrano-graphite)
3
+ [![Build Status](http://img.shields.io/travis/scottsuch/capistrano-graphite.svg)](http://travis-ci.org/scottsuch/capistrano-graphite)
4
+ [![Dependency Status](http://img.shields.io/gemnasium/scottsuch/capistrano-graphite.svg)](https://gemnasium.com/scottsuch/capistrano-graphite)
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/scottsuch/capistrano-graphite.svg)](https://codeclimate.com/github/scottsuch/capistrano-graphite)
6
+ [![Coverage Status](https://img.shields.io/coveralls/scottsuch/capistrano-graphite.svg)](https://coveralls.io/r/scottsuch/capistrano-graphite?branch=master)
7
+
8
+ This gem works with Capistrano v3.0.0 and above and was based off the work on [this gem](https://github.com/hellvinz/graphite-notify) which works with Capistrano v2.x.
14
9
 
15
10
  Adding this gem to [Capistrano](https://github.com/capistrano/capistrano) extends functionality by pushing events to graphite upon deployment and rollback.
16
11
  Currently events are only pushed after `deploy:updated` and `deploy:reverted`.
@@ -39,7 +34,7 @@ Add the following line to your `Capfile`.
39
34
  ### Configurable options
40
35
  Path to your graphite instance. Port and user:password are optional.
41
36
 
42
- set: :graphite_url, "http://user:password@example.com:8000/events/"
37
+ set :graphite_url, "http://user:password@example.com:8000/events/"
43
38
 
44
39
  Disable sending events for a particular stage by setting the following to 0.
45
40
  Note that the config `graphite_enable_events` has been deprecated in favor of
@@ -51,7 +46,7 @@ the config `suppress_graphite_events` below
51
46
  ### Test that it's working
52
47
  You can run the following on it's own assuming you have configured the graphite url
53
48
 
54
- $ bundle exec cap <stage> deploy:graphite_deploy
49
+ $ bundle exec cap <stage> deploy:post_graphite['deploy']
55
50
 
56
51
  ## Contributing
57
52
 
data/Rakefile CHANGED
@@ -1,5 +1,10 @@
1
- require "bundler/gem_tasks"
1
+ # encoding: utf-8
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
4
- task :default => :spec
7
+ task default: 'spec'
5
8
  RSpec::Core::RakeTask.new
9
+
10
+ RuboCop::RakeTask.new
@@ -4,34 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'capistrano/graphite/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "capistrano-graphite"
7
+ s.name = 'capistrano-graphite'
8
8
  s.version = Capistrano::Graphite::VERSION
9
- s.authors = ["scottsuch"]
10
- s.email = ["sgorsuch@gmail.com"]
11
- s.summary = %q{A gem for pushing graphite events via capistrano v3
12
- deployment}
13
- s.description = %q{This gem plugs into the deploy task in capistrano to
14
- help provide visibility into when deployments and
15
- rollbacks occured.}
16
- s.homepage = "https://github.com/scottsuch/capistrano-graphite"
17
- s.license = "MIT"
9
+ s.authors = ['scottsuch']
10
+ s.email = ['sgorsuch@gmail.com']
11
+ s.summary = 'A gem for pushing graphite events via capistrano v3 ' \
12
+ 'deployment'
13
+ s.description = 'This gem plugs into the deploy task in capistrano to ' \
14
+ 'help provide visibility into when deployments and ' \
15
+ 'rollbacks occured.'
16
+ s.homepage = 'https://github.com/scottsuch/capistrano-graphite'
17
+ s.license = 'MIT'
18
18
 
19
19
  s.required_ruby_version = '> 1.9'
20
20
 
21
- s.post_install_message = "The config `graphite_enable_events` has changed " \
22
- "to `suppress_graphite_events` and will accept " \
23
- "a true or false. See the README.md at" \
24
- "https://github.com/scottsuch/capistrano-graphite " \
25
- "for details.}"\
21
+ s.post_install_message = 'The config `graphite_enable_events` has changed ' \
22
+ 'to `suppress_graphite_events` and will accept ' \
23
+ 'a true or false. See the README.md at ' \
24
+ 'https://github.com/scottsuch/capistrano-graphite ' \
25
+ 'for details.'\
26
26
 
27
27
  s.files = `git ls-files -z`.split("\x0")
28
28
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
29
29
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
30
- s.require_paths = ["lib"]
30
+ s.require_paths = ['lib']
31
31
 
32
- s.add_dependency "capistrano", "~> 3.0"
33
- s.add_development_dependency "bundler", "~> 1.3"
34
- s.add_development_dependency "rake"
35
- s.add_development_dependency "rspec"
36
- s.add_development_dependency "coveralls"
32
+ s.add_dependency 'capistrano', '~> 3.0'
33
+ s.add_development_dependency 'bundler', '~> 1.3'
34
+ s.add_development_dependency 'coveralls'
35
+ s.add_development_dependency 'rake'
36
+ s.add_development_dependency 'rspec'
37
+ s.add_development_dependency 'rubocop'
38
+ s.add_development_dependency 'webmock'
37
39
  end
@@ -1,5 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  module Capistrano
4
+ # This module holds the capistrano-graphite version information.
2
5
  module Graphite
3
- VERSION = "1.0.0"
6
+ VERSION = '1.0.1'
4
7
  end
5
8
  end
@@ -1,15 +1,21 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'capistrano'
2
4
  require 'net/http'
3
5
  require 'uri'
4
6
  require 'sshkit'
5
7
  require 'sshkit/dsl'
6
8
 
9
+ # Build the request to post
7
10
  class GraphiteInterface
8
11
  def post_event(action)
9
- uri = URI::parse("#{fetch(:graphite_url)}")
12
+ uri = URI.parse("#{fetch(:graphite_url)}")
10
13
  req = Net::HTTP::Post.new(uri.path)
11
14
  req.basic_auth(uri.user, uri.password) if uri.user
12
- req.body = "{\"what\": \"#{action} #{fetch(:application)} in #{fetch(:stage)}\", \"tags\": \"#{fetch(:application)},#{fetch(:stage)},#{release_timestamp},#{action}\", \"data\": \"#{fetch(:local_user)}\"}"
15
+ req.body = "{\"what\": \"#{action} #{fetch(:application)} in " \
16
+ "#{fetch(:stage)}\", \"tags\": \"#{fetch(:application)}," \
17
+ "#{fetch(:stage)},#{release_timestamp},#{action}\", \"data\": " \
18
+ "\"#{fetch(:local_user)}\"}"
13
19
 
14
20
  Net::HTTP.start(uri.host, uri.port) do |http|
15
21
  http.request(req)
@@ -19,16 +25,16 @@ end
19
25
 
20
26
  namespace :deploy do
21
27
  desc 'Post an event to graphite'
22
- task :post_graphite, :action do |t, args|
28
+ task :post_graphite, :action do |args|
23
29
  action = args[:action]
24
- on roles(:all) do |host|
25
- if fetch(:suppress_graphite_events).downcase == "true"
30
+ run_locally do
31
+ if fetch(:suppress_graphite_events).downcase == 'true'
26
32
  GraphiteInterface.new.post_event("#{action}")
27
33
  info("#{action.capitalize} event posted to graphite.")
28
- elsif fetch(:suppress_graphite_events).downcase == "false"
29
- info("No event posted: `suppress_graphite_events` set to true.")
34
+ elsif fetch(:suppress_graphite_events).downcase == 'false'
35
+ info('No event posted: `suppress_graphite_events` set to true.')
30
36
  else
31
- warn("No event posted: `suppress_graphite_events` set incorrectly.")
37
+ warn('No event posted: `suppress_graphite_events` set incorrectly.')
32
38
  end
33
39
  end
34
40
  end
@@ -44,7 +50,7 @@ end
44
50
 
45
51
  namespace :load do
46
52
  task :defaults do
47
- set :suppress_graphite_events, "false"
53
+ set :suppress_graphite_events, 'false'
48
54
  set :local_user, ENV['USER']
49
55
  end
50
56
  end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ # graphite_spec.rb
4
+ require 'spec_helper'
5
+ require 'capistrano/graphite.rb'
6
+
7
+ RSpec.describe GraphiteInterface do
8
+ describe '#post_event' do
9
+ context 'deploy' do
10
+ it 'posts a deploy event to graphite' do
11
+ stub_request(:post, 'http://localhost/')
12
+ .with(body: "{\'what\': \'deploy testapp\', \'tags\': " \
13
+ "\'testapp,randomsha,deploy\', \'data\': \'testuser\'}")
14
+ .to_return(status: '200', body: '', headers: {})
15
+ end
16
+ end
17
+ context 'rollback' do
18
+ it 'posts a rollback event to graphite' do
19
+ stub_request(:post, 'http://localhost/')
20
+ .with(body: "{\'what\': \'rollback testapp\', \'tags\': " \
21
+ "\'testapp,randomsha,deploy\', \'data\': \'testuser\'}")
22
+ .to_return(status: '200', body: '', headers: {})
23
+ end
24
+ end
25
+ end
26
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rspec'
2
4
  require 'rake'
5
+ require 'webmock/rspec'
3
6
  require 'capistrano/all'
4
7
  require 'capistrano/framework'
5
8
  require 'capistrano/setup'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-15 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: coveralls
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -80,10 +108,8 @@ dependencies:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
- description: |-
84
- This gem plugs into the deploy task in capistrano to
85
- help provide visibility into when deployments and
86
- rollbacks occured.
111
+ description: This gem plugs into the deploy task in capistrano to help provide visibility
112
+ into when deployments and rollbacks occured.
87
113
  email:
88
114
  - sgorsuch@gmail.com
89
115
  executables: []
@@ -92,7 +118,10 @@ extra_rdoc_files: []
92
118
  files:
93
119
  - ".coveralls.yml"
94
120
  - ".gitignore"
121
+ - ".rubocop.yml"
122
+ - ".rubocop_todo.yml"
95
123
  - ".travis.yml"
124
+ - CHANGELOG.md
96
125
  - Gemfile
97
126
  - LICENSE.txt
98
127
  - README.md
@@ -100,14 +129,15 @@ files:
100
129
  - capistrano-graphite.gemspec
101
130
  - lib/capistrano/graphite.rb
102
131
  - lib/capistrano/graphite/version.rb
132
+ - spec/grapite_spec.rb
103
133
  - spec/spec_helper.rb
104
134
  homepage: https://github.com/scottsuch/capistrano-graphite
105
135
  licenses:
106
136
  - MIT
107
137
  metadata: {}
108
138
  post_install_message: The config `graphite_enable_events` has changed to `suppress_graphite_events`
109
- and will accept a true or false. See the README.md athttps://github.com/scottsuch/capistrano-graphite
110
- for details.}
139
+ and will accept a true or false. See the README.md at https://github.com/scottsuch/capistrano-graphite
140
+ for details.
111
141
  rdoc_options: []
112
142
  require_paths:
113
143
  - lib
@@ -123,10 +153,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
153
  version: '0'
124
154
  requirements: []
125
155
  rubyforge_project:
126
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.4.4
127
157
  signing_key:
128
158
  specification_version: 4
129
159
  summary: A gem for pushing graphite events via capistrano v3 deployment
130
160
  test_files:
161
+ - spec/grapite_spec.rb
131
162
  - spec/spec_helper.rb
132
- has_rdoc: