fluent-plugin-twilio 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab70ac89145baa0be76178e959a1528a6376f2d0
4
+ data.tar.gz: ee066533389d27be18d2a72ea98bfc09b077faac
5
+ SHA512:
6
+ metadata.gz: 1b94d3ac7124a401b14d849337b76d97cacc167ff61bbe175dd79fc10ddf2c904d614fef30d4d60604adfad1ac6a065bc05c1951f83f819f900b3147a7ec6529
7
+ data.tar.gz: f2f726644ce54a5e7f709dc8e214c20dab16650d240126a4371d5e992a00b37f22e0761b27b146670030cab49c0b452fcb5b96f64ac43e90f88b4662fc636aeb
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ vendor/*
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.4.1
5
+ - 2.3.4
4
6
  - 2.2
5
7
  - 2.1
6
- - 2.0.0
7
- - 1.9.3
8
-
8
+
data/README.md CHANGED
@@ -3,17 +3,27 @@ fluent-plugin-twilio
3
3
 
4
4
  ## Overview
5
5
  Fluentd Output plugin to make a call with twilio.
6
+ Twilio free trial is available to signup at the official website.
7
+ You can try call to your cellphone for free!
8
+
9
+ ## Requirements
10
+
11
+ | fluent-plugin-twilio | fluentd | ruby |
12
+ |----------------------|-------------|--------|
13
+ | >= 0.1.0 | >= v0.14.15 | >= 2.1 |
14
+ | < 0.1.0 | >= v0.12.0 | >= 1.9 |
15
+
6
16
 
7
17
  ## Installation
8
18
 
9
- install with gem or fluent-gem command as:
19
+ install with gem or td-agent-gem command as:
10
20
 
11
21
  `````
12
- ### system installed gem
13
- gem install fluent-plugin-twilio
22
+ ### for local fluentd
23
+ $ gem install fluent-plugin-twilio
14
24
 
15
- ### td-agent bundled gem
16
- /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-twilio
25
+ ### for td-agent2 (standard)
26
+ $ sudo td-agent-gem install fluent-plugin-twilio
17
27
  `````
18
28
 
19
29
  ## Configuration
@@ -29,12 +39,12 @@ fluent_logger.post('notify.call', {
29
39
  ### Sample
30
40
  `````
31
41
  <source>
32
- type http
42
+ @type http
33
43
  port 8888
34
44
  </source>
35
45
 
36
46
  <match notify.call>
37
- type twilio
47
+ @type twilio
38
48
 
39
49
  # Set account Sid and Token from twilio.com/user/account
40
50
  account_sid TWILIO_ACCOUNT_SID # Required
@@ -47,11 +57,36 @@ fluent_logger.post('notify.call', {
47
57
  # To call multiple phone at the same time, list them with comma like below.
48
58
  default_number +819012345678,+818012345678 # Optional
49
59
 
50
- # Set log level to prevent info error for Fluentd v0.10.43 or later.
51
- log_level warn
60
+ # Set log level to prevent info error
61
+ @log_level warn
52
62
  </match>
53
63
  `````
54
64
 
65
+ ### Sample to customize messages
66
+
67
+ You can customize message using [filter_record_transformer](http://docs.fluentd.org/v0.14/articles/filter_record_transformer).
68
+
69
+ ```
70
+ <source>
71
+ @type http
72
+ port 8888
73
+ @label @NOTIFY
74
+ </source>
75
+
76
+ <label @NOTIFY>
77
+ <filter>
78
+ @type record_transformer
79
+ <record>
80
+ message Hi. ${record["name"]} has made a order of ${record["item"]} just now.
81
+ </record>
82
+ </filter>
83
+ <match>
84
+ @type twilio
85
+ # snip ...
86
+ </match>
87
+ </label>
88
+ ```
89
+
55
90
  ### Quick Test
56
91
  `````
57
92
  # test call to +819012345678 and say "Help! System ABC has down." with woman voice.
@@ -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.3"
6
+ s.version = "0.1.0"
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 VoIP API. Twiml supports text-to-speech with many languages ref. https://www.twilio.com/docs/api/twiml/say}
10
+ s.summary = %q{Fluentd Output plugin to make a phone 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")
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
17
17
  # specify any dependencies here; for example:
18
18
  s.add_development_dependency "rake"
19
19
  s.add_development_dependency "test-unit", ">= 3.1.0"
20
- s.add_runtime_dependency "fluentd"
20
+ s.add_runtime_dependency "fluentd", ">= 0.14.15", "< 2"
21
21
  s.add_runtime_dependency "twilio-ruby"
22
22
  end
@@ -1,44 +1,36 @@
1
- class Fluent::TwilioOutput < Fluent::Output
1
+ require 'uri'
2
+ require 'twilio-ruby'
3
+
4
+ require 'fluent/plugin/output'
5
+
6
+ class Fluent::Plugin::TwilioOutput < Fluent::Plugin::Output
2
7
  Fluent::Plugin.register_output('twilio', self)
3
8
 
4
9
  config_param :account_sid, :string
5
- config_param :auth_token, :string, :secret => true
6
- config_param :from_number, :string, :default => ''
7
- config_param :default_number, :string, :default => ''
8
- config_param :default_voice, :string, :default => 'woman'
9
- config_param :language, :string, :default => 'ja-jp'
10
+ config_param :auth_token, :string, secret: true
11
+ config_param :from_number, :string, default: ''
12
+ config_param :default_number, :string, default: ''
13
+ config_param :default_voice, :string, default: 'woman'
14
+ config_param :language, :string, default: 'ja-jp'
10
15
 
11
16
  VOICE_MAP = ['man', 'woman']
12
17
 
13
- # Define `log` method for v0.10.42 or earlier
14
- unless method_defined?(:log)
15
- define_method("log") { $log }
16
- end
17
-
18
- def initialize
19
- super
20
- require 'uri'
21
- require 'twilio-ruby'
22
- end
23
-
24
18
  def configure(conf)
25
19
  super
26
20
 
27
21
  end
28
22
 
29
- def emit(tag, es, chain)
23
+ def process(tag, es)
30
24
  es.each do |time,record|
31
25
  number = record['number'].nil? ? @default_number : record['number']
32
26
  @voice = VOICE_MAP.include?(record['voice']) ? record['voice'] : @default_voice
33
27
  call(number, record['message'])
34
28
  end
35
-
36
- chain.next
37
29
  end
38
30
 
39
31
  def call(number, message)
40
32
  response = Twilio::TwiML::Response.new do |r|
41
- r.Say message, :voice => @voice, :language => @language
33
+ r.Say message, voice: @voice, language: @language
42
34
  end
43
35
  xml = response.text.sub(/<[^>]+?>/, '')
44
36
  url = "http://twimlets.com/echo?Twiml=#{URI.escape(xml)}"
@@ -48,7 +40,7 @@ class Fluent::TwilioOutput < Fluent::Output
48
40
  account = client.account
49
41
  number.gsub(' ', '').split(',').each do |to_number|
50
42
  begin
51
- call = account.calls.create({:from => @from_number, :to => to_number, :url => url})
43
+ account.calls.create({from: @from_number, to: to_number, url: url})
52
44
  rescue => e
53
45
  log.error "twilio: Error: #{e.message}"
54
46
  end
@@ -1,28 +1,10 @@
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
1
+ require 'bundler/setup'
10
2
  require 'test/unit'
11
3
 
12
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
5
+ $LOAD_PATH.unshift(__dir__)
14
6
  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
7
+ require 'fluent/test/driver/output'
24
8
 
25
9
  require 'fluent/plugin/out_twilio'
26
10
 
27
- class Test::Unit::TestCase
28
- end
@@ -11,8 +11,8 @@ class TwilioOutputTest < Test::Unit::TestCase
11
11
  from_number +8112345678
12
12
  ]
13
13
 
14
- def create_driver(conf=CONFIG,tag='test')
15
- Fluent::Test::OutputTestDriver.new(Fluent::TwilioOutput, tag).configure(conf)
14
+ def create_driver(conf=CONFIG)
15
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::TwilioOutput).configure(conf)
16
16
  end
17
17
 
18
18
  def test_configure
@@ -44,12 +44,12 @@ class TwilioOutputTest < Test::Unit::TestCase
44
44
 
45
45
 
46
46
  def test_emit
47
- d1 = create_driver(CONFIG, 'notify.call')
48
- d1.run do
49
- d1.emit({'message' => 'hello world.'})
47
+ d1 = create_driver(CONFIG)
48
+ d1.run(default_tag: 'notify.call') do
49
+ d1.feed({'message' => 'hello world.'})
50
50
  end
51
- emits = d1.emits
52
- assert_equal 0, emits.length
51
+ events = d1.events
52
+ assert_equal 0, events.length
53
53
  end
54
54
  end
55
55
 
metadata CHANGED
@@ -1,78 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-twilio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kentaro Yoshida
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-09-09 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: test-unit
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.1.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.1.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fluentd
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 0.14.15
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '2'
54
51
  type: :runtime
55
52
  prerelease: false
56
53
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
54
  requirements:
59
- - - ! '>='
55
+ - - ">="
60
56
  - !ruby/object:Gem::Version
61
- version: '0'
57
+ version: 0.14.15
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2'
62
61
  - !ruby/object:Gem::Dependency
63
62
  name: twilio-ruby
64
63
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
64
  requirements:
67
- - - ! '>='
65
+ - - ">="
68
66
  - !ruby/object:Gem::Version
69
67
  version: '0'
70
68
  type: :runtime
71
69
  prerelease: false
72
70
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
71
  requirements:
75
- - - ! '>='
72
+ - - ">="
76
73
  - !ruby/object:Gem::Version
77
74
  version: '0'
78
75
  description:
@@ -82,8 +79,8 @@ executables: []
82
79
  extensions: []
83
80
  extra_rdoc_files: []
84
81
  files:
85
- - .gitignore
86
- - .travis.yml
82
+ - ".gitignore"
83
+ - ".travis.yml"
87
84
  - Gemfile
88
85
  - LICENSE.txt
89
86
  - README.md
@@ -94,28 +91,27 @@ files:
94
91
  - test/plugin/test_out_twilio.rb
95
92
  homepage: https://github.com/y-ken/fluent-plugin-twilio
96
93
  licenses: []
94
+ metadata: {}
97
95
  post_install_message:
98
96
  rdoc_options: []
99
97
  require_paths:
100
98
  - lib
101
99
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
100
  requirements:
104
- - - ! '>='
101
+ - - ">="
105
102
  - !ruby/object:Gem::Version
106
103
  version: '0'
107
104
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
105
  requirements:
110
- - - ! '>='
106
+ - - ">="
111
107
  - !ruby/object:Gem::Version
112
108
  version: '0'
113
109
  requirements: []
114
110
  rubyforge_project:
115
- rubygems_version: 1.8.23
111
+ rubygems_version: 2.2.5
116
112
  signing_key:
117
- specification_version: 3
118
- summary: Fluentd Output plugin to make a call with Twilio VoIP API. Twiml supports
113
+ specification_version: 4
114
+ summary: Fluentd Output plugin to make a phone call with Twilio VoIP API. Twiml supports
119
115
  text-to-speech with many languages ref. https://www.twilio.com/docs/api/twiml/say
120
116
  test_files:
121
117
  - test/helper.rb