tweetstream 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tweetstream might be problematic. Click here for more details.

data/.rspec CHANGED
@@ -1 +1,3 @@
1
1
  --color
2
+ --fail-fast
3
+ --order random
@@ -1,10 +1,16 @@
1
+ bundler_args: --without development
1
2
  language: ruby
2
3
  matrix:
3
4
  allow_failures:
4
5
  - rvm: ruby-head
5
6
  rvm:
6
- - rbx-19mode
7
7
  - 1.8.7
8
8
  - 1.9.2
9
9
  - 1.9.3
10
10
  - ruby-head
11
+ gemfile:
12
+ - Gemfile
13
+ - gemfiles/twitter4_0.gemfile
14
+ - gemfiles/twitter4_1.gemfile
15
+ - gemfiles/twitter4_2.gemfile
16
+ - gemfiles/twitter4_3.gemfile
data/.yardopts CHANGED
@@ -1,4 +1,6 @@
1
1
  --markup markdown
2
2
  -
3
- RELEASE_NOTES.md
3
+ CHANGELOG.md
4
+ CONTRIBUTING.md
4
5
  LICENSE.md
6
+ README.md
@@ -1,12 +1,30 @@
1
- Version 2.0.1
1
+ Version 2.4.0
2
+ =============
3
+ * Revert "use extract_options! from the Twitter gem"
4
+ * Reorganize development and test dependencies
5
+
6
+ Version 2.3.0
7
+ =============
8
+ * Added support for Site Stream friends list
9
+ * Update paths for API 1.1
10
+ * Added stall warning handling
11
+
12
+ Version 2.2.0
2
13
  =============
14
+ * Change method to request_method
3
15
 
16
+ Version 2.1.0
17
+ =============
18
+ * Disable identity map to reduce memory usage
19
+ * Added options support to UserStreams
20
+
21
+ Version 2.0.1
22
+ =============
4
23
  * Fixed Twitter gem objects
5
24
  * Added on_unauthorized callback method (koenpunt)
6
25
 
7
26
  Version 2.0.0
8
27
  =============
9
-
10
28
  * Added Site Stream support
11
29
  * Switched to [em-twitter](https://github.com/spagalloco/em-twitter) for underlying streaming lib
12
30
  * Switched to Twitter gem objects instead of custom hashes, see [47e5cd3d21a9562b3d959bc231009af460b37567](https://github.com/intridea/tweetstream/commit/47e5cd3d21a9562b3d959bc231009af460b37567) for details (sferik)
@@ -16,36 +34,30 @@ Version 2.0.0
16
34
 
17
35
  Version 1.1.5
18
36
  =============
19
-
20
37
  * Added support for the scrub_geo response (augustj)
21
38
  * Update multi_json and twitter-stream version dependencies
22
39
 
23
40
  Version 1.1.4
24
41
  =============
25
-
26
42
  * Added Client#connect to start streaming inside an EM reactor (pelle)
27
43
  * Added shutdown_stream to cleanly stop the stream (lud)
28
44
  * Loosened multi_json dependency for Rails 3.2 compatibiltiy
29
45
 
30
46
  Version 1.1.3
31
47
  =============
32
-
33
48
  * Added on_reconnect callback method
34
49
 
35
50
  Version 1.1.2
36
51
  =============
37
-
38
52
  * Added support for statuses/links
39
53
  * Client now checks that specified json_parser can be loaded during initialization
40
54
 
41
55
  Version 1.1.1
42
56
  =============
43
-
44
57
  * Fix for 1.8.6 compatibility
45
58
 
46
59
  Version 1.1.0
47
60
  =============
48
-
49
61
  * OAuth authentication
50
62
  * User Stream support
51
63
  * Removed swappable JSON backend support for MultiJson
@@ -55,12 +67,10 @@ Version 1.1.0
55
67
 
56
68
  Version 1.0.5
57
69
  =============
58
-
59
70
  * Force SSL to comply with
60
71
 
61
72
  Version 1.0.0
62
73
  =============
63
-
64
74
  * Swappable JSON backend support
65
75
  * Switches to use EventMachine instead of Yajl for the HTTP Stream
66
76
  * Support reconnect and on_error
data/Gemfile CHANGED
@@ -1,3 +1,12 @@
1
- source 'https://rubygems.org'
1
+ source :rubygems
2
+
3
+ gem 'rake'
4
+ gem 'yard'
5
+ gem 'json', :platforms => :ruby_18
6
+
7
+ group :test do
8
+ gem 'rspec'
9
+ gem 'webmock'
10
+ end
2
11
 
3
12
  gemspec
data/Rakefile CHANGED
@@ -7,13 +7,5 @@ RSpec::Core::RakeTask.new(:spec)
7
7
  task :test => :spec
8
8
  task :default => :spec
9
9
 
10
- namespace :doc do
11
- require 'yard'
12
- YARD::Rake::YardocTask.new do |task|
13
- task.files = ['RELEASE_NOTES.md', 'LICENSE.md', 'lib/**/*.rb']
14
- task.options = [
15
- '--output-dir', 'doc/yard',
16
- '--markup', 'markdown',
17
- ]
18
- end
19
- end
10
+ require 'yard'
11
+ YARD::Rake::YardocTask.new
@@ -1,4 +1,3 @@
1
- require 'yajl'
2
1
  require 'tweetstream'
3
2
 
4
3
  TweetStream.configure do |config|
@@ -1,4 +1,3 @@
1
- require 'yajl'
2
1
  require 'tweetstream'
3
2
 
4
3
  TweetStream.configure do |config|
@@ -1,4 +1,3 @@
1
- require 'yajl'
2
1
  require 'tweetstream'
3
2
 
4
3
  TweetStream.configure do |config|
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'twitter', '~> 4.0.0'
4
+ gem 'rake'
5
+ gem 'yard'
6
+ gem 'json', :platforms => :ruby_18
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'webmock'
11
+ end
12
+
13
+ gemspec :path => '..'
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'twitter', '~> 4.1.0'
4
+ gem 'rake'
5
+ gem 'yard'
6
+ gem 'json', :platforms => :ruby_18
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'webmock'
11
+ end
12
+
13
+ gemspec :path => '..'
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'twitter', '~> 4.2.0'
4
+ gem 'rake'
5
+ gem 'yard'
6
+ gem 'json', :platforms => :ruby_18
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'webmock'
11
+ end
12
+
13
+ gemspec :path => '..'
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'twitter', '~> 4.3.0'
4
+ gem 'rake'
5
+ gem 'yard'
6
+ gem 'json', :platforms => :ruby_18
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'webmock'
11
+ end
12
+
13
+ gemspec :path => '..'
@@ -1,7 +1,7 @@
1
1
  require 'em-twitter'
2
2
  require 'eventmachine'
3
- require 'multi_json'
4
3
  require 'twitter'
4
+ require 'yajl'
5
5
 
6
6
  module TweetStream
7
7
  # Provides simple access to the Twitter Streaming API (https://dev.twitter.com/docs/streaming-api)
@@ -93,7 +93,8 @@ module TweetStream
93
93
  # Keywords containing punctuation will only exact match tokens.
94
94
  # Query parameters may be passed as the last argument.
95
95
  def track(*keywords, &block)
96
- query_params = keywords.extract_options!
96
+ query_params = keywords.pop if keywords.last.is_a?(::Hash)
97
+ query_params ||= {}
97
98
  filter(query_params.merge(:track => keywords), &block)
98
99
  end
99
100
 
@@ -102,7 +103,8 @@ module TweetStream
102
103
  # pressing the reply "swoosh") are not matched. Requires integer user
103
104
  # IDs, not screen names. Query parameters may be passed as the last argument.
104
105
  def follow(*user_ids, &block)
105
- query_params = user_ids.extract_options!
106
+ query_params = user_ids.pop if user_ids.last.is_a?(::Hash)
107
+ query_params ||= {}
106
108
  filter(query_params.merge(:follow => user_ids), &block)
107
109
  end
108
110
 
@@ -115,7 +117,8 @@ module TweetStream
115
117
  # the first pair denoting the southwest corner of the box
116
118
  # longitude/latitude pairs, separated by commas. The first pair specifies the southwest corner of the box.
117
119
  def locations(*locations_map, &block)
118
- query_params = locations_map.extract_options!
120
+ query_params = locations_map.pop if locations_map.last.is_a?(::Hash)
121
+ query_params ||= {}
119
122
  filter(query_params.merge(:locations => locations_map), &block)
120
123
  end
121
124
 
@@ -395,9 +398,9 @@ module TweetStream
395
398
  @stream = EM::Twitter::Client.connect(stream_parameters)
396
399
  @stream.each do |item|
397
400
  begin
398
- hash = MultiJson.decode(item, :symbolize_keys => true)
399
- rescue MultiJson::DecodeError
400
- invoke_callback(callbacks['error'], "MultiJson::DecodeError occured in stream: #{item}")
401
+ hash = Yajl::Parser.parse(item, :symbolize_keys => true)
402
+ rescue Yajl::ParseError
403
+ invoke_callback(callbacks['error'], "Yajl::ParseError occured in stream: #{item}")
401
404
  next
402
405
  end
403
406
 
@@ -1,4 +1,3 @@
1
- require 'multi_json'
2
1
  require 'tweetstream/version'
3
2
 
4
3
  module TweetStream
@@ -22,9 +21,6 @@ module TweetStream
22
21
  :oauth_token,
23
22
  :oauth_token_secret].freeze
24
23
 
25
- # The parser that will be used to connect if none is set
26
- DEFAULT_PARSER = MultiJson.default_engine
27
-
28
24
  # By default, don't set a username
29
25
  DEFAULT_USERNAME = nil
30
26
 
@@ -1,3 +1,3 @@
1
1
  module TweetStream
2
- VERSION = '2.3.0' unless defined?(TweetStream::VERSION)
2
+ VERSION = '2.4.0' unless defined?(TweetStream::VERSION)
3
3
  end
@@ -8,10 +8,16 @@ end
8
8
 
9
9
  require 'tweetstream'
10
10
  require 'tweetstream/site_stream_client'
11
+ require 'json'
11
12
  require 'rspec'
12
13
  require 'webmock/rspec'
13
14
  require 'yajl'
14
- require 'json'
15
+
16
+ RSpec.configure do |config|
17
+ config.expect_with :rspec do |c|
18
+ c.syntax = :expect
19
+ end
20
+ end
15
21
 
16
22
  def samples(fixture)
17
23
  samples = []
@@ -42,4 +48,4 @@ end
42
48
  FakeHttp = Class.new do
43
49
  def callback; end
44
50
  def errback; end
45
- end
51
+ end
@@ -29,7 +29,7 @@ describe TweetStream::Client do
29
29
  @client = TweetStream::Client.new
30
30
  end
31
31
 
32
- it 'should try to connect via a JSON stream with basic auth' do
32
+ it "tries to connect via a JSON stream with basic auth" do
33
33
  EM::Twitter::Client.should_receive(:connect).with(
34
34
  :path => '/1.1/statuses/filter.json',
35
35
  :method => 'POST',
@@ -59,7 +59,7 @@ describe TweetStream::Client do
59
59
  @client = TweetStream::Client.new
60
60
  end
61
61
 
62
- it 'should try to connect via a JSON stream with oauth' do
62
+ it "tries to connect via a JSON stream with oauth" do
63
63
  EM::Twitter::Client.should_receive(:connect).with(
64
64
  :path => '/1.1/statuses/filter.json',
65
65
  :method => 'POST',
@@ -38,27 +38,27 @@ describe TweetStream::Client do
38
38
  @client.sitestream
39
39
  end
40
40
 
41
- it 'supports "with followings" when followings set as a boolean' do
41
+ it "supports :followings => true" do
42
42
  @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
43
43
  @client.sitestream(['115192457'], :followings => true)
44
44
  end
45
45
 
46
- it 'supports "with followings" when followings set as an option' do
46
+ it "supports :with => 'followings'" do
47
47
  @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'followings')).and_return(@stream)
48
48
  @client.sitestream(['115192457'], :with => 'followings')
49
49
  end
50
50
 
51
- it 'supports "with user"' do
51
+ it "supports :with => 'user'" do
52
52
  @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:with => 'user')).and_return(@stream)
53
53
  @client.sitestream(['115192457'], :with => 'user')
54
54
  end
55
55
 
56
- it 'supports "replies all"' do
56
+ it "supports :replies => 'all'" do
57
57
  @client.should_receive(:start).once.with('/1.1/site.json', hash_including(:replies => 'all')).and_return(@stream)
58
58
  @client.sitestream(['115192457'], :replies => 'all')
59
59
  end
60
60
 
61
- describe 'control management' do
61
+ describe "control management" do
62
62
  before do
63
63
  @control_response = {"control" =>
64
64
  {
@@ -66,18 +66,18 @@ describe TweetStream::Client do
66
66
  }
67
67
  }
68
68
  end
69
- it 'assigns the control_uri' do
69
+ it "assigns the control_uri" do
70
70
  @stream.should_receive(:each).and_yield(@control_response.to_json)
71
71
  @client.sitestream
72
72
 
73
- @client.control_uri.should eq("/1.1/site/c/01_225167_334389048B872A533002B34D73F8C29FD09EFC50")
73
+ expect(@client.control_uri).to eq("/1.1/site/c/01_225167_334389048B872A533002B34D73F8C29FD09EFC50")
74
74
  end
75
75
 
76
- it 'instantiates a SiteStreamClient' do
76
+ it "instantiates a SiteStreamClient" do
77
77
  @stream.should_receive(:each).and_yield(@control_response.to_json)
78
78
  @client.sitestream
79
79
 
80
- @client.control.should be_kind_of(TweetStream::SiteStreamClient)
80
+ expect(@client.control).to be_kind_of(TweetStream::SiteStreamClient)
81
81
  end
82
82
 
83
83
  it "passes the client's on_error to the SiteStreamClient" do
@@ -88,44 +88,44 @@ describe TweetStream::Client do
88
88
 
89
89
  @client.control.on_error.call
90
90
 
91
- called.should be_true
91
+ expect(called).to be_true
92
92
  end
93
93
  end
94
94
 
95
- describe 'data handling' do
96
- context 'messages' do
95
+ describe "data handling" do
96
+ context "messages" do
97
97
  before do
98
98
  @ss_message = {'for_user' => '12345', 'message' => {'id' => 123, 'user' => {'screen_name' => 'monkey'}, 'text' => 'Oo oo aa aa'}}
99
99
  end
100
100
 
101
- it 'yields a site stream message' do
101
+ it "yields a site stream message" do
102
102
  @stream.should_receive(:each).and_yield(@ss_message.to_json)
103
103
  yielded_status = nil
104
104
  @client.sitestream do |message|
105
105
  yielded_status = message
106
106
  end
107
- yielded_status.should_not be_nil
108
- yielded_status[:for_user].should == '12345'
109
- yielded_status[:message][:user][:screen_name].should == 'monkey'
110
- yielded_status[:message][:text].should == 'Oo oo aa aa'
107
+ expect(yielded_status).not_to be_nil
108
+ expect(yielded_status[:for_user]).to eq('12345')
109
+ expect(yielded_status[:message][:user][:screen_name]).to eq('monkey')
110
+ expect(yielded_status[:message][:text]).to eq('Oo oo aa aa')
111
111
  end
112
- it 'yields itself if block has an arity of 2' do
112
+ it "yields itself if block has an arity of 2" do
113
113
  @stream.should_receive(:each).and_yield(@ss_message.to_json)
114
114
  yielded_client = nil
115
115
  @client.sitestream do |_, client|
116
116
  yielded_client = client
117
117
  end
118
- yielded_client.should_not be_nil
119
- yielded_client.should == @client
118
+ expect(yielded_client).not_to be_nil
119
+ expect(yielded_client).to eq(@client)
120
120
  end
121
121
  end
122
122
 
123
- context 'friends list' do
123
+ context "friends list" do
124
124
  before do
125
125
  @friends_list = { 'friends' => [123, 456] }
126
126
  end
127
127
 
128
- it 'yields a friends list array' do
128
+ it "yields a friends list array" do
129
129
  @stream.should_receive(:each).and_yield(@friends_list.to_json)
130
130
  yielded_list = nil
131
131
  @client.on_friends do |friends|
@@ -133,9 +133,9 @@ describe TweetStream::Client do
133
133
  end
134
134
  @client.sitestream
135
135
 
136
- yielded_list.should_not be_nil
137
- yielded_list.should be_an(Array)
138
- yielded_list.first.should eq(123)
136
+ expect(yielded_list).not_to be_nil
137
+ expect(yielded_list).to be_an(Array)
138
+ expect(yielded_list.first).to eq(123)
139
139
  end
140
140
  end
141
141
  end