hato-plugin-ikachan 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ce060d75ee12e9d32a8b5007fd0c68e351bbe51
4
- data.tar.gz: f782782ac676f750921ad5c8a3b36b2a5bc5a2be
3
+ metadata.gz: 73ecdda925f76a73a317154ac8db5a54ada85802
4
+ data.tar.gz: 588498f0a8c7e2026f672697f115fae8dff08e14
5
5
  SHA512:
6
- metadata.gz: e35db7b4ebea9e0d86ad2a18f53d7b0462544109b922da4e7108892b5737369ab6a23178b2d5a50b158ea5813f37f2061007f310bebf90f924821ce028f428ce
7
- data.tar.gz: 0352c2d078c6bd2c8bc0699589b607fae65595092ea4e20c03fe373efaa729545fc3443686707dbf0e605464e4c38257c596fb847d2246110481d6b0e7bae930
6
+ metadata.gz: e4e3e33efca0ba41d223e2aaf72f706c285cebcbefc119237fe4335349ae1f6963749dc7b0e42fe50012727fd01309c659586fc1486d0cd0cbb099b9272a137a
7
+ data.tar.gz: 8f8da4fd3b06749d65a65132fbe54e31896bc7ea423642c208d13163da22426f6595209042f0d8b202e02fc11bb40452fc193bbd07b9c3c0554f06cf27f9f0e9
data/README.md CHANGED
@@ -17,7 +17,18 @@ Hato::Config.define do
17
17
  scheme 'http'
18
18
  host 'irc.example.com'
19
19
  port 4979
20
- channel %w[hato pigeon],
20
+ channel %w[hato pigeon]
21
+ end
22
+ end
23
+
24
+ # with message template
25
+ tag 'test2' do
26
+ plugin 'Ikachan' do
27
+ scheme 'http'
28
+ host 'irc.example.com'
29
+ port 4979
30
+ channel %w[hato pigeon]
31
+ template 'Message from Hato: <%= args[:message] %>'
21
32
  end
22
33
  end
23
34
 
@@ -3,7 +3,7 @@ require 'hato/plugin'
3
3
  module Hato
4
4
  module Plugin
5
5
  class Ikachan < Base
6
- VERSION = "0.0.3"
6
+ VERSION = "0.0.4"
7
7
  end
8
8
  end
9
9
  end
@@ -1,6 +1,7 @@
1
1
  require 'hato/plugin'
2
2
  require 'hato/plugin/ikachan/version'
3
3
 
4
+ require 'erb'
4
5
  require 'uri'
5
6
  require 'net/http'
6
7
 
@@ -13,13 +14,20 @@ module Hato
13
14
 
14
15
  channel.each do |c|
15
16
  send_message(:join, c)
16
- send_message(:notice, c, args[:message])
17
+ send_message(:notice, c, args)
17
18
  end
18
19
  end
19
20
 
20
21
  protected
21
22
 
22
- def send_message(action, channel, message='')
23
+ def send_message(action, channel, args = {})
24
+ message = args[:message]
25
+
26
+ if config.template
27
+ erb = ERB.new(config.template)
28
+ message = erb.result(binding).chomp
29
+ end
30
+
23
31
  url = '%s://%s:%s/%s' % [
24
32
  config.scheme || 'http',
25
33
  config.host,
@@ -9,7 +9,7 @@ describe Hato::Plugin::Ikachan do
9
9
  subject {
10
10
  described_class.new(
11
11
  Hato::Config::Plugin.new('Ikachan') {
12
- scheme 'example.com'
12
+ host 'example.com'
13
13
  channel 'test'
14
14
  }
15
15
  )
@@ -28,7 +28,7 @@ describe Hato::Plugin::Ikachan do
28
28
  subject {
29
29
  described_class.new(
30
30
  Hato::Config::Plugin.new('Ikachan') {
31
- scheme 'example.com'
31
+ host 'example.com'
32
32
  channel %w[test1 test2]
33
33
  }
34
34
  )
@@ -49,7 +49,7 @@ describe Hato::Plugin::Ikachan do
49
49
  subject {
50
50
  described_class.new(
51
51
  Hato::Config::Plugin.new('Ikachan') {
52
- scheme 'example.com'
52
+ host 'example.com'
53
53
  channel 'test'
54
54
  }
55
55
  )
@@ -72,7 +72,7 @@ describe Hato::Plugin::Ikachan do
72
72
  subject {
73
73
  described_class.new(
74
74
  Hato::Config::Plugin.new('Ikachan') {
75
- scheme 'example.com'
75
+ hos t 'example.com'
76
76
  channel 'test'
77
77
  }
78
78
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hato-plugin-ikachan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Kuribayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hato