Skip to content

Commit

Permalink
Drop support for Ruby 1.8 and 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Dec 6, 2016
1 parent d12c128 commit 27980f4
Show file tree
Hide file tree
Showing 96 changed files with 1,335 additions and 1,375 deletions.
11 changes: 1 addition & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Max: 33
Max: 36

Metrics/BlockNesting:
Max: 2
Expand Down Expand Up @@ -41,21 +41,12 @@ Style/DotPosition:
Style/DoubleNegation:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/Encoding:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/Lambda:
Enabled: false

Style/RaiseArgs:
EnforcedStyle: compact

Expand Down
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
before_install:
- gem update bundler

cache: bundler

language: ruby

rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3.3
- jruby-18mode
- jruby-19mode
- jruby-9.1.6.0
- jruby-head
- rbx-2
- ruby-head
Expand Down
19 changes: 5 additions & 14 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
source 'https://rubygems.org'

gem 'addressable', '~> 2.3.8', :platforms => [:jruby, :ruby_18]
gem 'jruby-openssl', :platforms => :jruby
gem 'rake', '~> 10.5.0'
gem 'jruby-openssl', platforms: :jruby
gem 'rake'
gem 'yard'

group :development do
gem 'pry'
platforms :ruby_19, :ruby_20, :ruby_21 do
gem 'pry-stack_explorer'
gem 'redcarpet'
end
end

group :test do
gem 'backports'
gem 'coveralls'
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
gem 'rspec', '>= 2.14'
gem 'rubocop', '>= 0.46', :platforms => [:ruby_20, :ruby_21, :ruby_22, :ruby_23]
gem 'rubocop', '>= 0.46'
gem 'simplecov', '>= 0.9'
gem 'timecop', '0.6.1'
gem 'tins', '~> 1.6.0'
gem 'webmock', '~> 1.24.6'
gem 'timecop'
gem 'webmock'
gem 'yardstick'
end

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,11 @@ command:
This library aims to support and is [tested against][travis] the following Ruby
versions:
* Ruby 1.8.7
* Ruby 1.9.3
* Ruby 2.0.0
* Ruby 2.1
* Ruby 2.2
* JRuby 1.7 (Both 1.9 mode and 1.8 mode)
* Ruby 2.3
* JRuby 9.1.6.0
If something doesn't work on one of these versions, it's a bug.
Expand Down
16 changes: 5 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :test => :spec

begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
rescue LoadError
task :rubocop do
$stderr.puts 'Rubocop is disabled'
end
end
task test: :spec

require 'rubocop/rake_task'
RuboCop::RakeTask.new

require 'yard'
YARD::Rake::YardocTask.new
Expand All @@ -34,4 +28,4 @@ Yardstick::Rake::Verify.new do |verify|
verify.threshold = 59.3
end

task :default => [:spec, :rubocop, :verify_measurements]
task default: [:spec, :rubocop, :verify_measurements]
Binary file added etc/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def display_uri_attr_reader
# @param key1 [Symbol]
# @param key2 [Symbol]
def define_uri_method(key1, key2)
define_method(key1) do ||
define_method(key1) do
Addressable::URI.parse(@attrs[key2].chomp('#')) unless @attrs[key2].nil?
end
memoize(key1)
Expand All @@ -84,7 +84,7 @@ def define_uri_method(key1, key2)
# @param klass [Symbol]
# @param key2 [Symbol]
def define_attribute_method(key1, klass = nil, key2 = nil)
define_method(key1) do ||
define_method(key1) do
if attr_falsey_or_empty?(key1)
NullObject.new
elsif klass.nil?
Expand All @@ -99,7 +99,7 @@ def define_attribute_method(key1, klass = nil, key2 = nil)

# @param key [Symbol]
def deprecate_attribute_method(key)
define_method(key) do ||
define_method(key) do
warn "#{Kernel.caller.first}: [DEPRECATION] ##{key} is deprecated. Use ##{key}? instead."
@attrs[key]
end
Expand All @@ -111,7 +111,7 @@ def deprecate_attribute_method(key)
# @param key1 [Symbol]
# @param key2 [Symbol]
def define_predicate_method(key1, key2 = key1)
define_method(:"#{key1}?") do ||
define_method(:"#{key1}?") do
!attr_falsey_or_empty?(key2)
end
memoize(:"#{key1}?")
Expand Down
10 changes: 5 additions & 5 deletions lib/twitter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def user_agent
# @return [Hash]
def credentials
{
:consumer_key => consumer_key,
:consumer_secret => consumer_secret,
:token => access_token,
:token_secret => access_token_secret,
:ignore_extra_keys => true,
consumer_key: consumer_key,
consumer_secret: consumer_secret,
token: access_token,
token_secret: access_token_secret,
ignore_extra_keys: true,
}
end

