twitter 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +10 -0
- data/CHANGELOG.md +123 -110
- data/CONTRIBUTING.md +51 -0
- data/README.md +17 -2
- data/lib/twitter/api/direct_messages.rb +3 -6
- data/lib/twitter/api/favorites.rb +6 -13
- data/lib/twitter/api/friends_and_followers.rb +76 -8
- data/lib/twitter/api/lists.rb +65 -36
- data/lib/twitter/api/places_and_geo.rb +3 -3
- data/lib/twitter/api/saved_searches.rb +2 -2
- data/lib/twitter/api/spam_reporting.rb +2 -2
- data/lib/twitter/api/suggested_users.rb +1 -1
- data/lib/twitter/api/timelines.rb +12 -8
- data/lib/twitter/api/tweets.rb +8 -12
- data/lib/twitter/api/undocumented.rb +3 -3
- data/lib/twitter/api/users.rb +16 -10
- data/lib/twitter/api/utils.rb +109 -30
- data/lib/twitter/base.rb +15 -5
- data/lib/twitter/basic_user.rb +0 -1
- data/lib/twitter/client.rb +16 -37
- data/lib/twitter/core_ext/enumerable.rb +2 -2
- data/lib/twitter/default.rb +5 -8
- data/lib/twitter/exceptable.rb +36 -0
- data/lib/twitter/factory.rb +4 -4
- data/lib/twitter/list.rb +0 -1
- data/lib/twitter/request/multipart_with_file.rb +5 -7
- data/lib/twitter/search_results.rb +10 -6
- data/lib/twitter/settings.rb +0 -1
- data/lib/twitter/source_user.rb +0 -7
- data/lib/twitter/target_user.rb +0 -1
- data/lib/twitter/tweet.rb +15 -17
- data/lib/twitter/user.rb +4 -14
- data/lib/twitter/version.rb +4 -4
- data/spec/fixtures/followers_list.json +1 -0
- data/spec/fixtures/friends_list.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/helper.rb +9 -8
- data/spec/twitter/action_factory_spec.rb +1 -1
- data/spec/twitter/api/favorites_spec.rb +2 -2
- data/spec/twitter/api/friends_and_followers_spec.rb +102 -2
- data/spec/twitter/api/spam_reporting_spec.rb +2 -2
- data/spec/twitter/api/tweets_spec.rb +2 -2
- data/spec/twitter/api/users_spec.rb +107 -49
- data/spec/twitter/base_spec.rb +1 -1
- data/spec/twitter/client_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +2 -2
- data/spec/twitter/error/client_error_spec.rb +16 -5
- data/spec/twitter/error/server_error_spec.rb +1 -1
- data/spec/twitter/error_spec.rb +2 -2
- data/spec/twitter/geo_factory_spec.rb +1 -1
- data/spec/twitter/identifiable_spec.rb +2 -2
- data/spec/twitter/media_factory_spec.rb +1 -1
- data/spec/twitter/search_results_spec.rb +11 -0
- data/spec/twitter/tweet_spec.rb +11 -0
- data/twitter.gemspec +3 -2
- metadata +190 -173
- data/lib/twitter/core_ext/array.rb +0 -7
- data/lib/twitter/core_ext/hash.rb +0 -100
- data/lib/twitter/core_ext/string.rb +0 -10
    
        data/CONTRIBUTING.md
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            ## Contributing
         | 
| 2 | 
            +
            In the spirit of [free software][free-sw], **everyone** is encouraged to help
         | 
| 3 | 
            +
            improve this project.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Here are some ways *you* can contribute:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            * by using alpha, beta, and prerelease versions
         | 
| 10 | 
            +
            * by reporting bugs
         | 
| 11 | 
            +
            * by suggesting new features
         | 
| 12 | 
            +
            * by writing or editing documentation
         | 
| 13 | 
            +
            * by writing specifications
         | 
| 14 | 
            +
            * by writing code (**no patch is too small**: fix typos, add comments, clean up
         | 
| 15 | 
            +
            inconsistent whitespace)
         | 
| 16 | 
            +
            * by refactoring code
         | 
| 17 | 
            +
            * by fixing [issues][]
         | 
| 18 | 
            +
            * by reviewing patches
         | 
| 19 | 
            +
            * [financially][pledgie]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            [issues]: https://github.com/sferik/twitter/issues
         | 
| 22 | 
            +
            [pledgie]: http://pledgie.com/campaigns/18388
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ## Submitting an Issue
         | 
| 25 | 
            +
            We use the [GitHub issue tracker][issues] to track bugs and features. Before
         | 
| 26 | 
            +
            submitting a bug report or feature request, check to make sure it hasn't
         | 
| 27 | 
            +
            already been submitted. When submitting a bug report, please include a [Gist][]
         | 
| 28 | 
            +
            that includes a stack trace and any details that may be necessary to reproduce
         | 
| 29 | 
            +
            the bug, including your gem version, Ruby version, and operating system.
         | 
| 30 | 
            +
            Ideally, a bug report should include a pull request with failing specs.
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            [gist]: https://gist.github.com/
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ## Submitting a Pull Request
         | 
| 35 | 
            +
            1. [Fork the repository.][fork]
         | 
| 36 | 
            +
            2. [Create a topic branch.][branch]
         | 
| 37 | 
            +
            3. Add specs for your unimplemented feature or bug fix.
         | 
| 38 | 
            +
            4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
         | 
| 39 | 
            +
            5. Implement your feature or bug fix.
         | 
| 40 | 
            +
            6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
         | 
| 41 | 
            +
            7. Run `open coverage/index.html`. If your changes are not completely covered
         | 
| 42 | 
            +
               by your tests, return to step 3.
         | 
| 43 | 
            +
            8. Add documentation for your feature or bug fix.
         | 
| 44 | 
            +
            9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
         | 
| 45 | 
            +
               back to step 8.
         | 
| 46 | 
            +
            10. Add, commit, and push your changes.
         | 
| 47 | 
            +
            11. [Submit a pull request.][pr]
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            [fork]: http://help.github.com/fork-a-repo/
         | 
| 50 | 
            +
            [branch]: http://learn.github.com/p/branching.html
         | 
| 51 | 
            +
            [pr]: http://help.github.com/send-pull-requests/
         | 
    
        data/README.md
    CHANGED
    
    | @@ -302,6 +302,20 @@ Twitter.follow(213747670) | |
| 302 302 | 
             
            Twitter.user("gem")
         | 
| 303 303 | 
             
            Twitter.user(213747670)
         | 
| 304 304 | 
             
            ```
         | 
| 305 | 
            +
            **Fetch a cursored list of followers with profile details (by screen name or user ID, or by implict authenticated user)**
         | 
| 306 | 
            +
             | 
| 307 | 
            +
            ```ruby
         | 
| 308 | 
            +
            Twitter.followers("gem")
         | 
| 309 | 
            +
            Twitter.followers(213747670)
         | 
| 310 | 
            +
            Twitter.followers
         | 
| 311 | 
            +
            ```
         | 
| 312 | 
            +
            **Fetch a cursored list of friends with profile details (by screen name or user ID, or by implict authenticated user)**
         | 
| 313 | 
            +
             | 
| 314 | 
            +
            ```ruby
         | 
| 315 | 
            +
            Twitter.friends("gem")
         | 
| 316 | 
            +
            Twitter.friends(213747670)
         | 
| 317 | 
            +
            Twitter.friends
         | 
| 318 | 
            +
            ```
         | 
| 305 319 | 
             
            **Fetch the timeline of Tweets by a user**
         | 
| 306 320 |  | 
| 307 321 | 
             
            ```ruby
         | 
| @@ -357,10 +371,11 @@ Here are some fun facts about this library: | |
| 357 371 |  | 
| 358 372 | 
             
            * It is implemented in just 2,000 lines of Ruby code
         | 
| 359 373 | 
             
            * With over 4,000 lines of specs, the spec-to-code ratio is over 2:1
         | 
| 360 | 
            -
            * The spec suite contains  | 
| 374 | 
            +
            * The spec suite contains 700 examples and runs in about 2 seconds
         | 
| 361 375 | 
             
            * It has 100% C0 code coverage (the tests execute every line of
         | 
| 362 376 | 
             
              source code at least once)
         | 
| 363 | 
            -
            * It is comprehensive: you can request all documented Twitter REST API | 
| 377 | 
            +
            * It is comprehensive: you can request all documented Twitter REST API
         | 
| 378 | 
            +
              resources (over 100 resources)
         | 
| 364 379 | 
             
            * This gem works on every major Ruby implementation, including JRuby and
         | 
| 365 380 | 
             
              Rubinius
         | 
| 366 381 | 
             
            * The first version was released on November 26, 2006
         | 
| @@ -92,7 +92,7 @@ module Twitter | |
| 92 92 | 
             
                  #   @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
         | 
| 93 93 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 94 94 | 
             
                  def direct_messages(*args)
         | 
| 95 | 
            -
                    options =  | 
| 95 | 
            +
                    options = extract_options!(args)
         | 
| 96 96 | 
             
                    if args.empty?
         | 
| 97 97 | 
             
                      direct_messages_received(options)
         | 
| 98 98 | 
             
                    else
         | 
| @@ -118,10 +118,7 @@ module Twitter | |
| 118 118 | 
             
                  #   @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
         | 
| 119 119 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 120 120 | 
             
                  def direct_message_destroy(*args)
         | 
| 121 | 
            -
                     | 
| 122 | 
            -
                    args.flatten.threaded_map do |id|
         | 
| 123 | 
            -
                      object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/destroy.json", options.merge(:id => id))
         | 
| 124 | 
            -
                    end
         | 
| 121 | 
            +
                    threaded_object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/destroy.json", args)
         | 
| 125 122 | 
             
                  end
         | 
| 126 123 |  | 
| 127 124 | 
             
                  # Sends a new direct message to the specified user from the authenticating user
         | 
| @@ -138,7 +135,7 @@ module Twitter | |
| 138 135 | 
             
                  #   Twitter.direct_message_create('sferik', "I'm sending you this message via @gem!")
         | 
| 139 136 | 
             
                  #   Twitter.direct_message_create(7505382, "I'm sending you this message via @gem!")  # Same as above
         | 
| 140 137 | 
             
                  def direct_message_create(user, text, options={})
         | 
| 141 | 
            -
                     | 
| 138 | 
            +
                    merge_user!(options, user)
         | 
| 142 139 | 
             
                    options[:text] = text
         | 
| 143 140 | 
             
                    object_from_response(Twitter::DirectMessage, :post, "/1.1/direct_messages/new.json", options)
         | 
| 144 141 | 
             
                  end
         | 
| @@ -32,9 +32,9 @@ module Twitter | |
| 32 32 | 
             
                  #   @example Return the 20 most recent favorite Tweets for @sferik
         | 
| 33 33 | 
             
                  #     Twitter.favorites('sferik')
         | 
| 34 34 | 
             
                  def favorites(*args)
         | 
| 35 | 
            -
                    options =  | 
| 35 | 
            +
                    options = extract_options!(args)
         | 
| 36 36 | 
             
                    if user = args.pop
         | 
| 37 | 
            -
                       | 
| 37 | 
            +
                      merge_user!(options, user)
         | 
| 38 38 | 
             
                    end
         | 
| 39 39 | 
             
                    collection_from_response(Twitter::Tweet, :get, "/1.1/favorites/list.json", options)
         | 
| 40 40 | 
             
                  end
         | 
| @@ -55,10 +55,7 @@ module Twitter | |
| 55 55 | 
             
                  #   @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
         | 
| 56 56 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 57 57 | 
             
                  def unfavorite(*args)
         | 
| 58 | 
            -
                     | 
| 59 | 
            -
                    args.flatten.threaded_map do |id|
         | 
| 60 | 
            -
                      object_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", options.merge(:id => id))
         | 
| 61 | 
            -
                    end
         | 
| 58 | 
            +
                    threaded_object_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", args)
         | 
| 62 59 | 
             
                  end
         | 
| 63 60 | 
             
                  alias favorite_destroy unfavorite
         | 
| 64 61 | 
             
                  alias favourite_destroy unfavorite
         | 
| @@ -79,7 +76,7 @@ module Twitter | |
| 79 76 | 
             
                  #   @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
         | 
| 80 77 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 81 78 | 
             
                  def favorite(*args)
         | 
| 82 | 
            -
                    options =  | 
| 79 | 
            +
                    options = extract_options!(args)
         | 
| 83 80 | 
             
                    args.flatten.threaded_map do |id|
         | 
| 84 81 | 
             
                      begin
         | 
| 85 82 | 
             
                        object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", options.merge(:id => id))
         | 
| @@ -109,16 +106,12 @@ module Twitter | |
| 109 106 | 
             
                  #   @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
         | 
| 110 107 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 111 108 | 
             
                  def favorite!(*args)
         | 
| 112 | 
            -
                    options =  | 
| 109 | 
            +
                    options = extract_options!(args)
         | 
| 113 110 | 
             
                    args.flatten.threaded_map do |id|
         | 
| 114 111 | 
             
                      begin
         | 
| 115 112 | 
             
                        object_from_response(Twitter::Tweet, :post, "/1.1/favorites/create.json", options.merge(:id => id))
         | 
| 116 113 | 
             
                      rescue Twitter::Error::Forbidden => error
         | 
| 117 | 
            -
                         | 
| 118 | 
            -
                          raise Twitter::Error::AlreadyFavorited.new("Tweet with the ID #{id} has already been favorited by the authenticated user.")
         | 
| 119 | 
            -
                        else
         | 
| 120 | 
            -
                          raise
         | 
| 121 | 
            -
                        end
         | 
| 114 | 
            +
                        handle_forbidden_error(Twitter::Error::AlreadyFavorited, error)
         | 
| 122 115 | 
             
                      end
         | 
| 123 116 | 
             
                    end
         | 
| 124 117 | 
             
                  end
         | 
| @@ -76,8 +76,8 @@ module Twitter | |
| 76 76 | 
             
                  #   @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
         | 
| 77 77 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 78 78 | 
             
                  def friendships(*args)
         | 
| 79 | 
            -
                    options =  | 
| 80 | 
            -
                     | 
| 79 | 
            +
                    options = extract_options!(args)
         | 
| 80 | 
            +
                    merge_users!(options, Array(args))
         | 
| 81 81 | 
             
                    collection_from_response(Twitter::User, :get, "/1.1/friendships/lookup.json", options)
         | 
| 82 82 | 
             
                  end
         | 
| 83 83 |  | 
| @@ -129,7 +129,7 @@ module Twitter | |
| 129 129 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 130 130 | 
             
                  #   @option options [Boolean] :follow (false) Enable notifications for the target user.
         | 
| 131 131 | 
             
                  def follow(*args)
         | 
| 132 | 
            -
                    options =  | 
| 132 | 
            +
                    options = extract_options!(args)
         | 
| 133 133 | 
             
                    # Twitter always turns on notifications if the "follow" option is present, even if it's set to false
         | 
| 134 134 | 
             
                    # so only send follow if it's true
         | 
| 135 135 | 
             
                    options[:follow] = true if !!options.delete(:follow)
         | 
| @@ -159,13 +159,13 @@ module Twitter | |
| 159 159 | 
             
                  #   @param options [Hash] A customizable set of options.
         | 
| 160 160 | 
             
                  #   @option options [Boolean] :follow (false) Enable notifications for the target user.
         | 
| 161 161 | 
             
                  def follow!(*args)
         | 
| 162 | 
            -
                    options =  | 
| 162 | 
            +
                    options = extract_options!(args)
         | 
| 163 163 | 
             
                    # Twitter always turns on notifications if the "follow" option is present, even if it's set to false
         | 
| 164 164 | 
             
                    # so only send follow if it's true
         | 
| 165 165 | 
             
                    options[:follow] = true if !!options.delete(:follow)
         | 
| 166 166 | 
             
                    args.flatten.threaded_map do |user|
         | 
| 167 167 | 
             
                      begin
         | 
| 168 | 
            -
                         | 
| 168 | 
            +
                        merge_user!(options, user)
         | 
| 169 169 | 
             
                        object_from_response(Twitter::User, :post, "/1.1/friendships/create.json", options)
         | 
| 170 170 | 
             
                      rescue Twitter::Error::Forbidden
         | 
| 171 171 | 
             
                        # This error will be raised if the user doesn't have permission to
         | 
| @@ -208,7 +208,7 @@ module Twitter | |
| 208 208 | 
             
                  # @example Enable rewteets and devise notifications for @sferik
         | 
| 209 209 | 
             
                  #   Twitter.friendship_update('sferik', :device => true, :retweets => true)
         | 
| 210 210 | 
             
                  def friendship_update(user, options={})
         | 
| 211 | 
            -
                     | 
| 211 | 
            +
                    merge_user!(options, user)
         | 
| 212 212 | 
             
                    object_from_response(Twitter::Relationship, :post, "/1.1/friendships/update.json", options)
         | 
| 213 213 | 
             
                  end
         | 
| 214 214 |  | 
| @@ -227,9 +227,9 @@ module Twitter | |
| 227 227 | 
             
                  #   Twitter.friendship('sferik', 14100886)   # Same as above
         | 
| 228 228 | 
             
                  #   Twitter.friendship(7505382, 14100886)    # Same as above
         | 
| 229 229 | 
             
                  def friendship(source, target, options={})
         | 
| 230 | 
            -
                     | 
| 230 | 
            +
                    merge_user!(options, source, "source")
         | 
| 231 231 | 
             
                    options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
         | 
| 232 | 
            -
                     | 
| 232 | 
            +
                    merge_user!(options, target, "target")
         | 
| 233 233 | 
             
                    options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
         | 
| 234 234 | 
             
                    object_from_response(Twitter::Relationship, :get, "/1.1/friendships/show.json", options)
         | 
| 235 235 | 
             
                  end
         | 
| @@ -254,6 +254,74 @@ module Twitter | |
| 254 254 | 
             
                    friendship(source, target, options).source.following?
         | 
| 255 255 | 
             
                  end
         | 
| 256 256 |  | 
| 257 | 
            +
                  # Returns a cursored collection of user objects for users following the specified user.
         | 
| 258 | 
            +
                  #
         | 
| 259 | 
            +
                  # @see https://dev.twitter.com/docs/api/1.1/get/followers/list
         | 
| 260 | 
            +
                  # @rate_limited Yes
         | 
| 261 | 
            +
                  # @authentication_required Requires user context
         | 
| 262 | 
            +
                  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
         | 
| 263 | 
            +
                  # @return [Twitter::Cursor]
         | 
| 264 | 
            +
                  # @overload friend_ids(options={})
         | 
| 265 | 
            +
                  #   Returns an array of numeric IDs for every user the authenticated user is following
         | 
| 266 | 
            +
                  #
         | 
| 267 | 
            +
                  #   @param options [Hash] A customizable set of options.
         | 
| 268 | 
            +
                  #   @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
         | 
| 269 | 
            +
                  #   @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
         | 
| 270 | 
            +
                  #   @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
         | 
| 271 | 
            +
                  #   @example Return the authenticated user's friends' IDs
         | 
| 272 | 
            +
                  #     Twitter.friend_ids
         | 
| 273 | 
            +
                  # @overload friend_ids(user, options={})
         | 
| 274 | 
            +
                  #   Returns an array of numeric IDs for every user the specified user is following
         | 
| 275 | 
            +
                  #
         | 
| 276 | 
            +
                  #   @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
         | 
| 277 | 
            +
                  #   @param options [Hash] A customizable set of options.
         | 
| 278 | 
            +
                  #   @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
         | 
| 279 | 
            +
                  #   @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
         | 
| 280 | 
            +
                  #   @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
         | 
| 281 | 
            +
                  # @example Return the cursored collection of users following @sferik
         | 
| 282 | 
            +
                  #   Twitter.followers('sferik')
         | 
| 283 | 
            +
                  #   Twitter.followers(7505382)    # Same as above
         | 
| 284 | 
            +
                  def followers(*args)
         | 
| 285 | 
            +
                    options = extract_options!(args)
         | 
| 286 | 
            +
                    merge_user!(options, args.pop || screen_name)
         | 
