tweetstream 1.1.5 → 2.0.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/CHANGELOG.md +19 -2
- data/LICENSE.md +1 -1
- data/README.md +116 -43
- data/Rakefile +0 -2
- data/examples/growl_daemon.rb +5 -5
- data/examples/oauth.rb +4 -5
- data/examples/sitestream.rb +40 -0
- data/examples/userstream.rb +4 -5
- data/lib/tweetstream.rb +0 -4
- data/lib/tweetstream/client.rb +95 -75
- data/lib/tweetstream/configuration.rb +12 -5
- data/lib/tweetstream/site_stream_client.rb +123 -0
- data/lib/tweetstream/version.rb +1 -1
- data/spec/fixtures/ids.json +30 -0
- data/spec/fixtures/info.json +18 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/tweetstream/client_spec.rb +172 -65
- data/spec/tweetstream/site_stream_client_spec.rb +232 -0
- data/spec/tweetstream_spec.rb +18 -18
- data/tweetstream.gemspec +9 -5
- metadata +69 -90
- data/lib/tweetstream/direct_message.rb +0 -6
- data/lib/tweetstream/hash.rb +0 -27
- data/lib/tweetstream/status.rb +0 -12
- data/lib/tweetstream/user.rb +0 -7
- data/spec/tweetstream/direct_message_spec.rb +0 -21
- data/spec/tweetstream/hash_spec.rb +0 -19
- data/spec/tweetstream/parser_spec.rb +0 -42
- data/spec/tweetstream/status_spec.rb +0 -15
data/lib/tweetstream/hash.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class TweetStream::Hash < ::Hash #:nodoc: all
|
2
|
-
def initialize(other_hash = {})
|
3
|
-
other_hash.keys.each do |key|
|
4
|
-
value = other_hash[key]
|
5
|
-
value = TweetStream::Hash.new(value) if value.is_a?(::Hash)
|
6
|
-
self[key.to_sym] = value
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# This shim is necessary since method_missing won't be invoked for #id on
|
11
|
-
# Ruby < 1.9
|
12
|
-
def id
|
13
|
-
if key?(:id)
|
14
|
-
self[:id]
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def method_missing(method_name, *args)
|
21
|
-
if key?(method_name.to_sym)
|
22
|
-
self[method_name.to_sym]
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/tweetstream/status.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# A simple Hash wrapper that gives you method-based
|
2
|
-
# access to the properties of a Twitter status.
|
3
|
-
class TweetStream::Status < TweetStream::Hash
|
4
|
-
def initialize(hash)
|
5
|
-
super
|
6
|
-
self[:user] = TweetStream::User.new(self[:user])
|
7
|
-
end
|
8
|
-
|
9
|
-
def id
|
10
|
-
self[:id] || super
|
11
|
-
end
|
12
|
-
end
|
data/lib/tweetstream/user.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TweetStream::DirectMessage do
|
4
|
-
it 'modifies the :sender key into a TweetStream::User object called #user' do
|
5
|
-
@status = TweetStream::DirectMessage.new({:sender => {:screen_name => 'bob'}})
|
6
|
-
@status.user.should be_kind_of(TweetStream::User)
|
7
|
-
@status.user.screen_name.should == 'bob'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'transforms the sender into a TweetStream::User object called #sender' do
|
11
|
-
@status = TweetStream::DirectMessage.new({:sender => {:screen_name => 'bob'}})
|
12
|
-
@status.sender.should be_kind_of(TweetStream::User)
|
13
|
-
@status.sender.screen_name.should == 'bob'
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'overrides the #id method for itself and the user' do
|
17
|
-
@status = TweetStream::DirectMessage.new({:id => 123, :sender => {:id => 345}})
|
18
|
-
@status.id.should == 123
|
19
|
-
@status.user.id.should == 345
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TweetStream::Hash do
|
4
|
-
it 'should be initialized by passing in an existing hash' do
|
5
|
-
TweetStream::Hash.new(:abc => 123)[:abc].should == 123
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should symbolize incoming keys' do
|
9
|
-
TweetStream::Hash.new('abc' => 123)[:abc].should == 123
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should allow access via method calls' do
|
13
|
-
TweetStream::Hash.new(:abc => 123).abc.should == 123
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should still throw NoMethod for non-existent keys' do
|
17
|
-
lambda{TweetStream::Hash.new({}).akabi}.should raise_error(NoMethodError)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'TweetStream MultiJson Support' do
|
4
|
-
after do
|
5
|
-
TweetStream.reset
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should default to the MultiJson default's paser" do
|
9
|
-
TweetStream::Client.new.json_parser.engine.to_s.should == MultiJson.adapter.to_s
|
10
|
-
end
|
11
|
-
|
12
|
-
[:json_gem, :yajl, :json_pure].each do |engine|
|
13
|
-
describe "#{engine} parsing" do
|
14
|
-
before do
|
15
|
-
TweetStream.configure do |config|
|
16
|
-
config.username = 'test'
|
17
|
-
config.password = 'fake'
|
18
|
-
config.parser = engine
|
19
|
-
end
|
20
|
-
@client = TweetStream::Client.new
|
21
|
-
@class_name = "MultiJson::Adapters::#{engine.to_s.split('_').map{|s| s.capitalize}.join('')}"
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should set the parser to the appropriate class' do
|
25
|
-
@client.json_parser.engine.to_s == @class_name
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should be settable via client.parser=' do
|
29
|
-
@client.parser = engine
|
30
|
-
@client.json_parser.engine.to_s.should == @class_name
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class FakeParser; end
|
36
|
-
|
37
|
-
it 'should be settable to a class' do
|
38
|
-
@client = TweetStream::Client.new
|
39
|
-
@client.parser = FakeParser
|
40
|
-
@client.json_parser.engine.should == FakeParser
|
41
|
-
end
|
42
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe TweetStream::Status do
|
4
|
-
it 'should modify the :user key into a TweetStream::User object' do
|
5
|
-
@status = TweetStream::Status.new({:user => {:screen_name => 'bob'}})
|
6
|
-
@status.user.should be_kind_of(TweetStream::User)
|
7
|
-
@status.user.screen_name.should == 'bob'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should override the #id method for itself and the user' do
|
11
|
-
@status = TweetStream::Status.new({:id => 123, :user => {:id => 345}})
|
12
|
-
@status.id.should == 123
|
13
|
-
@status.user.id.should == 345
|
14
|
-
end
|
15
|
-
end
|