mikedamage-tweeb 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +9 -0
- data/LICENSE +20 -0
- data/README.textile +52 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/tweeb.rb +3 -0
- data/lib/tweeb_client.rb +288 -0
- data/lib/tweeb_client_error.rb +4 -0
- data/lib/tweeb_search.rb +42 -0
- data/lib/tweeb_search_error.rb +4 -0
- data/lib/tweeb_stream.rb +22 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/test_auth.yml.example +3 -0
- data/spec/tweeb_client_spec.rb +39 -0
- data/spec/tweeb_search_spec.rb +16 -0
- data/spec/tweeb_stream_spec.rb +16 -0
- metadata +82 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Mike Green
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
h1. Tweeb
|
2
|
+
|
3
|
+
Tweeb is a really simple, bare bones Twitter library that I created because I'm a glutton for punishment and enjoy reinventing the wheel.
|
4
|
+
In all seriousness, I'm creating it because I want to understand the Twitter API and the best way to understand something is to get your hands dirty. I don't expect anyone but me to actually use it, since John Nunemaker's Twitter gem is most excellent.
|
5
|
+
|
6
|
+
I'm using his "HTTParty":http://github.com/jnunemaker/httparty gem (at least at first) for the REST API, but I might get frisky and use "Yajl-Ruby":http://github.com/brianmario/yajl-ruby/tree/master to provide Stream API functionality.
|
7
|
+
|
8
|
+
h2. Documentation
|
9
|
+
|
10
|
+
Head on over to "http://rdoc.info/projects/mikedamage/tweeb":http://rdoc.info/projects/mikedamage/tweeb to peruse the project's RDoc at your leisure. The basics to get you up and Tweebing in no time are below:
|
11
|
+
|
12
|
+
h2. Installing
|
13
|
+
|
14
|
+
Once I get to a stable point in development, I'll release this project as a gem. Then all you'll have to do is
|
15
|
+
|
16
|
+
<pre>
|
17
|
+
$ sudo gem sources -a http://gems.github.com
|
18
|
+
$ sudo gem install mikedamage-tweeb
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
h2. Usage
|
22
|
+
|
23
|
+
h3. Tweeb::Client
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
require "rubygems"
|
27
|
+
require "tweeb"
|
28
|
+
|
29
|
+
tweeb = Tweeb::Client.new('username', 'password')
|
30
|
+
public_timeline = tweeb.public_timeline # can also be: tweeb.timeline(:public)
|
31
|
+
public_timeline.each do |tweet|
|
32
|
+
puts tweet["text"]
|
33
|
+
end
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
h3. Tweeb::Stream
|
37
|
+
|
38
|
+
<pre>
|
39
|
+
require "rubygems"
|
40
|
+
require "tweeb"
|
41
|
+
|
42
|
+
tweeb = Tweeb::Stream.new('username', 'password')
|
43
|
+
|
44
|
+
# Uses Twitter's "spritzer" stream
|
45
|
+
tweeb.spritzer do |tweet|
|
46
|
+
puts tweet["text"]
|
47
|
+
end
|
48
|
+
</pre>
|
49
|
+
|
50
|
+
h2. Copyright
|
51
|
+
|
52
|
+
Copyright (c) 2009 Mike Green. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "tweeb"
|
8
|
+
gem.summary = %Q{Tweeb is a really simple, bare bones Twitter library made possible by HTTParty}
|
9
|
+
gem.email = "mike.is.green@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/mikedamage/tweeb"
|
11
|
+
gem.authors = ["Mike Green"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:spec) do |spec|
|
21
|
+
spec.libs << 'lib' << 'spec'
|
22
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
23
|
+
spec.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |spec|
|
29
|
+
spec.libs << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "tweeb #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/lib/tweeb.rb
ADDED
data/lib/tweeb_client.rb
ADDED
@@ -0,0 +1,288 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "httparty"
|
3
|
+
require File.join(File.dirname(__FILE__), "tweeb_client_error.rb")
|
4
|
+
require File.join(File.dirname(__FILE__), "tweeb_search.rb")
|
5
|
+
|
6
|
+
class Hash
|
7
|
+
def symbolize_keys
|
8
|
+
t = self.dup
|
9
|
+
self.clear
|
10
|
+
t.each_pair do |key, value|
|
11
|
+
self[key.to_sym] = value
|
12
|
+
end
|
13
|
+
return self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Tweeb
|
18
|
+
class Client
|
19
|
+
include HTTParty
|
20
|
+
attr_reader :username, :password
|
21
|
+
|
22
|
+
base_uri "http://twitter.com"
|
23
|
+
format :json
|
24
|
+
|
25
|
+
def initialize(username, password, options={})
|
26
|
+
@username = username
|
27
|
+
@password = password
|
28
|
+
@options = {
|
29
|
+
:public_refresh => 60
|
30
|
+
}.merge(options)
|
31
|
+
self.class.basic_auth(@username, @password)
|
32
|
+
@symbolizer = lambda {|hash| hash['user'].symbolize_keys; hash.symbolize_keys; return hash }
|
33
|
+
end
|
34
|
+
|
35
|
+
def timeline(type, options={})
|
36
|
+
case type
|
37
|
+
when :public then public_timeline(options)
|
38
|
+
when :user then user_timeline(options)
|
39
|
+
when :friends then friends_timeline(options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def public_timeline(options={})
|
44
|
+
if options.empty?
|
45
|
+
json = self.class.get("/statuses/public_timeline.json")
|
46
|
+
else
|
47
|
+
if options[:count] && options[:count] > 200
|
48
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
49
|
+
end
|
50
|
+
json = self.class.get("/statuses/public_timeline.json", :query => options)
|
51
|
+
end
|
52
|
+
timeline = Array.new
|
53
|
+
json.each do |tweet|
|
54
|
+
tweet.symbolize_keys
|
55
|
+
tweet[:user].symbolize_keys
|
56
|
+
timeline << tweet
|
57
|
+
end
|
58
|
+
timeline
|
59
|
+
end
|
60
|
+
|
61
|
+
def user_timeline(options={})
|
62
|
+
if options.empty?
|
63
|
+
json = self.class.get("/statuses/user_timeline.json")
|
64
|
+
else
|
65
|
+
if options[:count] && options[:count] > 200
|
66
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
67
|
+
end
|
68
|
+
json = self.class.get("/statuses/user_timeline.json", :query => options)
|
69
|
+
end
|
70
|
+
timeline = Array.new
|
71
|
+
json.each do |tweet|
|
72
|
+
tweet.symbolize_keys
|
73
|
+
tweet[:user].symbolize_keys
|
74
|
+
timeline << tweet
|
75
|
+
end
|
76
|
+
timeline
|
77
|
+
end
|
78
|
+
|
79
|
+
def friends_timeline(options={})
|
80
|
+
if options.empty?
|
81
|
+
json = self.class.get("/statuses/friends_timeline.json")
|
82
|
+
else
|
83
|
+
if options[:count] && options[:count] > 200
|
84
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
85
|
+
end
|
86
|
+
json = self.class.get("/statuses/friends_timeline.json", :query => options)
|
87
|
+
end
|
88
|
+
timeline = Array.new
|
89
|
+
json.each do |tweet|
|
90
|
+
tweet.symbolize_keys
|
91
|
+
tweet[:user].symbolize_keys
|
92
|
+
timeline << tweet
|
93
|
+
end
|
94
|
+
timeline
|
95
|
+
end
|
96
|
+
|
97
|
+
def mentions(options={})
|
98
|
+
if options.empty?
|
99
|
+
json = self.class.get("/statuses/mentions.json")
|
100
|
+
else
|
101
|
+
if options[:count] and options[:count] > 200
|
102
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
103
|
+
end
|
104
|
+
json = self.class.get("/statuses/mentions.json", :query => options)
|
105
|
+
end
|
106
|
+
timeline = Array.new
|
107
|
+
json.each do |tweet|
|
108
|
+
tweet.symbolize_keys
|
109
|
+
tweet[:user].symbolize_keys
|
110
|
+
timeline << tweet
|
111
|
+
end
|
112
|
+
timeline
|
113
|
+
end
|
114
|
+
|
115
|
+
def update_status(message, reply_id=nil)
|
116
|
+
if message.length > 140
|
117
|
+
raise Tweeb::ClientError, "Message must be 140 characters or less"
|
118
|
+
end
|
119
|
+
if reply_id
|
120
|
+
json = self.class.post("/statuses/update.json", :query => {:status => message, :in_reply_to_status_id => reply_id})
|
121
|
+
else
|
122
|
+
json = self.class.post("/statuses/update.json", :query => {:status => message})
|
123
|
+
end
|
124
|
+
json.symbolize_keys
|
125
|
+
json[:user].symbolize_keys
|
126
|
+
json
|
127
|
+
end
|
128
|
+
|
129
|
+
def delete_status(id)
|
130
|
+
json = self.class.delete("/statuses/destroy/#{id}.json")
|
131
|
+
json.symbolize_keys
|
132
|
+
json[:user].symbolize_keys
|
133
|
+
json
|
134
|
+
end
|
135
|
+
|
136
|
+
def search(query, options={})
|
137
|
+
Tweeb::Search.search(query, options)
|
138
|
+
end
|
139
|
+
|
140
|
+
def trends(type=:trends)
|
141
|
+
case type
|
142
|
+
when :trends then Tweeb::Search.trends
|
143
|
+
when :current then Tweeb::Search.current_trends
|
144
|
+
when :daily then Tweeb::Search.daily_trends
|
145
|
+
when :weekly then Tweeb::Search.weekly_trends
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_status(id)
|
150
|
+
json = self.class.get("/statuses/show/#{id}.json")
|
151
|
+
json.symbolize_keys
|
152
|
+
json[:user].symbolize_keys
|
153
|
+
json
|
154
|
+
end
|
155
|
+
|
156
|
+
def friends(options={})
|
157
|
+
if options.empty?
|
158
|
+
json = self.class.get("/statuses/friends.json")
|
159
|
+
else
|
160
|
+
json = self.class.get("/statuses/friends.json", :query => options)
|
161
|
+
end
|
162
|
+
timeline = Array.new
|
163
|
+
json.each do |tweet|
|
164
|
+
tweet.symbolize_keys
|
165
|
+
tweet[:user].symbolize_keys
|
166
|
+
timeline << tweet
|
167
|
+
end
|
168
|
+
timeline
|
169
|
+
end
|
170
|
+
|
171
|
+
def show_user(id)
|
172
|
+
json = self.class.get("/users/show/#{id}.json")
|
173
|
+
json.symbolize_keys
|
174
|
+
end
|
175
|
+
|
176
|
+
def direct_message_inbox(options={})
|
177
|
+
if options.empty?
|
178
|
+
json = self.class.get("/direct_messages.json")
|
179
|
+
else
|
180
|
+
if options[:count] and options[:count] > 200
|
181
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
182
|
+
end
|
183
|
+
json = self.class.get("/direct_messages.json", :query => options)
|
184
|
+
end
|
185
|
+
timeline = Array.new
|
186
|
+
json.each do |tweet|
|
187
|
+
tweet.symbolize_keys
|
188
|
+
tweet[:sender].symbolize_keys
|
189
|
+
tweet[:recipient].symbolize_keys
|
190
|
+
timeline << tweet
|
191
|
+
end
|
192
|
+
timeline
|
193
|
+
end
|
194
|
+
|
195
|
+
def direct_messages_sent(options={})
|
196
|
+
if options.empty?
|
197
|
+
json = self.class.get("/direct_messages/sent.json")
|
198
|
+
else
|
199
|
+
if options[:count] and options[:count] > 200
|
200
|
+
raise Tweeb::ClientError, "Count must be less than 200"
|
201
|
+
end
|
202
|
+
json = self.class.get("/direct_messages/sent.json", :query => options)
|
203
|
+
end
|
204
|
+
json.each do |tweet|
|
205
|
+
tweet.symbolize_keys
|
206
|
+
tweet[:sender].symbolize_keys
|
207
|
+
tweet[:recipient].symbolize_keys
|
208
|
+
timeline << tweet
|
209
|
+
end
|
210
|
+
timeline
|
211
|
+
end
|
212
|
+
|
213
|
+
def direct_message(recipient, message)
|
214
|
+
json = self.class.post("/direct_messages/new.json", :query => {:user => recipient, :text => message})
|
215
|
+
json.symbolize_keys
|
216
|
+
json[:sender].symbolize_keys
|
217
|
+
json[:recipient].symbolize_keys
|
218
|
+
json
|
219
|
+
end
|
220
|
+
|
221
|
+
def delete_direct_message(id)
|
222
|
+
json = self.class.delete("/direct_messages/destroy.json", :query => {:id => id})
|
223
|
+
json.symbolize_keys
|
224
|
+
json[:sender].symbolize_keys
|
225
|
+
json[:recipient].symbolize_keys
|
226
|
+
json
|
227
|
+
end
|
228
|
+
|
229
|
+
def befriend(user, options={:follow => true})
|
230
|
+
json = self.class.post("/friendships/create.json", :query => {:id => user}.merge(options))
|
231
|
+
json.symbolize_keys
|
232
|
+
json[:status].symbolize_keys
|
233
|
+
json
|
234
|
+
end
|
235
|
+
alias_method :follow, :befriend
|
236
|
+
|
237
|
+
def unfriend(user)
|
238
|
+
json = self.class.delete("/friendships/destroy.json", :query => {:id => user})
|
239
|
+
json.symbolize_keys
|
240
|
+
json[:status].symbolize_keys
|
241
|
+
json
|
242
|
+
end
|
243
|
+
alias_method :unfollow, :unfriend
|
244
|
+
|
245
|
+
def friendship_info(target, source=nil)
|
246
|
+
query = Hash.new
|
247
|
+
if source
|
248
|
+
if source.is_a?(Fixnum)
|
249
|
+
query[:source_id] = source
|
250
|
+
elsif source.is_a?(String)
|
251
|
+
query[:source_screen_name] = source
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
if target.is_a?(Fixnum)
|
256
|
+
query[:target_id] = target
|
257
|
+
elsif target.is_a?(String)
|
258
|
+
query[:target_screen_name] = target
|
259
|
+
end
|
260
|
+
|
261
|
+
json = self.class.get("/friendships/show.json", :query => query)
|
262
|
+
json.symbolize_keys
|
263
|
+
relationship = json[:relationship].symbolize_keys
|
264
|
+
relationship[:source].symbolize_keys
|
265
|
+
relationship[:target].symbolize_keys
|
266
|
+
relationship
|
267
|
+
end
|
268
|
+
|
269
|
+
def friendship_exists?(target, source=nil)
|
270
|
+
rel = source.nil? ? friendship_info(target) : friendship_info(target, source)
|
271
|
+
return true if rel[:source][:following] && rel[:target][:following]
|
272
|
+
false
|
273
|
+
end
|
274
|
+
|
275
|
+
def following_me?(target)
|
276
|
+
rel = friendship_info(target)
|
277
|
+
return true if rel[:source][:followed_by]
|
278
|
+
false
|
279
|
+
end
|
280
|
+
|
281
|
+
def am_i_following?(target)
|
282
|
+
rel = friendship_info(target)
|
283
|
+
return true if rel[:source][:following]
|
284
|
+
false
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
288
|
+
end
|
data/lib/tweeb_search.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "httparty"
|
3
|
+
require File.join(File.dirname(__FILE__), "tweeb_search_error.rb")
|
4
|
+
|
5
|
+
module Tweeb
|
6
|
+
class Search
|
7
|
+
include HTTParty
|
8
|
+
base_uri "http://search.twitter.com"
|
9
|
+
format :json
|
10
|
+
|
11
|
+
def search(query, options={})
|
12
|
+
if options.empty?
|
13
|
+
json = self.class.get("/search.json", :query => {:q => query})
|
14
|
+
else
|
15
|
+
if options[:rpp] && options[:rpp] > 100
|
16
|
+
raise Tweeb::SearchError, "rpp parameter must be < 100"
|
17
|
+
end
|
18
|
+
if options[:rpp] && options[:page] && (options[:rpp] * options[:page]) > 1500
|
19
|
+
raise Tweeb::SearchError, "A maximum of 1500 tweets can be returned. Either lower rpp, or lower page options."
|
20
|
+
end
|
21
|
+
json = self.class.get("/search.json", :query => {:q => query}.merge(options))
|
22
|
+
end
|
23
|
+
return json
|
24
|
+
end
|
25
|
+
|
26
|
+
def trends
|
27
|
+
json = self.class.get("/trends.json")
|
28
|
+
end
|
29
|
+
|
30
|
+
def current_trends
|
31
|
+
json = self.class.get("/trends/current.json")
|
32
|
+
end
|
33
|
+
|
34
|
+
def daily_trends
|
35
|
+
json = self.class.get("/trends/daily.json")
|
36
|
+
end
|
37
|
+
|
38
|
+
def weekly_trends
|
39
|
+
json = self.class.get("/trends/weekly.json")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/tweeb_stream.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "rubygems"
|
3
|
+
require "yajl/http_stream"
|
4
|
+
|
5
|
+
module Tweeb
|
6
|
+
class Stream
|
7
|
+
|
8
|
+
def initialize(username, password)
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
@url = URI.parse("http://#{@username}:#{@password}@stream.twitter.com")
|
12
|
+
end
|
13
|
+
|
14
|
+
def spritzer(&block)
|
15
|
+
@url.path = "/spritzer.json"
|
16
|
+
Yajl::HttpStream.get(@url, :symbolize_keys => true) do |json|
|
17
|
+
block.call(json)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "a Tweeb::Client instance" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@auth_info = YAML.load_file("test_auth.yml")["twitter_auth"]
|
7
|
+
@tweeb = Tweeb::Client.new(@auth_info["username"], @auth_info["password"])
|
8
|
+
end
|
9
|
+
|
10
|
+
tweeb_object = lambda {|obj| obj.is_a?(Tweeb::Client) }
|
11
|
+
it "should return an object of class Tweeb::Client" do
|
12
|
+
@tweeb.should.be.a tweeb_object
|
13
|
+
end
|
14
|
+
|
15
|
+
array_with_hash = lambda {|obj| obj.is_a?(Array) && obj.first.is_a?(Hash) }
|
16
|
+
it "should return an array of hashes for public_timeline" do
|
17
|
+
@tweeb.public_timeline.should.be.a array_with_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return an array of hashes for user_timeline" do
|
21
|
+
@tweeb.user_timeline.should.be.a array_with_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return an array of hashes for friends_timeline" do
|
25
|
+
@tweeb.friends_timeline.should.be.a array_with_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should throw a Tweeb::ClientError when the public timeline's count option is too high" do
|
29
|
+
should.raise(Tweeb::ClientError) { @tweeb.public_timeline(:count => 400) }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should throw a Tweeb::ClientError when the user timeline's count option is too high" do
|
33
|
+
should.raise(Tweeb::ClientError) { @tweeb.user_timeline(:count => 400) }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should throw a Tweeb::ClientError when the friends timeline's count option is too high" do
|
37
|
+
should.raise(Tweeb::ClientError) { @tweeb.friends_timeline(:count => 400) }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "a Tweeb::Stream instance" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@auth_info = YAML.load_file("test_auth.yml")["twitter_auth"]
|
7
|
+
@tweeb = Tweeb::Stream.new(@auth_info["username"], @auth_info["password"])
|
8
|
+
end
|
9
|
+
|
10
|
+
tweeb_stream_object = lambda {|obj| obj.is_a?(Tweeb::Stream) }
|
11
|
+
it "should return an object of class Tweeb::Stream" do
|
12
|
+
@tweeb.should.be.a tweeb_object
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "a Tweeb::Stream instance" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@auth_info = YAML.load_file("test_auth.yml")["twitter_auth"]
|
7
|
+
@tweeb = Tweeb::Stream.new(@auth_info["username"], @auth_info["password"])
|
8
|
+
end
|
9
|
+
|
10
|
+
tweeb_stream_object = lambda {|obj| obj.is_a?(Tweeb::Stream) }
|
11
|
+
it "should return an object of class Tweeb::Stream" do
|
12
|
+
@tweeb.should.be.a tweeb_object
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mikedamage-tweeb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Green
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-15 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: jnunemaker-httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.4.3
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: mike.is.green@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.textile
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.textile
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- lib/tweeb.rb
|
42
|
+
- lib/tweeb_client.rb
|
43
|
+
- lib/tweeb_client_error.rb
|
44
|
+
- lib/tweeb_search.rb
|
45
|
+
- lib/tweeb_search_error.rb
|
46
|
+
- lib/tweeb_stream.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
- spec/test_auth.yml.example
|
49
|
+
- spec/tweeb_client_spec.rb
|
50
|
+
- spec/tweeb_search_spec.rb
|
51
|
+
- spec/tweeb_stream_spec.rb
|
52
|
+
has_rdoc: false
|
53
|
+
homepage: http://github.com/mikedamage/tweeb
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Tweeb is a really simple, bare bones Twitter library made possible by HTTParty
|
78
|
+
test_files:
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/tweeb_client_spec.rb
|
81
|
+
- spec/tweeb_search_spec.rb
|
82
|
+
- spec/tweeb_stream_spec.rb
|