Expand Down
3 changes: 1 addition & 2 deletions lib/twitter/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class Configuration < Twitter::Base
#
# @return [Array<Twitter::Size>]
def photo_sizes
@attrs.fetch(:photo_sizes, []).inject({}) do |object, (key, value)|
@attrs.fetch(:photo_sizes, []).each_with_object({}) do |(key, value), object|
object[key] = Size.new(value)
object
end
end
memoize :photo_sizes
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def last?

# @return [Hash]
def fetch_next_page
response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(:cursor => next_cursor)).perform
response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(cursor: next_cursor)).perform
self.attrs = response
end

Expand Down
7 changes: 1 addition & 6 deletions lib/twitter/headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ def bearer_auth_header
#
# @return [String]
def bearer_token_credentials_auth_header
basic_auth_token = strict_encode64("#{@client.consumer_key}:#{@client.consumer_secret}")
basic_auth_token = Base64.strict_encode64("#{@client.consumer_key}:#{@client.consumer_secret}")
"Basic #{basic_auth_token}"
end

# Base64.strict_encode64 is not available on Ruby 1.8.7
def strict_encode64(str)
Base64.encode64(str).delete("\n")
end
end
end
3 changes: 1 addition & 2 deletions lib/twitter/media/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ class Photo < Twitter::Identity
#
# @return [Array<Twitter::Size>]
def sizes
@attrs.fetch(:sizes, []).inject({}) do |object, (key, value)|
@attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
object[key] = Size.new(value)
object
end
end
memoize :sizes
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/media/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Video < Twitter::Identity
#
# @return [Array<Twitter::Size>]
def sizes
@attrs.fetch(:sizes, []).inject({}) do |object, (key, value)|
@attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
object[key] = Size.new(value)
object
end
Expand Down
7 changes: 3 additions & 4 deletions lib/twitter/null_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ module Twitter
config.define_implicit_conversions
config.predicates_return false

# TODO: Add when support for Ruby 1.8.7 is dropped
# def !
# true
# end
def !
true
end

