class Fluent::TwittersearchInput

Attributes

twitter[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_twittersearch.rb, line 19
def initialize
    super
    require "twitter"
end

Public Instance Methods

configure(config) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_twittersearch.rb, line 24
def configure(config)
    super
    Twitter.configure do |cnf|   
        cnf.consumer_key    = @consumer_key
        cnf.consumer_secret = @consumer_secret
    end
    @twitter = Twitter::Client.new(
                                     :oauth_token => @oauth_token,
                                     :oauth_token_secret => @oauth_token_secret
                                    )
    raise Fluent::ConfigError.new if @keyword.nil? and @hashtag.nil?
end
run() click to toggle source
# File lib/fluent/plugin/in_twittersearch.rb, line 64
def run
    loop do
        search.each do |tweet|
            Engine.emit @tag,Engine.now,tweet
        end
        sleep @run_interval
    end
end
shutdown() click to toggle source
# File lib/fluent/plugin/in_twittersearch.rb, line 73
def shutdown
    Thread.kill(@thread)
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_twittersearch.rb, line 37
def start
    super
    @thread = Thread.new(&method(:run))
end