Class: Fluent::Plugin::TwitterOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::TwitterOutput
- Defined in:
- lib/fluent/plugin/out_twitter.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ TwitterOutput
constructor
A new instance of TwitterOutput.
- #process(tag, es) ⇒ Object
- #tweet(message) ⇒ Object
Constructor Details
#initialize ⇒ TwitterOutput
Returns a new instance of TwitterOutput.
19 20 21 |
# File 'lib/fluent/plugin/out_twitter.rb', line 19 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fluent/plugin/out_twitter.rb', line 23 def configure(conf) super @twitter = Twitter::REST::Client.new do |config| config.consumer_key = @consumer_key config.consumer_secret = @consumer_secret config.access_token = @access_token config.access_token_secret = @access_token_secret config.proxy = @proxy.to_h if @proxy end end |
#process(tag, es) ⇒ Object
35 36 37 38 39 |
# File 'lib/fluent/plugin/out_twitter.rb', line 35 def process(tag, es) es.each do |_time, record| tweet(record['message']) end end |
#tweet(message) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/out_twitter.rb', line 41 def tweet() begin @twitter.update() rescue Twitter::Error => e log.error("Twitter Error: #{e.}") end end |