def respond_to?(*)
true
Expand Down
3 changes: 1 addition & 2 deletions lib/twitter/profile_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class ProfileBanner < Twitter::Base
#
# @return [Array<Twitter::Size>]
def sizes
@attrs.fetch(:sizes, []).inject({}) do |object, (key, value)|
@attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
object[key] = Size.new(value)
object
end
end
memoize :sizes
Expand Down
16 changes: 8 additions & 8 deletions lib/twitter/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ def connection_options=(connection_options)
# @return [Hash]
def connection_options
@connection_options ||= {
:builder => middleware,
:headers => {
:accept => 'application/json',
:user_agent => user_agent,
builder: middleware,
headers: {
accept: 'application/json',
user_agent: user_agent,
},
:request => {
:open_timeout => 10,
:timeout => 30,
request: {
open_timeout: 10,
timeout: 30,
},
:proxy => proxy,
proxy: proxy,
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/rest/favorites.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def favorite(*args)
arguments = Twitter::Arguments.new(args)
pmap(arguments) do |tweet|
begin
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
next
end
Expand All @@ -96,7 +96,7 @@ def favorite(*args)
def favorite!(*args)
arguments = Twitter::Arguments.new(args)
pmap(arguments) do |tweet|
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(:id => extract_id(tweet)), Twitter::Tweet)
perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
end
end
alias create_favorite! favorite!
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def list_update(*args)
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
# @option options [String] :description The description to give the list.
def create_list(name, options = {})
perform_post_with_object('/1.1/lists/create.json', options.merge(:name => name), Twitter::List)
perform_post_with_object('/1.1/lists/create.json', options.merge(name: name), Twitter::List)
end
deprecate_alias :list_create, :create_list

Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def reverse_token
conn = connection.dup
conn.builder.swap(4, Twitter::REST::Response::ParseErrorJson)
response = conn.post('/oauth/request_token?x_auth_mode=reverse_auth') do |request|
request.headers[:authorization] = Twitter::Headers.new(self, :post, 'https://api.twitter.com/oauth/request_token', :x_auth_mode => 'reverse_auth').oauth_auth_header.to_s
request.headers[:authorization] = Twitter::Headers.new(self, :post, 'https://api.twitter.com/oauth/request_token', x_auth_mode: 'reverse_auth').oauth_auth_header.to_s
end
response.body
end
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/request/multipart_with_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def mime_type(path)
end
end

Faraday::Request.register_middleware :twitter_multipart_with_file => Twitter::REST::Request::MultipartWithFile
Faraday::Request.register_middleware twitter_multipart_with_file: Twitter::REST::Request::MultipartWithFile
4 changes: 2 additions & 2 deletions lib/twitter/rest/response/parse_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def parse(body)
when WHITESPACE_REGEX, nil
nil
else
JSON.parse(body, :symbolize_names => true)
JSON.parse(body, symbolize_names: true)
end
end

Expand All @@ -28,4 +28,4 @@ def unparsable_status_codes
end
end

Faraday::Response.register_middleware :twitter_parse_json => Twitter::REST::Response::ParseJson
Faraday::Response.register_middleware twitter_parse_json: Twitter::REST::Response::ParseJson
2 changes: 1 addition & 1 deletion lib/twitter/rest/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def handle_forbidden_errors(response)
end
end

Faraday::Response.register_middleware :twitter_raise_error => Twitter::REST::Response::RaiseError
Faraday::Response.register_middleware twitter_raise_error: Twitter::REST::Response::RaiseError
2 changes: 1 addition & 1 deletion lib/twitter/rest/saved_searches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def saved_search(id, options = {})
# @param query [String] The query of the search the user would like to save.
# @param options [Hash] A customizable set of options.
def create_saved_search(query, options = {})
perform_post_with_object('/1.1/saved_searches/create.json', options.merge(:query => query), Twitter::SavedSearch)
perform_post_with_object('/1.1/saved_searches/create.json', options.merge(query: query), Twitter::SavedSearch)
end
deprecate_alias :saved_search_create, :create_saved_search

Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Search
# @return [Twitter::SearchResults] Return tweets that match a specified query with search metadata
def search(q, options = {})
options[:count] ||= MAX_TWEETS_PER_REQUEST
request = Twitter::REST::Request.new(self, :get, '/1.1/search/tweets.json', options.merge(:q => q))
request = Twitter::REST::Request.new(self, :get, '/1.1/search/tweets.json', options.merge(q: q))
Twitter::SearchResults.new(request)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/rest/tweets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def status(tweet, options = {})
def statuses(*args)
arguments = Twitter::Arguments.new(args)
flat_pmap(arguments.each_slice(MAX_TWEETS_PER_REQUEST)) do |tweets|
perform_post_with_objects('/1.1/statuses/lookup.json', arguments.options.merge(:id => tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
perform_post_with_objects('/1.1/statuses/lookup.json', arguments.options.merge(id: tweets.collect { |u| extract_id(u) }.join(',')), Twitter::Tweet)
end
end

Expand Down Expand Up @@ -127,7 +127,7 @@ def destroy_status(*args)
def update(status, options = {})
update!(status, options)
rescue Twitter::Error::DuplicateStatus
user_timeline(:count => 1).first
user_timeline(count: 1).first
end

# Updates the authenticating user's status
Expand Down Expand Up @@ -155,7 +155,7 @@ def update!(status, options = {})
hash = options.dup
hash[:in_reply_to_status_id] = hash.delete(:in_reply_to_status).id unless hash[:in_reply_to_status].nil?
hash[:place_id] = hash.delete(:place).woeid unless hash[:place].nil?
perform_post_with_object('/1.1/statuses/update.json', hash.merge(:status => status), Twitter::Tweet)
perform_post_with_object('/1.1/statuses/update.json', hash.merge(status: status), Twitter::Tweet)
end

# Retweets the specified Tweets as the authenticating user
Expand Down
Loading

0 comments on commit 27980f4

Please sign in to comment.