twitter 5.10.0 → 5.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ed9a45b1f841e8fd80f06a88cdb71d73448c27b
4
- data.tar.gz: 28ec0e841594b0e1c7b26a262ae1d8451157f1c0
3
+ metadata.gz: 6d7d42d9e3c81c1633f4d439a2986371be492475
4
+ data.tar.gz: ff20ed8b670c4843eaa02650184f74e99e70507b
5
5
  SHA512:
6
- metadata.gz: 7a1171a26b33386f6bc0a5d5fc71dd7c9250f4b8e45efe50465b8d795436dedf6fb767b026be8882c2e370bf8c4ef5d371b3c4aed0a3a99a67268bb147bce6f9
7
- data.tar.gz: 046690ce229a2af4d4d762602b1e64f694d0a2fcd138324a6dd0d430545c5967c15cde11b8181e250d5bdb64631ba3754aacd642f3fc309f81c17d002b751dce
6
+ metadata.gz: bec1abcdc08fbfd1e4b1f13dbccef720951ee61b18259f82a14e70e19fce5a856f57ebd7d127a131d2e39b8369bd4151cecc4393c8946c81542f8a2b9fb29599
7
+ data.tar.gz: a0025ecdd3e1802588789dc53ae5dd6f6801fb94e8ee1b8e7f0ed6c8c5a5ebee3ce79442e69ab7015bdcc0d595a059466235b7e7f952e3d1a212f0df6bc9e85b
@@ -1,3 +1,8 @@
1
+ 5.11.0
2
+ ------
3
+ * [Return a Twitter::NullObject for empty attributes](https://github.com/sferik/twitter/commit/bca179eefb1c157f19b882a88ba608f6817b76bb)
4
+ * [Add `iso_language_code` attribute to `Twitter::Metadata`](https://github.com/sferik/twitter/commit/7bf3a1b6ad0c35dc608b03ba2b3321b594e4da1c)
5
+
1
6
  5.10.0
2
7
  ------
3
8
  * [Add support for extended entities](https://github.com/sferik/twitter/commit/ed7c708e4208de1df27d141678c14e23422504a0)
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  require 'yardstick/rake/verify'
33
33
  Yardstick::Rake::Verify.new do |verify|
34
- verify.threshold = 59.5
34
+ verify.threshold = 59.6
35
35
  end
36
36
 
37
37
  task :default => [:spec, :rubocop, :verify_measurements]
@@ -84,11 +84,11 @@ module Twitter
84
84
  # @param key2 [Symbol]
85
85
  def define_attribute_method(key1, klass = nil, key2 = nil)
86
86
  define_method(key1) do ||
87
- if klass.nil?
88
- @attrs[key1]
87
+ if @attrs[key1].nil? || @attrs[key1].respond_to?(:empty?) && @attrs[key1].empty?
88
+ NullObject.new
89
89
  else
90
- if @attrs[key1].nil?
91
- NullObject.new
90
+ if klass.nil?
91
+ @attrs[key1]
92
92
  else
93
93
  attrs = attrs_for_object(key1, key2)
94
94
  Twitter.const_get(klass).new(attrs)
@@ -115,7 +115,7 @@ module Twitter
115
115
  # @param key2 [Symbol]
116
116
  def define_predicate_method(key1, key2 = key1)
117
117
  define_method(:"#{key1}?") do ||
118
- !@attrs[key2].nil? && @attrs[key2] != false
118
+ !@attrs[key2].nil? && @attrs[key2] != false && !(@attrs[key2].respond_to?(:empty?) && @attrs[key2].empty?)
119
119
  end
120
120
  memoize(:"#{key1}?")
121
121
  end
@@ -2,6 +2,6 @@ require 'twitter/base'
2
2
 
3
3
  module Twitter
4
4
  class Metadata < Twitter::Base
5
- attr_reader :result_type
5
+ attr_reader :iso_language_code, :result_type
6
6
  end
7
7
  end
@@ -17,7 +17,7 @@ module Twitter
17
17
  # @raise [ArgumentError] Error raised when supplied argument is missing a :woeid key.
18
18
  # @return [Twitter::Place]
19
19
  def initialize(attrs = {})
20
- attrs[:id] ||= attrs[:woeid]
20
+ attrs[:id] ||= attrs.fetch(:woeid)
21
21
  super
22
22
  end
23
23
 
@@ -24,7 +24,7 @@ module Twitter
24
24
  # Return the URL to the user's profile banner image
25
25
  #
26
26
  # @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
27
- # @return [String]
27
+ # @return [Addressable::URI]
28
28
  def profile_banner_uri(size = :web)
29
29
  parse_encoded_uri(insecure_uri([@attrs[:profile_banner_url], size].join('/'))) unless @attrs[:profile_banner_url].nil?
30
30
  end
@@ -33,7 +33,7 @@ module Twitter
33
33
  # Return the secure URL to the user's profile banner image
34
34
  #
35
35
  # @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
36
- # @return [String]
36
+ # @return [Addressable::URI]
37
37
  def profile_banner_uri_https(size = :web)
38
38
  parse_encoded_uri([@attrs[:profile_banner_url], size].join('/')) unless @attrs[:profile_banner_url].nil?
39
39
  end
@@ -49,7 +49,7 @@ module Twitter
49
49
  # Return the URL to the user's profile image
50
50
  #
51
51
  # @param size [String, Symbol] The size of the image. Must be one of: 'mini', 'normal', 'bigger' or 'original'
52
- # @return [String]
52
+ # @return [Addressable::URI]
53
53
  def profile_image_uri(size = :normal)
54
54
  parse_encoded_uri(insecure_uri(profile_image_uri_https(size))) unless @attrs[:profile_image_url_https].nil?
55
55
  end
@@ -58,7 +58,7 @@ module Twitter
58
58
  # Return the secure URL to the user's profile image
59
59
  #
60
60
  # @param size [String, Symbol] The size of the image. Must be one of: 'mini', 'normal', 'bigger' or 'original'
61
- # @return [String]
61
+ # @return [Addressable::URI]
62
62
  def profile_image_uri_https(size = :normal)
63
63
  # The profile image URL comes in looking like like this:
64
64
  # https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png
@@ -92,10 +92,12 @@ module Twitter
92
92
  # @return [Twitter::Cursor]
93
93
  # @overload memberships(options = {})
94
94
  # @param options [Hash] A customizable set of options.
95
+ # @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
95
96
  # @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
96
97
  # @overload memberships(user, options = {})
97
98
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
98
99
  # @param options [Hash] A customizable set of options.
100
+ # @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
99
101
  # @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
100
102
  def memberships(*args)
101
103
  cursor_from_response_with_user(:lists, Twitter::List, :get, '/1.1/lists/memberships.json', args)
@@ -26,7 +26,7 @@ module Twitter
26
26
  # @return [Array, Enumerator]
27
27
  def flat_pmap(enumerable)
28
28
  return to_enum(:flat_pmap, enumerable) unless block_given?
29
- pmap(enumerable, &Proc.new).flatten(1)
29
+ pmap(enumerable, &Proc.new).flatten!(1)
30
30
  end
31
31
  module_function :flat_pmap
32
32
 
@@ -37,24 +37,12 @@ module Twitter
37
37
  # @return [Array, Enumerator]
38
38
  def pmap(enumerable)
39
39
  return to_enum(:pmap, enumerable) unless block_given?
40
- pmap_with_index(enumerable).sort_by { |_, index| index }.collect { |object, _| yield(object) }
41
- end
42
- module_function :pmap
43
-
44
- # Calls block with two arguments, the item and its index, for each item in enumerable. Given arguments are passed through to pmap.
45
- # If no block is given, an enumerator is returned instead.
46
- #
47
- # @param enumerable [Enumerable]
48
- # @return [Array, Enumerator]
49
- def pmap_with_index(enumerable)
50
- return to_enum(:pmap_with_index, enumerable) unless block_given?
51
- # Don't bother spawning a new thread if there's only one item
52
40
  if enumerable.count == 1
53
- enumerable.collect { |object| yield(object, 0) }
41
+ enumerable.collect { |object| yield(object) }
54
42
  else
55
- enumerable.each_with_index.collect { |object, index| Thread.new { yield(object, index) } }.collect(&:value)
43
+ enumerable.collect { |object| Thread.new { yield(object) } }.collect(&:value)
56
44
  end
57
45
  end
58
- module_function :pmap_with_index
46
+ module_function :pmap
59
47
  end
60
48
  end
@@ -1,7 +1,7 @@
1
1
  module Twitter
2
2
  class Version
3
3
  MAJOR = 5
4
- MINOR = 10
4
+ MINOR = 11
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
@@ -2,6 +2,14 @@ require 'helper'
2
2
 
3
3
  describe Twitter::Place do
4
4
 
5
+ describe '.new' do
6
+ it 'raises an IndexError when id or woeid is not specified' do
7
+ expect { Twitter::Place.new(:id => 1) }.not_to raise_error
8
+ expect { Twitter::Place.new(:woeid => 1) }.not_to raise_error
9
+ expect { Twitter::Place.new }.to raise_error(IndexError)
10
+ end
11
+ end
12
+
5
13
  describe '#eql?' do
6
14
  it 'returns true when objects WOE IDs are the same' do
7
15
  place = Twitter::Place.new(:woeid => 1, :name => 'foo')
@@ -210,7 +210,7 @@ describe Twitter::Tweet do
210
210
 
211
211
  describe '#metadata' do
212
212
  it 'returns a Twitter::Metadata when metadata is set' do
213
- tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {})
213
+ tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {:result_type => 'recent'})
214
214
  expect(tweet.metadata).to be_a Twitter::Metadata
215
215
  end
216
216
  it 'returns nil when metadata is not set' do
@@ -221,7 +221,7 @@ describe Twitter::Tweet do
221
221
 
222
222
  describe '#metadata?' do
223
223
  it 'returns true when metadata is set' do
224
- tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {})
224
+ tweet = Twitter::Tweet.new(:id => 28_669_546_014, :metadata => {:result_type => 'recent'})
225
225
  expect(tweet.metadata?).to be true
