Skip to content

Commit

Permalink
Merge c40af13 into 27c5f41
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderadam committed Jan 1, 2017
2 parents 27c5f41 + c40af13 commit ccdfb8c
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 40 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ Style/RaiseArgs:
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Style/TrailingComma:
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: 'comma'

Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: 'comma'
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
bundler_args: --without development
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3
- 2.4.0
- rbx-2
- ruby-head
matrix:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
group :test do
gem 'coveralls'
gem 'rspec', '>= 3'
gem 'rubocop', '>= 0.32.1'
gem 'rubocop', '~> 0.46.0'
gem 'simplecov', '>= 0.9'
gem 'webmock'
end
Expand Down
2 changes: 1 addition & 1 deletion examples/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
end

client.track('yankees') do |status|
puts "#{status.text}"
puts status.text.to_s
end
2 changes: 1 addition & 1 deletion lib/tweetstream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def method_missing(method, *args, &block)
end

# Delegate to TweetStream::Client
def respond_to?(method, include_private = false)
def respond_to_missing?(method, include_private = false)
new.respond_to?(method, include_private) || super(method, include_private)
end
end
Expand Down
38 changes: 20 additions & 18 deletions lib/tweetstream/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ module TweetStream
class Client # rubocop:disable ClassLength
extend Forwardable

OPTION_CALLBACKS = [:close,
:delete,
:scrub_geo,
:limit,
:error,
:enhance_your_calm,
:unauthorized,
:reconnect,
:inited,
:direct_message,
:timeline_status,
:anything,
:no_data_received,
:status_withheld,
:user_withheld].freeze unless defined?(OPTION_CALLBACKS)
unless defined?(OPTION_CALLBACKS)
OPTION_CALLBACKS = [:close,
:delete,
:scrub_geo,
:limit,
:error,
:enhance_your_calm,
:unauthorized,
:reconnect,
:inited,
:direct_message,
:timeline_status,
:anything,
:no_data_received,
:status_withheld,
:user_withheld].freeze
end

# @private
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
Expand Down Expand Up @@ -140,7 +142,7 @@ def filter(query_params = {}, &block)
# Make a call to the userstream api for currently authenticated user
def userstream(query_params = {}, &block)
stream_params = {:host => 'userstream.twitter.com'}
query_params.merge!(:extra_stream_parameters => stream_params)
query_params[:extra_stream_parameters] = stream_params
start('/1.1/user.json', query_params, &block)
end

Expand All @@ -152,7 +154,7 @@ def sitestream(user_ids = [], query_params = {}, &block)
:follow => user_ids,
:extra_stream_parameters => stream_params,
)
query_params.merge!(:with => 'followings') if query_params.delete(:followings)
query_params[:with] = 'followings' if query_params.delete(:followings)
start('/1.1/site.json', query_params, &block)
end

Expand Down Expand Up @@ -466,7 +468,7 @@ def connect(path, options = {}, &block)
end

@stream.on_max_reconnects do |timeout, retries|
fail TweetStream::ReconnectError.new(timeout, retries)
raise TweetStream::ReconnectError.new(timeout, retries)
end

@stream.on_no_data_received { invoke_callback(callbacks['no_data_received']) }
Expand Down
9 changes: 6 additions & 3 deletions lib/tweetstream/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ module Configuration
:consumer_key,
:consumer_secret,
:oauth_token,
:oauth_token_secret].freeze
:oauth_token_secret,
].freeze

OAUTH_OPTIONS_KEYS = [
:consumer_key,
:consumer_secret,
:oauth_token,
:oauth_token_secret].freeze
:oauth_token_secret,
].freeze

# By default, don't set a username
DEFAULT_USERNAME = nil
Expand All @@ -38,7 +40,8 @@ module Configuration

VALID_FORMATS = [
:basic,
:oauth].freeze
:oauth,
].freeze

# By default, don't set an application key
DEFAULT_CONSUMER_KEY = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/tweetstream/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
module TweetStream
class Daemon < TweetStream::Client
DEFAULT_NAME = 'tweetstream'.freeze
DEFAULT_OPTIONS = {:multiple => true}
DEFAULT_OPTIONS = {:multiple => true}.freeze

attr_accessor :app_name, :daemon_options

Expand Down
6 changes: 3 additions & 3 deletions lib/tweetstream/site_stream_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def request(method, path, options, &block) # rubocop:disable CyclomaticComplexit
http = connection.send(method, options.merge(:path => path))
http.callback do
if http.response_header.status == 200 && block && block.is_a?(Proc)
block.arity == 1 ? block.call(http.response) : block.call
else
@on_error.call(error_msg) if @on_error && @on_error.is_a?(Proc)
block.arity == 1 ? yield(http.response) : yield
elsif @on_error && @on_error.is_a?(Proc)
@on_error.call(error_msg)
end
end
http.errback do
Expand Down
2 changes: 1 addition & 1 deletion lib/tweetstream/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TweetStream
VERSION = '2.6.1'
VERSION = '2.6.1'.freeze
end
6 changes: 2 additions & 4 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def fixture(file)
end

FakeHttp = Class.new do
def callback
end
def callback; end

def errback
end
def errback; end
end
3 changes: 1 addition & 2 deletions spec/tweetstream/client_site_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
@control_response = {'control' =>
{
'control_uri' => '/1.1/site/c/01_225167_334389048B872A533002B34D73F8C29FD09EFC50',
},
}
}}
end
it 'assigns the control_uri' do
expect(@stream).to receive(:each).and_yield(@control_response.to_json)
Expand Down
4 changes: 2 additions & 2 deletions tweetstream.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Gem::Specification.new do |spec|
spec.add_dependency 'daemons', '~> 1.1'
spec.add_dependency 'em-http-request', '>= 1.1.1'
spec.add_dependency 'em-twitter', '~> 0.3'
spec.add_dependency 'twitter', '~> 5.12'
spec.add_dependency 'twitter', '~> 6.0'
spec.add_dependency 'multi_json', '~> 1.3'
spec.add_development_dependency 'bundler', '~> 1.0'

spec.files = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md tweetstream.gemspec) + Dir['lib/**/*.rb']

spec.require_paths = ['lib']
spec.required_ruby_version = '>= 1.9.3'
spec.required_ruby_version = '>= 2.1.0'
end

0 comments on commit ccdfb8c

Please sign in to comment.