io_mailer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +83 -0
- data/README.md +11 -0
- data/Rakefile +8 -0
- data/bin/io_mailer +31 -0
- data/bin/test.sh +4 -0
- data/config/io_mailer.yml.example +0 -0
- data/config/schedule.rb +3 -0
- data/io_mailer.gemspec +29 -0
- data/lib/io_mailer.rb +20 -0
- data/lib/io_mailer/configuration.rb +46 -0
- data/lib/io_mailer/notification_mailer.rb +13 -0
- data/lib/io_mailer/version.rb +3 -0
- data/views/mailers/io_mailer/notification_mailer/notify.html.erb +15 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d51a2f6ef6be68f5cf79af0beed57d01a1e3bdb2
|
4
|
+
data.tar.gz: e7e53b04c44885bb7041f67710167789f9dd75ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 402c25c3211566d656b6da675ac501982a0ea834d74684ae03d4ae93f594cfa0a27ad94b2a9683a55bc159b5e2aef1dc4d4ad775336fb8060fcda9a196f54eba
|
7
|
+
data.tar.gz: c5d640c060af53e483e698823a96add02b6f06218c74f327efd7a9f0832e6c5b6a87bb4599386c1d1956981d9d2c924854724014254411b70920fe74476b849f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
io_mailer (0.0.1)
|
5
|
+
actionmailer
|
6
|
+
whenever
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.0.1)
|
12
|
+
actionpack (= 4.0.1)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (4.0.1)
|
15
|
+
activesupport (= 4.0.1)
|
16
|
+
builder (~> 3.1.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
activesupport (4.0.1)
|
21
|
+
i18n (~> 0.6, >= 0.6.4)
|
22
|
+
minitest (~> 4.2)
|
23
|
+
multi_json (~> 1.3)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
tzinfo (~> 0.3.37)
|
26
|
+
addressable (2.3.5)
|
27
|
+
atomic (1.1.14)
|
28
|
+
builder (3.1.4)
|
29
|
+
chronic (0.10.2)
|
30
|
+
coderay (1.1.0)
|
31
|
+
columnize (0.3.6)
|
32
|
+
debugger (1.6.2)
|
33
|
+
columnize (>= 0.3.1)
|
34
|
+
debugger-linecache (~> 1.2.0)
|
35
|
+
debugger-ruby_core_source (~> 1.2.3)
|
36
|
+
debugger-linecache (1.2.0)
|
37
|
+
debugger-ruby_core_source (1.2.3)
|
38
|
+
erubis (2.7.0)
|
39
|
+
i18n (0.6.5)
|
40
|
+
launchy (2.4.0)
|
41
|
+
addressable (~> 2.3)
|
42
|
+
letter_opener (1.1.2)
|
43
|
+
launchy (~> 2.2)
|
44
|
+
mail (2.5.4)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
method_source (0.8.2)
|
48
|
+
mime-types (1.25)
|
49
|
+
minitest (4.7.5)
|
50
|
+
multi_json (1.8.2)
|
51
|
+
polyglot (0.3.3)
|
52
|
+
pry (0.9.12.3)
|
53
|
+
coderay (~> 1.0)
|
54
|
+
method_source (~> 0.8)
|
55
|
+
slop (~> 3.4)
|
56
|
+
pry-debugger (0.2.2)
|
57
|
+
debugger (~> 1.3)
|
58
|
+
pry (~> 0.9.10)
|
59
|
+
rack (1.5.2)
|
60
|
+
rack-test (0.6.2)
|
61
|
+
rack (>= 1.0)
|
62
|
+
rake (10.1.0)
|
63
|
+
slop (3.4.7)
|
64
|
+
thread_safe (0.1.3)
|
65
|
+
atomic
|
66
|
+
treetop (1.4.15)
|
67
|
+
polyglot
|
68
|
+
polyglot (>= 0.3.1)
|
69
|
+
tzinfo (0.3.38)
|
70
|
+
whenever (0.8.4)
|
71
|
+
activesupport (>= 2.3.4)
|
72
|
+
chronic (>= 0.6.3)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
bundler
|
79
|
+
io_mailer!
|
80
|
+
letter_opener
|
81
|
+
pry
|
82
|
+
pry-debugger
|
83
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# IO Mailer
|
2
|
+
|
3
|
+
This simple script executes a command provided as command line argument and sends the output results of the script to email addresses. These email addresses can be specified in a configuration file.
|
4
|
+
|
5
|
+
# Configuration
|
6
|
+
* Recipient email addresses can be specified in the config/io_mailer.yml
|
7
|
+
file. An example can be found under config/io_mailer.yml.example .
|
8
|
+
|
9
|
+
# Usage
|
10
|
+
|
11
|
+
* Script execution: bundle exec bin/io_mailer <the script file location or command to execute> (e.g. bundle exec bin/io_mailer ls)
|
data/Rakefile
ADDED
data/bin/io_mailer
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'open3'
|
3
|
+
require_relative '../lib/io_mailer'
|
4
|
+
|
5
|
+
raise "Insufficient arguments for io_mailer. Please specify a script or a command to run" if ARGV.size < 1
|
6
|
+
puts "Running io_mailer with arguments=#{ARGV}"
|
7
|
+
|
8
|
+
command = ARGV[0]
|
9
|
+
command_output = []
|
10
|
+
|
11
|
+
IO.popen(command).each do |line|
|
12
|
+
command_output << line.chomp
|
13
|
+
end
|
14
|
+
|
15
|
+
config = IOMailer.config.config
|
16
|
+
|
17
|
+
puts "The command/script produced the following output:"
|
18
|
+
puts ""
|
19
|
+
puts command_output
|
20
|
+
|
21
|
+
payload = { :command => command }
|
22
|
+
payload[:lines] = command_output
|
23
|
+
|
24
|
+
puts "Sending email to recipients: #{config['recipients']} !"
|
25
|
+
mail = IOMailer::NotificationMailer.notify(config['recipients'], config['from_address'], config['subject'], payload)
|
26
|
+
|
27
|
+
puts "Sending email with body:"
|
28
|
+
puts mail.body
|
29
|
+
|
30
|
+
mail.deliver
|
31
|
+
puts "Sent email!"
|
data/bin/test.sh
ADDED
File without changes
|
data/config/schedule.rb
ADDED
data/io_mailer.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'io_mailer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'io_mailer'
|
8
|
+
spec.version = IOMailer::VERSION
|
9
|
+
spec.authors = ["Julian Weber"]
|
10
|
+
spec.email = ["jweber@anynines.com"]
|
11
|
+
spec.description = %q{IOMailer is a simple script for executing commands and shell scripts, collecting their output and mailing it to designated email addresses.}
|
12
|
+
spec.summary = %q{IOMailer is a simple script for executing commands and shell scripts, collecting their output and mailing it to designated email addresses.}
|
13
|
+
spec.homepage = "http://anynines.com"
|
14
|
+
spec.license = ""
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'pry-debugger'
|
24
|
+
spec.add_development_dependency 'pry'
|
25
|
+
spec.add_development_dependency 'letter_opener'
|
26
|
+
|
27
|
+
spec.add_dependency 'actionmailer'
|
28
|
+
spec.add_dependency 'whenever'
|
29
|
+
end
|
data/lib/io_mailer.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'io_mailer/version'
|
2
|
+
require 'pry'
|
3
|
+
require 'action_mailer'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module IOMailer
|
7
|
+
autoload :NotificationMailer, File.expand_path('../io_mailer/notification_mailer', __FILE__)
|
8
|
+
autoload :Configuration, File.expand_path('../io_mailer/configuration', __FILE__)
|
9
|
+
|
10
|
+
@@config = nil
|
11
|
+
|
12
|
+
def self.config
|
13
|
+
@@config = IOMailer::Configuration.new(File.expand_path('config/io_mailer.yml')) if @@config.nil?
|
14
|
+
return @@config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.base_directory
|
18
|
+
File.expand_path("../", File.dirname(__FILE__))
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class IOMailer::Configuration
|
2
|
+
attr_accessor :config
|
3
|
+
|
4
|
+
def initialize(file_location)
|
5
|
+
load_config_from_file(file_location)
|
6
|
+
configure_mailer
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Loads the configuration from the specified yaml file.
|
13
|
+
def load_config_from_file(file_location)
|
14
|
+
raise "There's no configuration file at #{file_location}!" unless File.exists? file_location
|
15
|
+
config = YAML.load_file(file_location)
|
16
|
+
@config = config
|
17
|
+
@config
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure_mailer
|
21
|
+
if @config['delivery_method'].to_sym == :letter_opener
|
22
|
+
configure_letter_opener
|
23
|
+
else
|
24
|
+
configure_action_mailer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure_action_mailer
|
29
|
+
::ActionMailer::Base.raise_delivery_errors = true
|
30
|
+
::ActionMailer::Base.delivery_method = @config['delivery_method'].to_sym
|
31
|
+
|
32
|
+
::ActionMailer::Base.smtp_settings = @config['smtp_settings'] if ActionMailer::Base.delivery_method == :smtp
|
33
|
+
|
34
|
+
::ActionMailer::Base.view_paths = File.expand_path('../../../views/mailers', __FILE__)
|
35
|
+
end
|
36
|
+
|
37
|
+
def configure_letter_opener
|
38
|
+
require "letter_opener"
|
39
|
+
|
40
|
+
ActionMailer::Base.raise_delivery_errors = true
|
41
|
+
ActionMailer::Base.add_delivery_method :letter_opener, LetterOpener::DeliveryMethod,
|
42
|
+
:location => File.expand_path("./tmp", IOMailer.base_directory)
|
43
|
+
ActionMailer::Base.delivery_method = :letter_opener
|
44
|
+
ActionMailer::Base.view_paths = File.expand_path('../../../views/mailers', __FILE__)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class IOMailer::NotificationMailer < ActionMailer::Base
|
2
|
+
|
3
|
+
def notify(recipients, from_address, subject, payload)
|
4
|
+
@payload = payload
|
5
|
+
|
6
|
+
mail( :to => recipients,
|
7
|
+
:from => from_address,
|
8
|
+
:subject => subject) do |format|
|
9
|
+
format.html { render }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>IOMailer Message delivery for command: <%= @payload[:command] %></h1></br>
|
9
|
+
<p>
|
10
|
+
<% @payload[:lines].each do |l| %>
|
11
|
+
<%= l %> </br>
|
12
|
+
<% end %>
|
13
|
+
</p>
|
14
|
+
</body>
|
15
|
+
</html>
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: io_mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julian Weber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: pry-debugger
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: letter_opener
|
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: actionmailer
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
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: whenever
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: IOMailer is a simple script for executing commands and shell scripts,
|
112
|
+
collecting their output and mailing it to designated email addresses.
|
113
|
+
email:
|
114
|
+
- jweber@anynines.com
|
115
|
+
executables:
|
116
|
+
- io_mailer
|
117
|
+
- test.sh
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- .gitignore
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/io_mailer
|
127
|
+
- bin/test.sh
|
128
|
+
- config/io_mailer.yml.example
|
129
|
+
- config/schedule.rb
|
130
|
+
- io_mailer.gemspec
|
131
|
+
- lib/io_mailer.rb
|
132
|
+
- lib/io_mailer/configuration.rb
|
133
|
+
- lib/io_mailer/notification_mailer.rb
|
134
|
+
- lib/io_mailer/version.rb
|
135
|
+
- views/mailers/io_mailer/notification_mailer/notify.html.erb
|
136
|
+
homepage: http://anynines.com
|
137
|
+
licenses:
|
138
|
+
- ''
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.0.6
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: IOMailer is a simple script for executing commands and shell scripts, collecting
|
160
|
+
their output and mailing it to designated email addresses.
|
161
|
+
test_files: []
|