tweetstream 1.1.1 → 1.1.2

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,12 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'tweetstream'
3
- require 'ruby-growl'
3
+ require 'growl'
4
4
 
5
- if args_start = ARGV.index('--')
6
- username, password = ARGV[args_start + 1].split(':')
7
- tracks = ARGV[args_start + 2 .. -1]
8
- puts "Starting a GrowlTweet to track: #{tracks.inspect}"
9
- end
5
+ tracks = 'yankees'
6
+ puts "Starting a GrowlTweet to track: #{tracks}"
10
7
 
11
8
  TweetStream.configure do |config|
12
9
  config.consumer_key = 'abcdefghijklmnopqrstuvwxyz'
@@ -16,7 +13,6 @@ TweetStream.configure do |config|
16
13
  config.auth_method = :oauth
17
14
  end
18
15
 
19
- TweetStream::Daemon.new('tracker').track(*tracks) do |status|
20
- g = Growl.new 'localhost', 'growltweet', ['tweet']
21
- g.notify 'tweet', status.user.screen_name, status.text
16
+ TweetStream::Daemon.new('tracker').track(tracks) do |status|
17
+ Growl.notify status.text, :title => status.user.screen_name
22
18
  end
@@ -31,6 +31,9 @@ module TweetStream
31
31
  Configuration::VALID_OPTIONS_KEYS.each do |key|
32
32
  send("#{key}=", options[key])
33
33
  end
34
+
35
+ # Ensure the json parser can be properly loaded
36
+ json_parser
34
37
  end
35
38
 
36
39
  # Get the JSON parser class for this client.
@@ -46,6 +49,14 @@ module TweetStream
46
49
  start('statuses/firehose', query_parameters, &block)
47
50
  end
48
51
 
52
+ # Returns all statuses containing http: and https:. The links stream is
53
+ # not a generally available resource. Few applications require this level
54
+ # of access. Creative use of a combination of other resources and various
55
+ # access levels can satisfy nearly every application use case.
56
+ def links(query_parameters = {}, &block)
57
+ start('statuses/links', query_parameters, &block)
58
+ end
59
+
49
60
  # Returns all retweets. The retweet stream is not a generally available
50
61
  # resource. Few applications require this level of access. Creative
51
62
  # use of a combination of other resources and various access levels
@@ -30,22 +30,23 @@ require 'daemons'
30
30
  # is posted.
31
31
  #
32
32
  class TweetStream::Daemon < TweetStream::Client
33
- # Initialize a Daemon with the credentials of the
34
- # Twitter account you wish to use. The daemon has
35
- # an optional process name for use when querying
36
- # running processes.
37
- def initialize(app_name=nil)
38
- @app_name = app_name
33
+
34
+ DEFAULT_NAME = 'tweetstream'.freeze
35
+ DEFAULT_OPTIONS = { :multiple => true }
36
+
37
+ attr_accessor :app_name, :daemon_options
38
+
39
+ # The daemon has an optional process name for use when querying
40
+ # running processes. You can also pass daemon options.
41
+ def initialize(name = DEFAULT_NAME, options = DEFAULT_OPTIONS)
42
+ @app_name = name
43
+ @daemon_options = options
39
44
  super({})
40
45
  end
41
46
 
42
47
  def start(path, query_parameters = {}, &block) #:nodoc:
43
- # Because of a change in Ruvy 1.8.7 patchlevel 249, you cannot call anymore
44
- # super inside a block. So I assign to a variable the base class method before
45
- # the Daemons block begins.
46
- startmethod = super.start
47
- Daemons.run_proc(@app_name || 'tweetstream', :multiple => true) do
48
- startmethod(path, query_parameters, &block)
48
+ Daemons.run_proc(@app_name, @daemon_options) do
49
+ super(path, query_parameters, &block)
49
50
  end
50
51
  end
51
52
  end
@@ -1,3 +1,3 @@
1
1
  module TweetStream
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -244,8 +244,8 @@ describe TweetStream::Client do
244
244
  end
245
245
  end
246
246
 
247
- describe ' API methods' do
248
- %w(firehose retweet sample).each do |method|
247
+ describe 'API methods' do
248
+ %w(firehose retweet sample links).each do |method|
249
249
  it "##{method} should make a call to start with \"statuses/#{method}\"" do
250
250
  @client.should_receive(:start).once.with('statuses/' + method, {})
251
251
  @client.send(method)
@@ -337,7 +337,7 @@ describe TweetStream::Client do
337
337
  end
338
338
  end
339
339
 
340
- describe 'instance .stop' do
340
+ describe '#stop' do
341
341
  it 'should call EventMachine::stop_event_loop' do
342
342
  EventMachine.should_receive :stop_event_loop
