capistrano3-newrelic 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,52 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ .DS_Store
31
+
32
+ # For TextMate
33
+ *.tmproj
34
+ tmtags
35
+
36
+ # For emacs:
37
+ *~
38
+ \#*
39
+ .\#*
40
+
41
+ # For vim:
42
+ *.swp
43
+ *.swo
44
+
45
+ # For redcar:
46
+ .redcar
47
+
48
+ # For rubinius:
49
+ *.rbc
50
+
51
+
52
+ tmp
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p125
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color -fd
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-v3-newrelic (0.0.1)
5
+ activesupport
6
+ capistrano (~> 3.1.0)
7
+ capistrano-rails
8
+ capistrano-rbenv (~> 2.0)
9
+ newrelic_rpm (>= 3.7.0)
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ activesupport (4.1.0)
15
+ i18n (~> 0.6, >= 0.6.9)
16
+ json (~> 1.7, >= 1.7.7)
17
+ minitest (~> 5.1)
18
+ thread_safe (~> 0.1)
19
+ tzinfo (~> 1.1)
20
+ capistrano (3.1.0)
21
+ i18n
22
+ rake (>= 10.0.0)
23
+ sshkit (~> 1.3)
24
+ capistrano-bundler (1.1.2)
25
+ capistrano (~> 3.0)
26
+ sshkit (~> 1.2)
27
+ capistrano-rails (1.1.1)
28
+ capistrano (~> 3.1)
29
+ capistrano-bundler (~> 1.1)
30
+ capistrano-rbenv (2.0.2)
31
+ capistrano (~> 3.1)
32
+ sshkit (~> 1.3)
33
+ diff-lcs (1.2.5)
34
+ fakefs (0.5.2)
35
+ i18n (0.6.10)
36
+ json (1.8.1)
37
+ minitest (5.3.3)
38
+ net-scp (1.2.1)
39
+ net-ssh (>= 2.6.5)
40
+ net-ssh (2.9.1)
41
+ newrelic_rpm (3.7.3.204)
42
+ rake (10.2.1)
43
+ rspec (2.14.1)
44
+ rspec-core (~> 2.14.0)
45
+ rspec-expectations (~> 2.14.0)
46
+ rspec-mocks (~> 2.14.0)
47
+ rspec-core (2.14.8)
48
+ rspec-expectations (2.14.5)
49
+ diff-lcs (>= 1.1.3, < 2.0)
50
+ rspec-mocks (2.14.6)
51
+ sshkit (1.4.0)
52
+ net-scp (>= 1.1.2)
53
+ net-ssh (>= 2.8.0)
54
+ term-ansicolor
55
+ term-ansicolor (1.3.0)
56
+ tins (~> 1.0)
57
+ thread_safe (0.3.3)
58
+ tins (1.3.0)
59
+ tzinfo (1.1.0)
60
+ thread_safe (~> 0.1)
61
+ yard (0.8.7.4)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler
68
+ capistrano-v3-newrelic!
69
+ fakefs
70
+ rake
71
+ rspec
72
+ yard
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ capistrano3-newrelic
2
+ ======================
3
+
4
+ Capistrano3 task for New Relic notification about deployment
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'capistrano3-newrelic'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install cap-newrelic
21
+
22
+ ## Usage
23
+
24
+ Require the module in your `Capfile`:
25
+
26
+ ```ruby
27
+ require 'capistrano/newrelic'
28
+ ```
29
+
30
+ Gem comes with 1 task `notification:newrelic`.
31
+
32
+ By default the task will run after `deploy`
33
+
34
+
35
+ ### Configuration
36
+
37
+ Configurable options, set in `newrelic.yml` config.
38
+
39
+ ## Thanks
40
+
41
+ This code started out based on [https://github.com/newrelic/rpm](https://github.com/newrelic/rpm) (for Capistrano2)
42
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ Bundler.setup(:default, :development)
6
+ require 'rake'
7
+ require 'rspec/core/rake_task'
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.7
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "capistrano3-newrelic"
5
+ s.version = `cat VERSION`
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ivan Antropov"]
9
+ s.date = "2014-05-29"
10
+ s.description = "Capistrano v3 task for New Relic notification about deployment"
11
+ s.email = ["i.antropov@fun-box.ru"]
12
+ s.extra_rdoc_files = [ "README.md" ]
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.licenses = ["MIT"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = "1.6.2"
18
+ s.summary = "Sends New Relic deployment notifications"
19
+
20
+ s.add_dependency("capistrano", "~> 3.1.0")
21
+ s.add_dependency("capistrano-rails")
22
+ s.add_dependency("capistrano-rbenv", "~> 2.0")
23
+ s.add_dependency("newrelic_rpm", ">= 3.7.0")
24
+ s.add_dependency("activesupport")
25
+
26
+ s.add_development_dependency("bundler")
27
+ s.add_development_dependency("rake")
28
+ s.add_development_dependency("rspec")
29
+ s.add_development_dependency("yard")
30
+ s.add_development_dependency("fakefs")
31
+ end
@@ -0,0 +1,6 @@
1
+ require 'capistrano/setup'
2
+ require 'capistrano/deploy'
3
+ require 'capistrano/rbenv'
4
+ require 'capistrano/bundler'
5
+
6
+ load File.expand_path("../tasks/newrelic.rake", __FILE__)
@@ -0,0 +1,15 @@
1
+ require 'newrelic/notificator'
2
+
3
+ namespace :notification do
4
+
5
+ desc 'Send notification to New Relic'
6
+ task :newrelic do
7
+ env = fetch(:env, "production")
8
+ revision = `git rev-parse HEAD`[0..6]
9
+ notificator = NewRelic::Notificator.new(env, revision, local_user, 'config/newrelic.yml')
10
+ notificator.notify
11
+ end
12
+
13
+ after :deploy, 'notification:newrelic'
14
+
15
+ end
File without changes
@@ -0,0 +1,43 @@
1
+ require 'active_support/hash_with_indifferent_access'
2
+ require 'active_support/core_ext/hash'
3
+ require 'new_relic/cli/command.rb'
4
+ require 'yaml'
5
+
6
+ class NewRelic::Notificator
7
+ def initialize(stage, revision, user, newrelic_config_file)
8
+ @stage = stage
9
+ @revision = revision
10
+ @user = user
11
+ @newrelic_config_file = newrelic_config_file
12
+ end
13
+
14
+ def notify
15
+ new_relic_yml = YAML.load_file(@newrelic_config_file) rescue nil
16
+ unless new_relic_yml
17
+ puts "Can't open New Relic config file!"
18
+ return
19
+ end
20
+
21
+ config = HashWithIndifferentAccess.new(new_relic_yml)[@stage]
22
+
23
+ deploy_options = {
24
+ :revision => @revision,
25
+ :environment => @stage,
26
+ :user => @user,
27
+ :description => config[:description],
28
+ :license_key => config[:license_key],
29
+ :appname => config[:app_name]
30
+ }
31
+
32
+ puts "Uploading deployment to New Relic..."
33
+
34
+ deployment = NewRelic::Cli::Deployments.new deploy_options
35
+ deployment.run
36
+
37
+ puts "Uploaded deployment information to New Relic"
38
+
39
+ rescue => e
40
+ puts "Unable to notify New Relic of the deployment... skipping"
41
+ puts "Error creating New Relic deployment (#{e})\n#{e.message})\n#{e.backtrace.join("\n")}"
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe NewRelic::Notificator do
4
+
5
+ it "should load new relic settings and notify" do
6
+ NewRelic::ConfigFaker.with_config do |filename|
7
+ NewRelic::Cli::Deployments.any_instance.should_receive :run
8
+ described_class.new(:test, '123', 'user', filename).notify
9
+ end
10
+ end
11
+
12
+ it "shouldn't notify without config options" do
13
+ NewRelic::Cli::Deployments.any_instance.should_not_receive :run
14
+ described_class.new(:test, '123', 'user', 'filename').notify
15
+ end
16
+
17
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup(:default, :development, :test)
4
+
5
+ $: << File.join(File.dirname(__FILE__), '../lib/')
6
+
7
+ require 'newrelic/notificator'
8
+
9
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ end
@@ -0,0 +1,15 @@
1
+ require 'tempfile'
2
+ module NewRelic::ConfigFaker
3
+ def self.with_config
4
+ options = { :test => {} }
5
+ file = Tempfile.new('newrelic_config')
6
+ begin
7
+ file.write(options.to_yaml)
8
+ file.close
9
+ yield(file.path)
10
+ ensure
11
+ file.close
12
+ file.unlink
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano3-newrelic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ivan Antropov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &12825580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12825580
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano-rails
27
+ requirement: &12825200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *12825200
36
+ - !ruby/object:Gem::Dependency
37
+ name: capistrano-rbenv
38
+ requirement: &12824660 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *12824660
47
+ - !ruby/object:Gem::Dependency
48
+ name: newrelic_rpm
49
+ requirement: &12824160 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.7.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *12824160
58
+ - !ruby/object:Gem::Dependency
59
+ name: activesupport
60
+ requirement: &12823780 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *12823780
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: &12823320 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *12823320
80
+ - !ruby/object:Gem::Dependency
81
+ name: rake
82
+ requirement: &12852660 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *12852660
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &12852240 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *12852240
102
+ - !ruby/object:Gem::Dependency
103
+ name: yard
104
+ requirement: &12851820 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *12851820
113
+ - !ruby/object:Gem::Dependency
114
+ name: fakefs
115
+ requirement: &12851400 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *12851400
124
+ description: Capistrano v3 task for New Relic notification about deployment
125
+ email:
126
+ - i.antropov@fun-box.ru
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files:
130
+ - README.md
131
+ files:
132
+ - .gitignore
133
+ - .rbenv-version
134
+ - .rspec
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - README.md
138
+ - Rakefile
139
+ - VERSION
140
+ - capistrano3-newrelic.gemspec
141
+ - lib/capistrano/newrelic.rb
142
+ - lib/capistrano/tasks/newrelic.rake
143
+ - lib/capistrano3-newrelic.rb
144
+ - lib/newrelic/notificator.rb
145
+ - spec/lib/newrelic/notificator_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/newrelic/config_faker.rb
148
+ homepage:
149
+ licenses:
150
+ - MIT
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 1.8.11
170
+ signing_key:
171
+ specification_version: 3
172
+ summary: Sends New Relic deployment notifications
173
+ test_files: []
174
+ has_rdoc: