Permalink
Browse files

Add Twitter::Utils#flat_pmap

  • Loading branch information...
1 parent dfe7b1d commit ee40768bcfb0cd788dadce0451e50e099e3733fd @sferik committed Mar 1, 2014
Showing with 15 additions and 4 deletions.
  1. +1 −1 Rakefile
  2. +2 −2 lib/twitter/rest/users.rb
  3. +11 −0 lib/twitter/utils.rb
  4. +1 −1 spec/helper.rb
View
@@ -31,7 +31,7 @@ end
require 'yardstick/rake/verify'
Yardstick::Rake::Verify.new do |verify|
- verify.threshold = 59.6
+ verify.threshold = 59.5
end
task :default => [:spec, :rubocop, :verify_measurements]
@@ -227,9 +227,9 @@ def unblock(*args)
def users(*args)
arguments = Twitter::Arguments.new(args)
request_method = arguments.options.delete(:method) || :post
- pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
+ flat_pmap(arguments.each_slice(MAX_USERS_PER_REQUEST)) do |users|
perform_with_objects(request_method, '/1.1/users/lookup.json', merge_users(arguments.options, users), Twitter::User)
- end.flatten
+ end
end
# @see https://dev.twitter.com/docs/api/1.1/get/users/show
View
@@ -15,6 +15,17 @@ def deprecate_alias(new_name, old_name)
end
end
+ # Returns a new array with the concatenated results of running block once for every element in enumerable.
+ # If no block is given, an enumerator is returned instead.
+ #
+ # @param enumerable [Enumerable]
+ # @return [Array, Enumerator]
+ def flat_pmap(enumerable, &block)
+ return to_enum(:flat_pmap, enumerable) unless block_given?
+ pmap(enumerable, &block).flatten(1)
+ end
+ module_function :flat_pmap
+
# Returns a new array with the results of running block once for every element in enumerable.
# If no block is given, an enumerator is returned instead.
#
View
@@ -8,7 +8,7 @@
SimpleCov.start do
add_filter '/spec/'
- minimum_coverage(99.39)
+ minimum_coverage(99.4)
end
require 'twitter'

0 comments on commit ee40768

Please sign in to comment.