| 287 | 
            +
                    merge_default_cursor!(options)
         | 
| 288 | 
            +
                    cursor_from_response(:users, Twitter::User, :get, "/1.1/followers/list.json", options)
         | 
| 289 | 
            +
                  end
         | 
| 290 | 
            +
             | 
| 291 | 
            +
                  # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
         | 
| 292 | 
            +
                  #
         | 
| 293 | 
            +
                  # @see https://dev.twitter.com/docs/api/1.1/get/friendships/show
         | 
| 294 | 
            +
                  # @rate_limited Yes
         | 
| 295 | 
            +
                  # @authentication_required Requires user context
         | 
| 296 | 
            +
                  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
         | 
| 297 | 
            +
                  # @return [Twitter::Cursor]
         | 
| 298 | 
            +
                  # @overload friend_ids(options={})
         | 
| 299 | 
            +
                  #   Returns an array of numeric IDs for every user the authenticated user is following
         | 
| 300 | 
            +
                  #
         | 
| 301 | 
            +
                  #   @param options [Hash] A customizable set of options.
         | 
| 302 | 
            +
                  #   @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
         | 
| 303 | 
            +
                  #   @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
         | 
| 304 | 
            +
                  #   @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
         | 
| 305 | 
            +
                  #   @example Return the authenticated user's friends' IDs
         | 
| 306 | 
            +
                  #     Twitter.friend_ids
         | 
| 307 | 
            +
                  # @overload friend_ids(user, options={})
         | 
| 308 | 
            +
                  #   Returns an array of numeric IDs for every user the specified user is following
         | 
| 309 | 
            +
                  #
         | 
| 310 | 
            +
                  #   @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
         | 
| 311 | 
            +
                  #   @param options [Hash] A customizable set of options.
         | 
| 312 | 
            +
                  #   @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
         | 
| 313 | 
            +
                  #   @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
         | 
| 314 | 
            +
                  #   @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
         | 
| 315 | 
            +
                  # @example Return the cursored collection of users @sferik is following
         | 
| 316 | 
            +
                  #   Twitter.friends('sferik')
         | 
| 317 | 
            +
                  #   Twitter.friends(7505382)    # Same as above
         | 
| 318 | 
            +
                  def friends(*args)
         | 
| 319 | 
            +
                    options = extract_options!(args)
         | 
| 320 | 
            +
                    merge_user!(options, args.pop || screen_name)
         | 
| 321 | 
            +
                    merge_default_cursor!(options)
         | 
| 322 | 
            +
                    cursor_from_response(:users, Twitter::User, :get, "/1.1/friends/list.json", options)
         | 
| 323 | 
            +
                  end
         | 
| 324 | 
            +
                  alias following friends
         | 
| 257 325 | 
             
                end
         | 
| 258 326 | 
             
              end
         | 
| 259 327 | 
             
            end
         | 
    
        data/lib/twitter/api/lists.rb
    CHANGED
    
    | @@ -63,9 +63,9 @@ module Twitter | |
| 63 63 | 
             
                  #     Twitter.list_timeline(7505382, 'presidents')
         | 
| 64 64 | 
             
                  #     Twitter.list_timeline(7505382, 8863586)
         | 
| 65 65 | 
             
                  def list_timeline(*args)
         | 
| 66 | 
            -
                    options =  | 
| 67 | 
            -
                     | 
| 68 | 
            -
                     | 
| 66 | 
            +
                    options = extract_options!(args)
         | 
| 67 | 
            +
                    merge_list!(options, args.pop)
         | 
| 68 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 69 69 | 
             
                    collection_from_response(Twitter::Tweet, :get, "/1.1/lists/statuses.json", options)
         | 
| 70 70 | 
             
                  end
         | 
| 71 71 |  | 
| @@ -507,64 +507,93 @@ module Twitter | |
| 507 507 | 
             
                private
         | 
| 508 508 |  | 
| 509 509 | 
             
                  # @param request_method [Symbol]
         | 
| 510 | 
            -
                  # @param  | 
| 510 | 
            +
                  # @param path [String]
         | 
| 511 511 | 
             
                  # @param args [Array]
         | 
| 512 512 | 
             
                  # @return [Array<Twitter::User>]
         | 
| 513 | 
            -
                  def list_from_response(request_method,  | 
| 514 | 
            -
                    options =  | 
| 515 | 
            -
                     | 
| 516 | 
            -
                     | 
| 517 | 
            -
                    object_from_response(Twitter::List, request_method,  | 
| 513 | 
            +
                  def list_from_response(request_method, path, args)
         | 
| 514 | 
            +
                    options = extract_options!(args)
         | 
| 515 | 
            +
                    merge_list!(options, args.pop)
         | 
| 516 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 517 | 
            +
                    object_from_response(Twitter::List, request_method, path, options)
         | 
| 518 518 | 
             
                  end
         | 
| 519 519 |  | 
| 520 520 | 
             
                  # @param request_method [Symbol]
         | 
| 521 | 
            -
                  # @param  | 
| 521 | 
            +
                  # @param path [String]
         | 
| 522 522 | 
             
                  # @param args [Array]
         | 
| 523 523 | 
             
                  # @return [Array<Twitter::List>]
         | 
| 524 | 
            -
                  def lists_from_response(request_method,  | 
| 525 | 
            -
                    options =  | 
| 524 | 
            +
                  def lists_from_response(request_method, path, args)
         | 
| 525 | 
            +
                    options = extract_options!(args)
         | 
| 526 526 | 
             
                    merge_default_cursor!(options)
         | 
| 527 | 
            -
                     | 
| 528 | 
            -
                    cursor_from_response(:lists, Twitter::List, request_method,  | 
| 527 | 
            +
                    merge_user!(options, args.pop)
         | 
| 528 | 
            +
                    cursor_from_response(:lists, Twitter::List, request_method, path, options, calling_method)
         | 
| 529 529 | 
             
                  end
         | 
| 530 530 |  | 
| 531 | 
            -
                  def list_users(request_method,  | 
| 532 | 
            -
                    options =  | 
| 531 | 
            +
                  def list_users(request_method, path, args)
         | 
| 532 | 
            +
                    options = extract_options!(args)
         | 
| 533 533 | 
             
                    merge_default_cursor!(options)
         | 
| 534 | 
            -
                     | 
| 535 | 
            -
                     | 
| 536 | 
            -
                    cursor_from_response(:users, Twitter::User, request_method,  | 
| 534 | 
            +
                    merge_list!(options, args.pop)
         | 
| 535 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 536 | 
            +
                    cursor_from_response(:users, Twitter::User, request_method, path, options, calling_method)
         | 
| 537 537 | 
             
                  end
         | 
| 538 538 |  | 
| 539 | 
            -
                  def list_user?(request_method,  | 
| 540 | 
            -
                    options =  | 
| 541 | 
            -
                     | 
| 542 | 
            -
                     | 
| 543 | 
            -
                     | 
| 544 | 
            -
                    send(request_method.to_sym,  | 
| 539 | 
            +
                  def list_user?(request_method, path, args)
         | 
| 540 | 
            +
                    options = extract_options!(args)
         | 
| 541 | 
            +
                    merge_user!(options, args.pop)
         | 
| 542 | 
            +
                    merge_list!(options, args.pop)
         | 
| 543 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 544 | 
            +
                    send(request_method.to_sym, path, options)
         | 
| 545 545 | 
             
                    true
         | 
| 546 546 | 
             
                  rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
         | 
| 547 547 | 
             
                    false
         | 
| 548 548 | 
             
                  end
         | 
| 549 549 |  | 
| 550 | 
            -
                  def list_modify_member(request_method,  | 
| 551 | 
            -
                    options =  | 
| 552 | 
            -
                     | 
| 553 | 
            -
                     | 
| 554 | 
            -
                     | 
| 555 | 
            -
                    object_from_response(Twitter::List, request_method,  | 
| 550 | 
            +
                  def list_modify_member(request_method, path, args)
         | 
| 551 | 
            +
                    options = extract_options!(args)
         | 
| 552 | 
            +
                    merge_user!(options, args.pop)
         | 
| 553 | 
            +
                    merge_list!(options, args.pop)
         | 
| 554 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 555 | 
            +
                    object_from_response(Twitter::List, request_method, path, options)
         | 
| 556 556 | 
             
                  end
         | 
| 557 557 |  | 
| 558 | 
            -
                  def list_modify_members(request_method,  | 
| 559 | 
            -
                    options =  | 
| 558 | 
            +
                  def list_modify_members(request_method, path, args)
         | 
| 559 | 
            +
                    options = extract_options!(args)
         | 
| 560 560 | 
             
                    members = args.pop
         | 
| 561 | 
            -
                     | 
| 562 | 
            -
                     | 
| 561 | 
            +
                    merge_list!(options, args.pop)
         | 
| 562 | 
            +
                    merge_owner!(options, args.pop || screen_name) unless options[:owner_id] || options[:owner_screen_name]
         | 
| 563 563 | 
             
                    members.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users|
         | 
| 564 | 
            -
                      object_from_response(Twitter::List, request_method,  | 
| 564 | 
            +
                      object_from_response(Twitter::List, request_method, path, merge_users(options, users))
         | 
| 565 565 | 
             
                    end.last
         | 
| 566 566 | 
             
                  end
         | 
| 567 567 |  | 
| 568 | 
            +
                  # Take a list and merge it into the hash with the correct key
         | 
| 569 | 
            +
                  #
         | 
| 570 | 
            +
                  # @param hash [Hash]
         | 
| 571 | 
            +
                  # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
         | 
| 572 | 
            +
                  # @return [Hash]
         | 
| 573 | 
            +
                  def merge_list!(hash, list)
         | 
| 574 | 
            +
                    case list
         | 
| 575 | 
            +
                    when Integer
         | 
| 576 | 
            +
                      hash[:list_id] = list
         | 
| 577 | 
            +
                    when String
         | 
| 578 | 
            +
                      hash[:slug] = list
         | 
| 579 | 
            +
                    when Twitter::List
         | 
| 580 | 
            +
                      hash[:list_id] = list.id
         | 
| 581 | 
            +
                      merge_owner!(hash, list.user)
         | 
| 582 | 
            +
                    end
         | 
| 583 | 
            +
                    hash
         | 
| 584 | 
            +
                  end
         | 
| 585 | 
            +
             | 
| 586 | 
            +
                  # Take an owner and merge it into the hash with the correct key
         | 
| 587 | 
            +
                  #
         | 
| 588 | 
            +
                  # @param hash [Hash]
         | 
| 589 | 
            +
                  # @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
         | 
| 590 | 
            +
                  # @return [Hash]
         | 
| 591 | 
            +
                  def merge_owner!(hash, user)
         | 
| 592 | 
            +
                    merge_user!(hash, user, "owner")
         | 
| 593 | 
            +
                    hash[:owner_id] = hash.delete(:owner_user_id) unless hash[:owner_user_id].nil?
         | 
| 594 | 
            +
                    hash
         | 
| 595 | 
            +
                  end
         | 
| 596 | 
            +
             | 
| 568 597 | 
             
                end
         | 
| 569 598 | 
             
              end
         | 
| 570 599 | 
             
            end
         | 
| @@ -109,11 +109,11 @@ module Twitter | |
| 109 109 | 
             
                private
         | 
| 110 110 |  | 
| 111 111 | 
             
                  # @param request_method [Symbol]
         | 
| 112 | 
            -
                  # @param  | 
| 112 | 
            +
                  # @param path [String]
         | 
| 113 113 | 
             
                  # @param options [Hash]
         | 
| 114 114 | 
             
                  # @return [Array]
         | 
| 115 | 
            -
                  def geo_collection_from_response(request_method,  | 
| 116 | 
            -
                    collection_from_array(Twitter::Place, send(request_method.to_sym,  | 
| 115 | 
            +
                  def geo_collection_from_response(request_method, path, params={})
         | 
| 116 | 
            +
                    collection_from_array(Twitter::Place, send(request_method.to_sym, path, params)[:body][:result][:places])
         | 
| 117 117 | 
             
                  end
         | 
| 118 118 |  | 
| 119 119 | 
             
                end
         |