fluent-plugin-twilio 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/README.md +22 -8
- data/fluent-plugin-twilio.gemspec +2 -2
- data/lib/fluent/plugin/out_twilio.rb +13 -6
- data/test/plugin/test_out_twilio.rb +14 -1
- metadata +5 -3
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -6,13 +6,13 @@ Fluentd Output plugin to make a call with twilio.
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
install with gem or fluent-gem command as:
|
10
|
+
|
10
11
|
`````
|
12
|
+
### system installed gem
|
11
13
|
gem install fluent-plugin-twilio
|
12
|
-
`````
|
13
14
|
|
14
|
-
### td-agent gem
|
15
|
-
`````
|
15
|
+
### td-agent bundled gem
|
16
16
|
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-twilio
|
17
17
|
`````
|
18
18
|
|
@@ -35,10 +35,20 @@ fluent_logger.post('notify.call', {
|
|
35
35
|
|
36
36
|
<match notify.call>
|
37
37
|
type twilio
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
|
39
|
+
# Set account Sid and Token from twilio.com/user/account
|
40
|
+
account_sid TWILIO_ACCOUNT_SID # Required
|
41
|
+
auth_token TWILIO_AUTH_TOKEN # Required
|
42
|
+
|
43
|
+
# Set caller ID with country code
|
44
|
+
from_number +81312345678 # Required
|
45
|
+
|
46
|
+
# Set defaults of making outbound call.
|
47
|
+
# To call multiple phone at the same time, list them with comma like below.
|
48
|
+
default_number +819012345678,+818012345678 # Optional
|
49
|
+
|
50
|
+
# Set log level to prevent info error for Fluentd v0.10.43 or later.
|
51
|
+
log_level warn
|
42
52
|
</match>
|
43
53
|
`````
|
44
54
|
|
@@ -56,6 +66,10 @@ $ tail -f /var/log/td-agent/td-agent.log
|
|
56
66
|
* Twilio https://www.twilio.com/
|
57
67
|
* Twilio Japan http://twilio.kddi-web.com/
|
58
68
|
|
69
|
+
## Blog Articles
|
70
|
+
|
71
|
+
* http://y-ken.hatenablog.com/entry/fluent-plugin-twilio-has-released
|
72
|
+
|
59
73
|
## TODO
|
60
74
|
Pull requests are very welcome!!
|
61
75
|
|
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-twilio"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.2"
|
7
7
|
s.authors = ["Kentaro Yoshida"]
|
8
8
|
s.email = ["y.ken.studio@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/y-ken/fluent-plugin-twilio"
|
10
|
-
s.summary = %q{Fluentd Output plugin to make a call with twilio.}
|
10
|
+
s.summary = %q{Fluentd Output plugin to make a call with Twilio VoIP API. Twiml supports text-to-speech with many languages ref. https://www.twilio.com/docs/api/twiml/say}
|
11
11
|
|
12
12
|
s.files = `git ls-files`.split("\n")
|
13
13
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -8,7 +8,12 @@ class Fluent::TwilioOutput < Fluent::Output
|
|
8
8
|
config_param :default_voice, :string, :default => 'woman'
|
9
9
|
config_param :language, :string, :default => 'ja-jp'
|
10
10
|
|
11
|
-
VOICE_MAP = ['woman']
|
11
|
+
VOICE_MAP = ['man', 'woman']
|
12
|
+
|
13
|
+
# Define `log` method for v0.10.42 or earlier
|
14
|
+
unless method_defined?(:log)
|
15
|
+
define_method("log") { $log }
|
16
|
+
end
|
12
17
|
|
13
18
|
def initialize
|
14
19
|
super
|
@@ -37,14 +42,16 @@ class Fluent::TwilioOutput < Fluent::Output
|
|
37
42
|
end
|
38
43
|
xml = response.text.sub(/<[^>]+?>/, '')
|
39
44
|
url = "http://twimlets.com/echo?Twiml=#{URI.escape(xml)}"
|
40
|
-
|
45
|
+
log.info "twilio: generateing twiml: #{xml}"
|
41
46
|
|
42
47
|
client = Twilio::REST::Client.new(@account_sid, @auth_token)
|
43
48
|
account = client.account
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
number.gsub(' ', '').split(',').each do |to_number|
|
50
|
+
begin
|
51
|
+
call = account.calls.create({:from => @from_number, :to => to_number, :url => url})
|
52
|
+
rescue => e
|
53
|
+
log.error "twilio: Error: #{e.message}"
|
54
|
+
end
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
@@ -24,12 +24,25 @@ class TwilioOutputTest < Test::Unit::TestCase
|
|
24
24
|
auth_token TWILIO_AUTH_TOKEN
|
25
25
|
from_number +8112345678
|
26
26
|
]
|
27
|
-
d.instance.inspect
|
28
27
|
assert_equal 'TWILIO_ACCOUNT_SID', d.instance.account_sid
|
29
28
|
assert_equal 'TWILIO_AUTH_TOKEN', d.instance.auth_token
|
30
29
|
assert_equal '+8112345678', d.instance.from_number
|
31
30
|
end
|
32
31
|
|
32
|
+
def test_configure_multinumber
|
33
|
+
d = create_driver %[
|
34
|
+
account_sid TWILIO_ACCOUNT_SID
|
35
|
+
auth_token TWILIO_AUTH_TOKEN
|
36
|
+
from_number +8112345678
|
37
|
+
default_number +81123456789,+811234567890
|
38
|
+
]
|
39
|
+
assert_equal 'TWILIO_ACCOUNT_SID', d.instance.account_sid
|
40
|
+
assert_equal 'TWILIO_AUTH_TOKEN', d.instance.auth_token
|
41
|
+
assert_equal '+8112345678', d.instance.from_number
|
42
|
+
assert_equal '+81123456789,+811234567890', d.instance.default_number
|
43
|
+
end
|
44
|
+
|
45
|
+
|
33
46
|
def test_emit
|
34
47
|
d1 = create_driver(CONFIG, 'notify.call')
|
35
48
|
d1.run do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -67,6 +67,7 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- .travis.yml
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE.txt
|
72
73
|
- README.md
|
@@ -98,7 +99,8 @@ rubyforge_project:
|
|
98
99
|
rubygems_version: 1.8.23
|
99
100
|
signing_key:
|
100
101
|
specification_version: 3
|
101
|
-
summary: Fluentd Output plugin to make a call with
|
102
|
+
summary: Fluentd Output plugin to make a call with Twilio VoIP API. Twiml supports
|
103
|
+
text-to-speech with many languages ref. https://www.twilio.com/docs/api/twiml/say
|
102
104
|
test_files:
|
103
105
|
- test/helper.rb
|
104
106
|
- test/plugin/test_out_twilio.rb
|