226
226
  end
227
227
  it 'returns false when metadata is not set' do
@@ -0,0 +1,34 @@
1
+ require 'benchmark'
2
+ require 'helper'
3
+
4
+ describe Twitter::Utils do
5
+ describe '#pmap' do
6
+ it 'maps in parallel' do
7
+ delay = 0.1
8
+ array = (0..9).to_a
9
+ size = array.size
10
+ block = proc { |x| sleep(delay) && x + 1 }
11
+ block_without_sleep = proc { |x| x + 1 }
12
+ expected = array.collect(&block_without_sleep)
13
+ elapsed_time = Benchmark.realtime do
14
+ expect(subject.pmap(array, &block)).to eq(expected)
15
+ end
16
+ expect(elapsed_time).to be_between(delay, delay * size)
17
+ end
18
+ end
19
+
20
+ describe '#flat_pmap' do
21
+ it 'flat maps in parallel' do
22
+ delay = 0.1
23
+ array = (0..4).to_a.combination(2).to_a
24
+ size = array.size
25
+ block = proc { |x| sleep(delay) && x.reverse }
26
+ block_without_sleep = proc { |x| x.reverse }
27
+ expected = array.collect(&block_without_sleep).flatten!(1)
28
+ elapsed_time = Benchmark.realtime do
29
+ expect(subject.flat_pmap(array, &block)).to eq(expected)
30
+ end
31
+ expect(elapsed_time).to be_between(delay, delay * size)
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.0
4
+ version: 5.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-06-10 00:00:00.000000000 Z
15
+ date: 2014-06-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -389,6 +389,7 @@ files:
389
389
  - spec/twitter/trend_spec.rb
390
390
  - spec/twitter/tweet_spec.rb
391
391
  - spec/twitter/user_spec.rb
392
+ - spec/twitter/utils_spec.rb
392
393
  - twitter.gemspec
393
394
  homepage: http://sferik.github.com/twitter/
394
395
  licenses:
@@ -410,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
410
411
  version: 1.3.5
411
412
  requirements: []
412
413
  rubyforge_project:
413
- rubygems_version: 2.2.2
414
+ rubygems_version: 2.3.0
414
415
  signing_key:
415
416
  specification_version: 4
416
417
  summary: A Ruby interface to the Twitter API.
@@ -540,4 +541,5 @@ test_files:
540
541
  - spec/twitter/trend_spec.rb
541
542
  - spec/twitter/tweet_spec.rb
542
543
  - spec/twitter/user_spec.rb
544
+ - spec/twitter/utils_spec.rb
543
545
  has_rdoc: