module ExTwitter::ExistingApi

Public Instance Methods

favorites(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 111
def favorites(*args)
  options = {count: 100, call_count: 1}.merge(args.extract_options!)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_max_id("old_#{__method__}", *args, options)
  }
end
follower_ids(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 41
def follower_ids(*args)
  options = {count: 5000, cursor: -1}.merge(args.extract_options!)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_cursor("old_#{__method__}", *args, options)
  }
end
followers(*args) click to toggle source

specify reduce: false to use tweet for inactive_*

# File lib/ex_twitter/existing_api.rb, line 60
def followers(*args)
  options = {count: 200, include_user_entities: true, cursor: -1}.merge(args.extract_options!)
  options[:reduce] = false unless options.has_key?(:reduce)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_cursor("old_#{__method__}", *args, options)
  }
end
friend_ids(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 33
def friend_ids(*args)
  options = {count: 5000, cursor: -1}.merge(args.extract_options!)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_cursor("old_#{__method__}", *args, options)
  }
end
friends(*args) click to toggle source

specify reduce: false to use tweet for inactive_*

# File lib/ex_twitter/existing_api.rb, line 50
def friends(*args)
  options = {count: 200, include_user_entities: true, cursor: -1}.merge(args.extract_options!)
  options[:reduce] = false unless options.has_key?(:reduce)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_cursor("old_#{__method__}", *args, options)
  }
end
friendship?(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 10
def friendship?(*args)
  options = args.extract_options!
  fetch_cache_or_call_api(__method__, args) {
    call_old_method("old_#{__method__}", *args, options)
  }
end
home_timeline(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 89
def home_timeline(*args)
  options = {count: 200, include_rts: true, call_limit: 3}.merge(args.extract_options!)
  fetch_cache_or_call_api(__method__, user.id, options) {
    collect_with_max_id("old_#{__method__}", options)
  }
end
mentions_timeline(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 104
def mentions_timeline(*args)
  options = {count: 200, include_rts: true, call_limit: 1}.merge(args.extract_options!)
  fetch_cache_or_call_api(__method__, user.id, options) {
    collect_with_max_id("old_#{__method__}", options)
  }
end
user(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 25
def user(*args)
  options = args.extract_options!
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    call_old_method("old_#{__method__}", args[0], options)
  }
end
user?(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 17
def user?(*args)
  options = args.extract_options!
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    call_old_method("old_#{__method__}", args[0], options)
  }
end
user_timeline(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 96
def user_timeline(*args)
  options = {count: 200, include_rts: true, call_limit: 3}.merge(args.extract_options!)
  args[0] = verify_credentials(skip_status: true).id if args.empty?
  fetch_cache_or_call_api(__method__, args[0], options) {
    collect_with_max_id("old_#{__method__}", *args, options)
  }
end
users(*args) click to toggle source

use compact, not use sort and uniq specify reduce: false to use tweet for inactive_* TODO Perhaps `old_users` automatically merges result…

# File lib/ex_twitter/existing_api.rb, line 72
def users(*args)
  options = args.extract_options!
  options[:reduce] = false
  users_per_workers = args.first.compact.each_slice(100).to_a
  processed_users = []

  Parallel.each_with_index(users_per_workers, in_threads: [users_per_workers.size, 10].min) do |users_per_worker, i|
    _users = fetch_cache_or_call_api(__method__, users_per_worker, options) {
      call_old_method("old_#{__method__}", users_per_worker, options)
    }

    processed_users << {i: i, users: _users}
  end

  processed_users.sort_by{|p| p[:i] }.map{|p| p[:users] }.flatten.compact
end
verify_credentials(*args) click to toggle source
# File lib/ex_twitter/existing_api.rb, line 3
def verify_credentials(*args)
  options = {skip_status: true}.merge(args.extract_options!)
  fetch_cache_or_call_api(__method__, args) {
    call_old_method("old_#{__method__}", *args, options)
  }
end