hato 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/hato.gemspec +1 -1
- data/lib/hato/observer.rb +3 -3
- data/lib/hato/version.rb +1 -1
- metadata +1 -17
- data/lib/hato/plugin/ikachan.rb +0 -33
- data/lib/hato/plugin/mail.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c911cd9411f589c2ca7db3e534ed77b3536942b8
|
4
|
+
data.tar.gz: 7957d0bf047be3f829a98a9a8ff637088623586a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba45a0d953bd29dc0d3a3bca7195b48f5ed45a1b3a4a885a67c569d6827dfb3a586a06550d6673a9f9e7477d8059f09fe30eeb3b93bbaaa298497f97ea44baf
|
7
|
+
data.tar.gz: f31c44905201b10fc991e91745c6c1cbf734bd0ba8023342ea1b73c218abfbb07a312632c27415e6eee7635375a8d885cf5df78aada0b6e3c2d00caafee0743c
|
data/README.md
CHANGED
@@ -67,10 +67,10 @@ end
|
|
67
67
|
|
68
68
|
## Plugin Architecture
|
69
69
|
|
70
|
-
|
70
|
+
There have alread been some plugins:
|
71
71
|
|
72
|
-
* [Hato::Plugin::Ikachan](
|
73
|
-
* [Hato::Plugin::Mail](
|
72
|
+
* [Hato::Plugin::Ikachan](https://github.com/kentaro/hato-plugin-ikachan)
|
73
|
+
* [Hato::Plugin::Mail](https://github.com/kentaro/hato-plugin-mail)
|
74
74
|
|
75
75
|
You can easily extend Hato by creating your own plugins. See the source for detail. It's really easy.
|
76
76
|
|
@@ -82,7 +82,8 @@ At first, create a `Gemfile` to manage dependencies:
|
|
82
82
|
source 'https://rubygems.org'
|
83
83
|
|
84
84
|
gem 'hato'
|
85
|
-
gem 'hato-plugin-
|
85
|
+
gem 'hato-plugin-mail'
|
86
|
+
gem 'hato-plugin-ikachan'
|
86
87
|
```
|
87
88
|
|
88
89
|
Then, execute `bundle exec hato -c your_config_file`
|
data/hato.gemspec
CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency "sinatra"
|
25
25
|
spec.add_dependency "sinatra-logger"
|
26
|
-
spec.add_dependency "mail"
|
27
26
|
spec.add_dependency "hashie"
|
28
27
|
|
29
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
@@ -31,3 +30,4 @@ Gem::Specification.new do |spec|
|
|
31
30
|
spec.add_development_dependency "rspec"
|
32
31
|
spec.add_development_dependency "pry"
|
33
32
|
end
|
33
|
+
|
data/lib/hato/observer.rb
CHANGED
@@ -11,11 +11,11 @@ module Hato
|
|
11
11
|
plugins = load_plugins_for(args[:tag])
|
12
12
|
|
13
13
|
plugins.each do |plugin|
|
14
|
-
Thread.start(plugin) do |
|
14
|
+
Thread.start(plugin) do |t|
|
15
15
|
begin
|
16
|
-
|
16
|
+
t.notify(args)
|
17
17
|
rescue => e
|
18
|
-
logger.error("#{e.message} from #{
|
18
|
+
logger.error("#{e.message} from #{t.class}")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/hato/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Kuribayashi
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: mail
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: hashie
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,8 +129,6 @@ files:
|
|
143
129
|
- lib/hato/httpd.rb
|
144
130
|
- lib/hato/observer.rb
|
145
131
|
- lib/hato/plugin.rb
|
146
|
-
- lib/hato/plugin/ikachan.rb
|
147
|
-
- lib/hato/plugin/mail.rb
|
148
132
|
- lib/hato/version.rb
|
149
133
|
- spec/assets/config/test.rb
|
150
134
|
- spec/lib/hato/config_spec.rb
|
data/lib/hato/plugin/ikachan.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require 'net/http'
|
3
|
-
|
4
|
-
module Hato
|
5
|
-
module Plugin
|
6
|
-
class Ikachan < Base
|
7
|
-
def notify(args)
|
8
|
-
send_request(:join)
|
9
|
-
send_request(:notice, args[:message])
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def send_request(action, message='')
|
15
|
-
url = '%s://%s:%s/%s' % [
|
16
|
-
config.scheme || 'http',
|
17
|
-
config.host,
|
18
|
-
config.port || 4979,
|
19
|
-
action.to_s,
|
20
|
-
]
|
21
|
-
|
22
|
-
http = Net::HTTP.new(URI(url).host, URI(url).port)
|
23
|
-
req = Net::HTTP::Post.new(URI(url).path)
|
24
|
-
|
25
|
-
req.form_data = {
|
26
|
-
'channel' => "##{config.channel}",
|
27
|
-
'message' => message,
|
28
|
-
}
|
29
|
-
http.request(req)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/hato/plugin/mail.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'mail'
|
3
|
-
|
4
|
-
module Hato
|
5
|
-
module Plugin
|
6
|
-
class Mail < Base
|
7
|
-
def notify(args)
|
8
|
-
if smtp_opts = config.smtp
|
9
|
-
::Mail.defaults do
|
10
|
-
delivery_method :smtp, (
|
11
|
-
smtp_opts.to_hash.keys.inject({}) { |opts, key|
|
12
|
-
opts[key.to_sym] = smtp_opts.send(key.to_sym)
|
13
|
-
opts
|
14
|
-
}
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
to_addresses = config.message['to']
|
20
|
-
if to_addresses.is_a?(String)
|
21
|
-
to_addresses = [to_addresses]
|
22
|
-
end
|
23
|
-
|
24
|
-
mail = {
|
25
|
-
from: config.message['from'],
|
26
|
-
subject: render(config.message['subject_template'], args),
|
27
|
-
body: render(config.message['body_template'], args),
|
28
|
-
}
|
29
|
-
|
30
|
-
to_addresses.each do |to_address|
|
31
|
-
::Mail.deliver do
|
32
|
-
from mail[:from]
|
33
|
-
to to_address
|
34
|
-
subject mail[:subject]
|
35
|
-
body mail[:body]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
def render(template, args)
|
43
|
-
erb = ERB.new(template)
|
44
|
-
erb.result(binding).chomp
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|