fluent-plugin-boundio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +14 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/fluent-plugin-boundio.gemspec +20 -0
- data/lib/fluent/plugin/out_boundio.rb +46 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_boundio.rb +46 -0
- metadata +79 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2012- Kentaro Yoshida
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
fluent-plugin-boundio
|
2
|
+
=====================
|
3
|
+
|
4
|
+
## Component
|
5
|
+
Fluent Input plugin to make a call with boundio by KDDI. This Multilingual speech synthesis system uses VoiceText.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### native gem
|
10
|
+
`````
|
11
|
+
gem install fluent-plugin-boundio
|
12
|
+
`````
|
13
|
+
|
14
|
+
### td-agent gem
|
15
|
+
`````
|
16
|
+
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-boundio
|
17
|
+
`````
|
18
|
+
|
19
|
+
## Output Configuration
|
20
|
+
|
21
|
+
### Output Sample
|
22
|
+
`````
|
23
|
+
<source>
|
24
|
+
type http
|
25
|
+
port 8888
|
26
|
+
</source>
|
27
|
+
|
28
|
+
<match notify.call>
|
29
|
+
type boundio
|
30
|
+
user_serial_id YOUR_BOUNDIO_USER_SERIAL_ID
|
31
|
+
api_key YOUR_BOUNDIO_API_KEY
|
32
|
+
user_key YOUR_BOUNDIO_USER_KEY
|
33
|
+
default_number 09012345678
|
34
|
+
</match>
|
35
|
+
`````
|
36
|
+
|
37
|
+
### Debug
|
38
|
+
`````
|
39
|
+
$ curl http://localhost:8888/notify.call -F 'json={"number":"09012345678","message":"Help! System ABC has down."}'
|
40
|
+
$ tail -f /var/log/td-agent/td-agent.log
|
41
|
+
`````
|
42
|
+
|
43
|
+
## Backend Service
|
44
|
+
http://boundio.jp/
|
45
|
+
|
46
|
+
## TODO
|
47
|
+
patches welcome!
|
48
|
+
|
49
|
+
## Copyright
|
50
|
+
Copyright © 2012- Kentaro Yoshida (@yoshi_ken)
|
51
|
+
|
52
|
+
## License
|
53
|
+
Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-boundio"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = ["Kentaro Yoshida"]
|
8
|
+
s.email = ["y.ken.studio@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/y-ken/fluent-plugin-boundio"
|
10
|
+
s.summary = %q{Fluent Input plugin to make a call with boundio by KDDI. This Multilingual speech synthesis system uses VoiceText.}
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
|
17
|
+
# specify any dependencies here; for example:
|
18
|
+
s.add_development_dependency "fluentd"
|
19
|
+
s.add_runtime_dependency "fluentd"
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class Fluent::BoundioOutput < Fluent::Output
|
3
|
+
Fluent::Plugin.register_output('boundio', self)
|
4
|
+
|
5
|
+
config_param :user_serial_id, :string
|
6
|
+
config_param :api_key, :string
|
7
|
+
config_param :user_key, :string
|
8
|
+
config_param :default_number, :string
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
require 'uri'
|
14
|
+
require 'net/https'
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
|
20
|
+
@voice_type = 1
|
21
|
+
end
|
22
|
+
|
23
|
+
def emit(tag, es, chain)
|
24
|
+
es.each do |time,record|
|
25
|
+
number = record['number'].nil? ? @default_number : record['number']
|
26
|
+
call(number, record['message'])
|
27
|
+
end
|
28
|
+
|
29
|
+
chain.next
|
30
|
+
end
|
31
|
+
|
32
|
+
def call(number, message)
|
33
|
+
begin
|
34
|
+
https = Net::HTTP.new('boundio.jp', 443)
|
35
|
+
https.use_ssl = true
|
36
|
+
cast = "file_d(#{message}, #{@voice_type})"
|
37
|
+
query = 'key=' + @api_key + '&tel_to=' + number + '&cast=' + cast
|
38
|
+
response = https.post('/api/vd2/' + @user_serial_id + '/call', URI.escape(query))
|
39
|
+
$log.info "boundio makeing a call: #{message} "
|
40
|
+
$log.info "boundio call result: #{response.body}"
|
41
|
+
rescue => e
|
42
|
+
$log.error("Boundio Error: #{e.message}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_boundio'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BoundioOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
user_serial_id YOUR_BOUNDIO_USER_SERIAL_ID
|
10
|
+
api_key YOUR_BOUNDIO_API_KEY
|
11
|
+
user_key YOUR_BOUNDIO_USER_KEY
|
12
|
+
default_number 09012345678
|
13
|
+
]
|
14
|
+
|
15
|
+
def create_driver(conf=CONFIG,tag='test')
|
16
|
+
Fluent::Test::OutputTestDriver.new(Fluent::BoundioOutput, tag).configure(conf)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_configure
|
20
|
+
assert_raise(Fluent::ConfigError) {
|
21
|
+
d = create_driver('')
|
22
|
+
}
|
23
|
+
d = create_driver %[
|
24
|
+
user_serial_id YOUR_BOUNDIO_USER_SERIAL_ID
|
25
|
+
api_key YOUR_BOUNDIO_API_KEY
|
26
|
+
user_key YOUR_BOUNDIO_USER_KEY
|
27
|
+
default_number 09012345678
|
28
|
+
]
|
29
|
+
d.instance.inspect
|
30
|
+
assert_equal 'YOUR_BOUNDIO_USER_SERIAL_ID', d.instance.user_serial_id
|
31
|
+
assert_equal 'YOUR_BOUNDIO_API_KEY', d.instance.api_key
|
32
|
+
assert_equal 'YOUR_BOUNDIO_USER_KEY', d.instance.user_key
|
33
|
+
assert_equal '09012345678', d.instance.default_number
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_emit
|
37
|
+
d1 = create_driver(CONFIG, 'input.access')
|
38
|
+
time = Time.parse("2012-01-02 13:14:15").to_i
|
39
|
+
d1.run do
|
40
|
+
d1.emit({'message' => 'sample message'})
|
41
|
+
end
|
42
|
+
emits = d1.emits
|
43
|
+
assert_equal 0, emits.length
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-boundio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kentaro Yoshida
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: &16370520 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *16370520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fluentd
|
27
|
+
requirement: &16370080 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *16370080
|
36
|
+
description:
|
37
|
+
email:
|
38
|
+
- y.ken.studio@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE.txt
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- fluent-plugin-boundio.gemspec
|
49
|
+
- lib/fluent/plugin/out_boundio.rb
|
50
|
+
- test/helper.rb
|
51
|
+
- test/plugin/test_out_boundio.rb
|
52
|
+
homepage: https://github.com/y-ken/fluent-plugin-boundio
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.11
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Fluent Input plugin to make a call with boundio by KDDI. This Multilingual
|
76
|
+
speech synthesis system uses VoiceText.
|
77
|
+
test_files:
|
78
|
+
- test/helper.rb
|
79
|
+
- test/plugin/test_out_boundio.rb
|