alerty-plugin-mail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e7268a5d09184316f313afd7bf86e7eb715bda4
4
+ data.tar.gz: a8afa3bc426cdf00a6a7b191e73b81073a796495
5
+ SHA512:
6
+ metadata.gz: 151db20cab2524a4a2fe12d51b9e6681ff5a4bb64119da8c074cafda6f90cbdfec23c5a50f8532bbf4e25abe0289fb6130d50cc2ed93c49332b2a4716e1a5d1b
7
+ data.tar.gz: edf6afe3d521f0573dc1f7956ca8241801ae24fc04649468141f937b50c586616eede0b8ff856d3caf716c3e250216bee743cefc3c20d3403b9d45677756a09d
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .ruby-version
11
+ *.bak
12
+ .tags
13
+ vendor
14
+ .idea
15
+ *.iml
@@ -0,0 +1,3 @@
1
+ # 0.0.1 (2015/11/25)
2
+
3
+ first version
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alerty-plugin-mail.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Civitaspo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # Alerty::Plugin::Mail
2
+
3
+ mail plugin for alerty
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'alerty-plugin-mail'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install alerty-plugin-mail
20
+
21
+ ## Configuration
22
+
23
+ - **type**: must be `mail`
24
+ - **send_from**: send a mail from (required)
25
+ - **send_to**: send a mail to (required)
26
+ - **delivery_method**: delivery method. see https://github.com/mikel/mail (optional, default: `sendmail`)
27
+ - **delivery_settings**: delivery settings. see https://github.com/mikel/mail (optional)
28
+ - **num_retries**: retry to send the mail if failed (optional, default: `3`)
29
+ - **subject**: mail subject (optional)
30
+
31
+ ## ChangeLog
32
+
33
+ See [CHANGELOG.md](./CHANGELOG.md)
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/civitaspo/alerty-plugin-mail. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
49
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'alerty/plugin/mail/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "alerty-plugin-mail"
8
+ spec.version = Alerty::Plugin::Mail::VERSION
9
+ spec.authors = ["Civitaspo"]
10
+ spec.email = ["civitaspo@gmail.com"]
11
+
12
+ spec.summary = %q{mail plugin for alerty}
13
+ spec.description = %q{mail plugin for alerty}
14
+ spec.homepage = "https://github.com/civitaspo/alerty-plugin-mail"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'alerty'
23
+ spec.add_dependency 'mail'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "test-unit"
28
+ spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "pry-nav"
30
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "alerty/plugin/mail"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ log_path: STDOUT
2
+ log_level: 'debug'
3
+ timeout: 10
4
+ lock_path: /tmp/lock
5
+ retry_limit: 2
6
+ retry_wait: 10
7
+ plugins:
8
+ - type: mail
9
+ send_from: civitaspo@gmail.com
10
+ send_to: civitaspo@gmail.com
11
+ delivery_method: sendmail # see: https://github.com/mikel/mail
12
+ # delivery_settings:# optional
13
+ # address: 'smtp.example.net',
14
+ # port: 587,
15
+ # domain: 'example',
16
+ # user_name: 'civitaspo',
17
+ # password: 'xxxxxxxxx'
18
+ subject: "FATAL: [${hostname}] ${command}" # optional
@@ -0,0 +1,55 @@
1
+ require "alerty/plugin/mail/version"
2
+
3
+ require 'alerty'
4
+ require 'mail'
5
+
6
+ class Alerty
7
+ class Plugin
8
+ class Mail
9
+ def initialize(config)
10
+ raise ConfigError.new('mail: send_from is not configured') unless config.send_from
11
+ raise ConfigError.new('mail: send_to is not configured') unless config.send_to
12
+ delivery_method = config.delivery_method.to_sym || :sendmail
13
+ delivery_settings = config.delivery_settings
14
+ num_retries = config.num_retries || 3
15
+
16
+ @mail = ::Mail.new do
17
+ from config.send_from
18
+ to config.send_to
19
+ end
20
+ if delivery_settings
21
+ @mail.delivery_method(delivery_method, delivery_settings)
22
+ else
23
+ @mail.delivery_method(delivery_method)
24
+ end
25
+ @num_retries = num_retries
26
+ @subject = config.subject
27
+ end
28
+
29
+ def alert(record)
30
+ subject = expand_placeholder(@subject, record) if @subject
31
+ message = record[:output]
32
+ retries = 0
33
+ begin
34
+ @mail.subject = subject if @subject
35
+ @mail.body = message
36
+ @mail.deliver!
37
+ rescue => e
38
+ retries += 1
39
+ sleep 1
40
+ if retries <= @num_retries
41
+ retry
42
+ else
43
+ raise e
44
+ end
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def expand_placeholder(str, record)
51
+ str.gsub('${hostname}', record[:hostname]).gsub!('${command}', record[:command])
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ class Alerty
2
+ class Plugin
3
+ class Mail
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alerty-plugin-mail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Civitaspo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: alerty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mail
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
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: pry-nav
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: mail plugin for alerty
112
+ email:
113
+ - civitaspo@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - CHANGELOG.md
120
+ - CODE_OF_CONDUCT.md
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - alerty-plugin-mail.gemspec
126
+ - bin/console
127
+ - bin/setup
128
+ - example.yml
129
+ - lib/alerty/plugin/mail.rb
130
+ - lib/alerty/plugin/mail/version.rb
131
+ homepage: https://github.com/civitaspo/alerty-plugin-mail
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.5.1
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: mail plugin for alerty
155
+ test_files: []