chef-notifier 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/LICENSE ADDED
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) + '/lib/'
2
+ require 'chef-notifier/version'
3
+ Gem::Specification.new do |s|
4
+ s.name = 'chef-notifier'
5
+ s.version = ChefNotifier::VERSION.to_s
6
+ s.summary = 'Notifications for Chef'
7
+ s.author = 'Chris Roberts'
8
+ s.email = 'chrisroberts.code@gmail.com'
9
+ s.homepage = 'http://bitbucket.org/chrisroberts/chef-notifier'
10
+ s.description = 'Notifications for Chef'
11
+ s.require_path = 'lib'
12
+ s.extra_rdoc_files = ['README.rdoc', 'CHANGELOG.rdoc']
13
+ s.add_dependency 'pony'
14
+ s.files = %w(LICENSE README.rdoc CHANGELOG.rdoc) + Dir.glob("**/*")
15
+ end
@@ -0,0 +1 @@
1
+ require 'chef-notifier/version'
@@ -0,0 +1,52 @@
1
+ require 'chef'
2
+ require 'chef/handler'
3
+ require 'singleton'
4
+ require 'pony'
5
+
6
+ module ChefNotifier
7
+ class Mailer < Chef::Handler
8
+
9
+ include Singleton
10
+
11
+ def setup(args={})
12
+ @args = {:delivery => {:method => :sendmail, :arguments => '-i'}}.merge(args)
13
+ @recipients = Array(@args[:recipients])
14
+ end
15
+
16
+ def report
17
+ message = "#{run_status.formatted_exception}\n"
18
+ message << Array(backtrace).join("\n")
19
+ send_mail(message)
20
+ end
21
+
22
+ def warn(msg)
23
+ send_mail(msg, "[Chef WARN #{Socket.gethostname}]")
24
+ end
25
+
26
+ def error(msg)
27
+ send_mail(msg)
28
+ end
29
+
30
+ def info(msg)
31
+ send_mail(msg, "[Chef INFO #{Socket.gethostname}]")
32
+ end
33
+
34
+ private
35
+
36
+ def send_mail(message, subject=nil)
37
+ deliver_to = @recipients
38
+ unless(Array(deliver_to).empty?)
39
+ Pony.mail(
40
+ :to => deliver_to,
41
+ :subject => subject || "[Chef ERROR #{Socket.gethostname}]",
42
+ :from => "chef-client@#{Socket.gethostname}",
43
+ :body => message,
44
+ :via_options => {
45
+ :arguments => @args[:delivery][:arguments]
46
+ }
47
+ )
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module ChefNotifier
2
+ class Version
3
+
4
+ attr_reader :major, :minor, :tiny
5
+
6
+ def initialize(version)
7
+ version = version.split('.')
8
+ @major, @minor, @tiny = [version[0].to_i, version[1].to_i, version[2].to_i]
9
+ end
10
+
11
+ def to_s
12
+ "#{@major}.#{@minor}.#{@tiny}"
13
+ end
14
+ end
15
+
16
+ VERSION = Version.new('1.0.0')
17
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-notifier
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Chris Roberts
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-28 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: pony
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Notifications for Chef
36
+ email: chrisroberts.code@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.rdoc
43
+ - CHANGELOG.rdoc
44
+ files:
45
+ - LICENSE
46
+ - README.rdoc
47
+ - CHANGELOG.rdoc
48
+ - chef-notifier.gemspec
49
+ - chef-notifier-1.0.0.gem
50
+ - lib/chef-notifier.rb
51
+ - lib/chef-notifier/mail.rb
52
+ - lib/chef-notifier/version.rb
53
+ has_rdoc: true
54
+ homepage: http://bitbucket.org/chrisroberts/chef-notifier
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.4.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Notifications for Chef
87
+ test_files: []
88
+