343
343
  TweetStream::Client.new.stop.should be_nil
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe TweetStream::Daemon do
4
+ describe '.new' do
5
+ it 'initializes with no arguments' do
6
+ client = TweetStream::Daemon.new
7
+ client.should be_kind_of(TweetStream::Client)
8
+ end
9
+
10
+ it 'initializes with defaults' do
11
+ client = TweetStream::Daemon.new
12
+ client.app_name.should eq(TweetStream::Daemon::DEFAULT_NAME)
13
+ client.daemon_options.should eq(TweetStream::Daemon::DEFAULT_OPTIONS)
14
+ end
15
+
16
+ it 'initializes with an app_name' do
17
+ client = TweetStream::Daemon.new('tweet_tracker')
18
+ client.app_name.should eq('tweet_tracker')
19
+ end
20
+ end
21
+ end
data/tweetstream.gemspec CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
17
17
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
18
18
 
19
19
  s.add_dependency 'twitter-stream', '~> 0.1.14'
20
- s.add_dependency 'daemons', '~> 1.1.2'
20
+ s.add_dependency 'daemons', '~> 1.1.4'
21
21
  s.add_dependency 'multi_json', '~> 1.0.3'
22
22
  s.add_development_dependency 'rake', '~> 0.9'
23
- s.add_development_dependency 'simplecov', '~> 0.4'
23
+ s.add_development_dependency 'simplecov', '~> 0.5.4'
24
24
  s.add_development_dependency 'yard', '~> 0.7'
25
25
  s.add_development_dependency 'rdiscount', '~> 1.6'
26
- s.add_development_dependency 'rspec', '~> 2.6.0'
26
+ s.add_development_dependency 'rspec', '~> 2.7'
27
27
  s.add_development_dependency 'yajl-ruby', '~> 1.0'
28
28
  s.add_development_dependency 'json', '~> 1.5.1'
29
29
  s.add_development_dependency 'guard-rspec', '~> 0.4.3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweetstream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-04 00:00:00.000000000Z
12
+ date: 2011-10-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter-stream
16
- requirement: &2153681580 !ruby/object:Gem::Requirement
16
+ requirement: &2153351480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 0.1.14
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153681580
24
+ version_requirements: *2153351480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: daemons
27
- requirement: &2153681060 !ruby/object:Gem::Requirement
27
+ requirement: &2153351020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 1.1.2
32
+ version: 1.1.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153681060
35
+ version_requirements: *2153351020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &2153680500 !ruby/object:Gem::Requirement
38
+ requirement: &2153350560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153680500
46
+ version_requirements: *2153350560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &2153678780 !ruby/object:Gem::Requirement
49
+ requirement: &2153350100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,21 +54,21 @@ dependencies:
54
54
  version: '0.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153678780
57
+ version_requirements: *2153350100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &2153677120 !ruby/object:Gem::Requirement
60
+ requirement: &2153349640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: '0.4'
65
+ version: 0.5.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153677120
68
+ version_requirements: *2153349640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &2153670740 !ruby/object:Gem::Requirement
71
+ requirement: &2153349180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.7'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153670740
79
+ version_requirements: *2153349180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rdiscount
82
- requirement: &2153670260 !ruby/object:Gem::Requirement
82
+ requirement: &2153348720 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,21 +87,21 @@ dependencies:
87
87
  version: '1.6'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2153670260
90
+ version_requirements: *2153348720
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &2153669800 !ruby/object:Gem::Requirement
93
+ requirement: &2153348260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: 2.6.0
98
+ version: '2.7'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2153669800
101
+ version_requirements: *2153348260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: yajl-ruby
104
- requirement: &2153669320 !ruby/object:Gem::Requirement
104
+ requirement: &2153347800 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '1.0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2153669320
112
+ version_requirements: *2153347800
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: json
115
- requirement: &2153668860 !ruby/object:Gem::Requirement
115
+ requirement: &2153347340 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 1.5.1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2153668860
123
+ version_requirements: *2153347340
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard-rspec
126
- requirement: &2153668400 !ruby/object:Gem::Requirement
126
+ requirement: &2153346840 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: 0.4.3
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2153668400
134
+ version_requirements: *2153346840
135
135
  description: TweetStream allows you to easily consume the Twitter Streaming API utilizing
136
136
  the YAJL Ruby gem.
137
137
  email:
@@ -168,6 +168,7 @@ files:
168
168
  - spec/data/statuses.json
169
169
  - spec/spec_helper.rb
170
170
  - spec/tweetstream/client_spec.rb
171
+ - spec/tweetstream/daemon_spec.rb
171
172
  - spec/tweetstream/direct_message_spec.rb
172
173
  - spec/tweetstream/hash_spec.rb
173
174
  - spec/tweetstream/parser_spec.rb
@@ -203,6 +204,7 @@ test_files:
203
204
  - spec/data/statuses.json
204
205
  - spec/spec_helper.rb
205
206
  - spec/tweetstream/client_spec.rb
207
+ - spec/tweetstream/daemon_spec.rb
206
208
  - spec/tweetstream/direct_message_spec.rb
207
209
  - spec/tweetstream/hash_spec.rb
208
210
  - spec/tweetstream/parser_spec.rb