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.

@@ -1,6 +0,0 @@
1
- class TweetStream::DirectMessage < TweetStream::Hash
2
- def initialize(hash)
3
- super
4
- self[:user] = self[:sender] = TweetStream::User.new(self[:sender])
5
- end
6
- end
@@ -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
@@ -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
@@ -1,7 +0,0 @@
1
- # A simple Hash wrapper that gives you method-based
2
- # access to user properties returned by the streamer.
3
- class TweetStream::User < TweetStream::Hash
4
- def id
5
- self[:id] || super
6
- end
7
- end
@@ -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