Permalink
Browse files

removed Client#on_interval, fix for #75

  • Loading branch information...
1 parent 758bc75 commit 7ba5425c6c4369c537c25fce6dd5f1aaf6e5b6c4 @stve stve committed May 12, 2012
Showing with 0 additions and 48 deletions.
  1. +0 −28 lib/tweetstream/client.rb
  2. +0 −3 lib/tweetstream/configuration.rb
  3. +0 −17 spec/tweetstream/client_spec.rb
View
@@ -24,7 +24,6 @@ class Client
# @private
attr_accessor *Configuration::VALID_OPTIONS_KEYS
- attr_accessor :timer
# Creates a new API
def initialize(options={})
@@ -301,24 +300,6 @@ def on_inited(&block)
end
end
- # Set a Proc to be run on a regular interval
- # independent of timeline status updates
- #
- # @client = TweetStream::Client.new
- # @client.on_interval(20) do
- # # do something every 20 seconds
- # end
- #
- def on_interval(time_interval=nil, &block)
- if block_given?
- @on_interval_time = time_interval
- @on_interval_proc = block
- self
- else
- [@on_interval_time, @on_interval_proc]
- end
- end
-
# connect to twitter while starting a new EventMachine run loop
def start(path, query_parameters = {}, &block)
if EventMachine.reactor_running?
@@ -362,15 +343,6 @@ def connect(path, query_parameters = {}, &block)
:ssl => true
}.merge(auth_params).merge(extra_stream_parameters)
- if @on_interval_proc.is_a?(Proc)
- interval = @on_interval_time || Configuration::DEFAULT_TIMER_INTERVAL
- @timer = EventMachine.add_periodic_timer(interval) do
- EventMachine.defer do
- @on_interval_proc.call
- end
- end
- end
-
@stream = Twitter::JSONStream.connect(stream_params)
@stream.each_item do |item|
begin
@@ -44,9 +44,6 @@ module Configuration
# By default, don't set a user oauth secret
DEFAULT_OAUTH_TOKEN_SECRET = nil
- # Default time interval for use with on_interval
- DEFAULT_TIMER_INTERVAL = 30
-
# @private
attr_accessor *VALID_OPTIONS_KEYS
@@ -334,23 +334,6 @@
end
end
- describe '#on_interval' do
- it 'should set when a block is given' do
- @client.on_interval(5) { puts 'hi' }
- @client.on_interval[0].should == 5
- @client.on_interval[1].should be_kind_of(Proc)
- end
-
- it 'should should create a periodic timer' do
- # need to figure out a better way to test this
- # for now, using on_inited to stop the reactor
- proc = Proc.new{ puts 'hi' }
- EM.should_receive(:add_periodic_timer).once.with(5)
- @client.on_inited { EM.stop }.on_interval(5, &proc)
- @client.track('go')
- end
- end
-
describe '#stop' do
it 'should call EventMachine::stop_event_loop' do
EventMachine.should_receive :stop_event_loop

0 comments on commit 7ba5425

Please sign in to comment.