tuiter 0.0.2 → 0.0.3
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/AUTHORS +9 -9
- data/CHANGELOG +36 -2
- data/Rakefile +9 -0
- data/lib/tuiter.log +3 -0
- data/lib/tuiter/client.rb +10 -2
- data/lib/tuiter/client.rb~ +2 -2
- data/lib/tuiter/data/rate_limit.rb +2 -2
- data/lib/tuiter/version.rb +1 -1
- data/lib/tuiter/version.rb~ +1 -1
- data/test/macros/attr_accessor_macro.rb +1 -1
- data/test/unit/client_test.rb +46 -12
- data/test/unit/rate_limit_test.rb +15 -0
- metadata +3 -3
- data/lib/tuiter.rb~ +0 -19
data/AUTHORS
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
Tuiter was design and developed by Manoel Lemos (manoel@lemos.net), to provide
|
1
|
+
Tuiter was design and developed by Manoel Lemos (manoel@lemos.net - http://www.github.com/mlemos), to provide
|
2
2
|
basic access to the Twitter API. It was developed for the experimental project
|
3
3
|
called Tuitersfera Brasil (http://tuitersfera.com.br), an application to
|
4
4
|
monitor the Twitter usage in Brazil.
|
5
5
|
|
6
|
-
Both projects were latter adopted by WebCo Internet (http://webcointernet.com).
|
6
|
+
Both projects were latter adopted by WebCo Internet (http://webcointernet.com - http://www.github.com/webco).
|
7
7
|
|
8
8
|
The authors and contributors of Tuiter are:
|
9
9
|
|
10
|
-
* Manoel Lemos (manoel@lemos.net) - initial work
|
11
|
-
* Celestino Gomes (tinorj@gmail.com)
|
12
|
-
* Leandro Silva (leandrodoze@gmail.com)
|
13
|
-
* Lucas Fais (lfais@webcointernet.com)
|
14
|
-
* Lucas Húngaro (lucashungaro@gmail.com)
|
15
|
-
* Luis Cipriani (lfcipriani@talleye.com)
|
16
|
-
* Luiz Rocha (lsdr@lsdr.net)
|
10
|
+
* Manoel Lemos (manoel@lemos.net - http://www.github.com/mlemos) - initial work
|
11
|
+
* Celestino Gomes (tinorj@gmail.com - http://www.github.com/tinogomes)
|
12
|
+
* Leandro Silva (leandrodoze@gmail.com - http://www.github.com/leandrosilva)
|
13
|
+
* Lucas Fais (lfais@webcointernet.com - http://www.github.com/lucasfais)
|
14
|
+
* Lucas Húngaro (lucashungaro@gmail.com - http://www.github.com/lucashungaro)
|
15
|
+
* Luis Cipriani (lfcipriani@talleye.com - http://www.github.com/lfcipriani)
|
16
|
+
* Luiz Rocha (lsdr@lsdr.net - http://www.github.com/lsdr)
|
17
17
|
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
-
==
|
2
|
-
|
1
|
+
== v0.0.2
|
2
|
+
* Added github profile path on AUTHORS
|
3
|
+
* Bumping version, including direct message files
|
4
|
+
* Updating AUTHORS. Giving credit where is due
|
5
|
+
* Adding DirectMessage data structure and listing method. Bumping tiny version one up
|
6
|
+
* Fixing the installation instructions on the README file
|
7
|
+
* Refactoring client tests to use fakeweb and less expectations
|
8
|
+
* Tests for StatusBasic and Status
|
9
|
+
* Tests for User, UserBasic and UserExtended - 100% tests coverage
|
10
|
+
* Added rake tasks to execute rcov
|
11
|
+
* Adding some json fixtures for testing
|
12
|
+
* Fixing a false cognate on README
|
13
|
+
* Added initial tests
|
14
|
+
* Namespace done right
|
15
|
+
* Fixed requires definitely
|
16
|
+
* Fixed requires again
|
17
|
+
* Fixed requires
|
18
|
+
* Updating README
|
19
|
+
* Updating tuiter.gemspec
|
20
|
+
* Adding a rake task to publish tuiter on Rubyforge
|
21
|
+
* Added http proxy support to all operations
|
22
|
+
* Added check RUBY_PLATFORM because JRuby does not support native extensions
|
23
|
+
* Rakefile and gemspec updated, it should work fine now
|
24
|
+
* Trying to fix the gemspec
|
25
|
+
* Small fix on tuiter gemspec
|
26
|
+
* Adding the gemspec to allow Github to generate and publish a tuiter gem
|
27
|
+
* Adding the most simple and obvious example ever
|
28
|
+
* The most simple and basic example that could ever be
|
29
|
+
* Updating .gitignore
|
30
|
+
* Adding a README, just for kicks
|
31
|
+
* Moving the requires out of the client
|
32
|
+
* Cleaning up some stuff, organizing things, the plumbing
|
33
|
+
* Adding authors, license and changelog files
|
34
|
+
|
35
|
+
== v0.0.1
|
36
|
+
* Extracting tuiter from tuitersfera
|
3
37
|
|
data/Rakefile
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "rake"
|
4
4
|
require "rake/testtask"
|
5
5
|
require "rake/rdoctask"
|
6
|
+
require 'rcov/rcovtask'
|
6
7
|
|
7
8
|
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].each do |req|
|
8
9
|
load req
|
@@ -128,5 +129,13 @@ task "publish" => "build" do
|
|
128
129
|
@rubyforge.add_release('tuiter', 'tuiter', "#{spec.version}", "#{spec.name}-#{spec.version}.gem")
|
129
130
|
end
|
130
131
|
|
132
|
+
desc "Rcov"
|
133
|
+
Rcov::RcovTask.new(:rcov) do |t|
|
134
|
+
t.pattern = ENV["FROM"] || FileList["test/**/*_test.rb"]
|
135
|
+
t.output_dir = "coverage"
|
136
|
+
t.rcov_opts = ["-x gem,TextMate", "--text-summary", "--html", "--charset UTF8"]
|
137
|
+
# t.rcov_opts = ["-x gem,TextMate", "--text-summary", "--html", "--charset UTF8"]
|
138
|
+
end
|
139
|
+
|
131
140
|
task :default => ["test"]
|
132
141
|
|
data/lib/tuiter.log
CHANGED
@@ -66,3 +66,6 @@ I, [2009-04-04T11:27:16.028439 #877] INFO -- : [Tuiter:877] Sat Apr 04 11:27:16
|
|
66
66
|
I, [2009-04-04T11:27:16.798857 #877] INFO -- : [Tuiter:877] Sat Apr 04 11:27:16 -0300 2009 : request() debug: http status is 200 OK
|
67
67
|
I, [2009-04-04T11:27:32.333157 #877] INFO -- : [Tuiter:877] Sat Apr 04 11:27:32 -0300 2009 : request() query: http://twitter.com/direct_messages.json?page=2
|
68
68
|
I, [2009-04-04T11:27:33.356890 #877] INFO -- : [Tuiter:877] Sat Apr 04 11:27:33 -0300 2009 : request() debug: http status is 200 OK
|
69
|
+
I, [2009-04-05T20:41:37.553400 #2715] INFO -- : [Tuiter:2715] Sun Apr 05 20:41:37 -0300 2009 : initialize()
|
70
|
+
I, [2009-04-05T20:41:44.512426 #2715] INFO -- : [Tuiter:2715] Sun Apr 05 20:41:44 -0300 2009 : request() query: http://twitter.com/followers/ids/el_cocho.json
|
71
|
+
I, [2009-04-05T20:41:44.995093 #2715] INFO -- : [Tuiter:2715] Sun Apr 05 20:41:44 -0300 2009 : request() debug: http status is 200 OK
|
data/lib/tuiter/client.rb
CHANGED
@@ -24,7 +24,7 @@ module Tuiter
|
|
24
24
|
log("update() success: OK")
|
25
25
|
return res # OK
|
26
26
|
else
|
27
|
-
log("update() error: #{res.
|
27
|
+
log("update() error: #{res.to_s}")
|
28
28
|
res.error!
|
29
29
|
end
|
30
30
|
end
|
@@ -101,7 +101,15 @@ module Tuiter
|
|
101
101
|
return nil
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
|
+
def get_followers_ids
|
106
|
+
if res = request("http://twitter.com/followers/ids/#{username}.json")
|
107
|
+
return JSON.parse(res)
|
108
|
+
else
|
109
|
+
return nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
105
113
|
def get_replies(options = {})
|
106
114
|
query = "http://twitter.com/statuses/replies.json"
|
107
115
|
if options[:since]
|
data/lib/tuiter/client.rb~
CHANGED
@@ -24,7 +24,7 @@ module Tuiter
|
|
24
24
|
log("update() success: OK")
|
25
25
|
return res # OK
|
26
26
|
else
|
27
|
-
log("update() error: #{res.
|
27
|
+
log("update() error: #{res.to_s}")
|
28
28
|
res.error!
|
29
29
|
end
|
30
30
|
end
|
@@ -47,7 +47,7 @@ module Tuiter
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def direct_list(options = {})
|
50
|
-
url = 'http://twitter.com/direct_messages.json'
|
50
|
+
url = 'http://twitter.com/direct_messages.json'
|
51
51
|
params = parse_options(options) || ""
|
52
52
|
|
53
53
|
if res = request(url+params)
|
@@ -10,8 +10,8 @@ module Tuiter
|
|
10
10
|
def initialize(data = nil)
|
11
11
|
unless data.nil?
|
12
12
|
@reset_time_in_seconds = Time.at(data["reset_time_in_seconds"].to_i)
|
13
|
-
@reset_time = Time.parse(data["reset_time"])
|
14
|
-
@reset_window = @reset_time - Time.now
|
13
|
+
@reset_time = Time.parse(data["reset_time"]) if data["reset_time"]
|
14
|
+
@reset_window = @reset_time - Time.now if @reset_time
|
15
15
|
@remaining_hits = data["remaining_hits"].to_i
|
16
16
|
@hourly_limit = data["hourly_limit"].to_i
|
17
17
|
end
|
data/lib/tuiter/version.rb
CHANGED
data/lib/tuiter/version.rb~
CHANGED
@@ -15,7 +15,7 @@ class Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.should_load_attribute_on_initialize(klass, attributes, expected_value = "value", setter_value = expected_value)
|
18
|
-
|
18
|
+
attributes = [attributes] unless attributes.class == Array
|
19
19
|
attributes.each do |attribute|
|
20
20
|
should "load attribute '#{attribute}' on initialize" do
|
21
21
|
data = eval("{'#{attribute}' => #{setter_value.inspect}}")
|
data/test/unit/client_test.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
3
|
class ClientTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def self.fake_web_post_on_update(message = "Ok", http_response_status = 200)
|
6
|
+
FakeWeb.register_uri(:post, "http://twitter.com/statuses/update.json", :string => message, :status => http_response_status.to_s)
|
7
|
+
end
|
4
8
|
|
5
9
|
context "A valid Tuiter client" do
|
6
10
|
|
@@ -12,21 +16,51 @@ class ClientTest < Test::Unit::TestCase
|
|
12
16
|
|
13
17
|
context "posting data" do
|
14
18
|
setup do
|
15
|
-
@update_message = "I'm fine"
|
16
|
-
FakeWeb.register_uri(:post, "http://twitter.com/statuses/update.json", :string => @update_message, :status => "200")
|
17
19
|
end
|
18
20
|
|
19
|
-
|
20
|
-
# basic authentication and form data
|
21
|
-
Net::HTTP::Post.any_instance.expects(:basic_auth).with(@username, @password)
|
22
|
-
Net::HTTP::Post.any_instance.expects(:set_form_data).with('status' => @update_message, 'in_reply_to_status_id' => nil)
|
21
|
+
context "successfully" do
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
setup do
|
24
|
+
@update_message = "I'm fine"
|
25
|
+
FakeWeb.register_uri(:post, "http://twitter.com/statuses/update.json",
|
26
|
+
:string => @update_message,
|
27
|
+
:status => "200")
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
+
should "allow the user to post an update to Twitter" do
|
31
|
+
# basic authentication and form data
|
32
|
+
Net::HTTP::Post.any_instance.expects(:basic_auth).with(@username, @password)
|
33
|
+
Net::HTTP::Post.any_instance.expects(:set_form_data).with('status' => @update_message, 'in_reply_to_status_id' => nil)
|
34
|
+
|
35
|
+
@response = @client.update(@update_message)
|
36
|
+
|
37
|
+
assert_instance_of Net::HTTPOK, @response
|
38
|
+
end
|
39
|
+
|
40
|
+
end # context "successfully"
|
41
|
+
|
42
|
+
context "some error on request" do
|
43
|
+
setup do
|
44
|
+
@update_message = "I'm fine"
|
45
|
+
FakeWeb.register_uri(:post, "http://twitter.com/statuses/update.json",
|
46
|
+
:string => "503 Service unavailable",
|
47
|
+
:status => ["503", "Service unavailable"])
|
48
|
+
end
|
49
|
+
|
50
|
+
should "raise for http response status on 503" do
|
51
|
+
Net::HTTP::Post.any_instance.expects(:basic_auth).with(@username, @password)
|
52
|
+
Net::HTTP::Post.any_instance.expects(:set_form_data).with('status' => @update_message, 'in_reply_to_status_id' => nil)
|
53
|
+
assert_raises Net::HTTPFatalError do
|
54
|
+
@response = @client.update(@update_message)
|
55
|
+
end
|
56
|
+
# assert_instance_of Net::HTTPServiceUnavailable, @response
|
57
|
+
end
|
58
|
+
|
59
|
+
end # context "some error on request"
|
60
|
+
|
61
|
+
|
62
|
+
end # context "posting data"
|
30
63
|
|
31
|
-
|
64
|
+
|
65
|
+
end # context "A valid Tuiter client"
|
32
66
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class RateLimitTest < Test::Unit::TestCase
|
4
|
+
RATE_LIMIT_ATTRIBUTES = %w(reset_time reset_time_in_seconds reset_window remaining_hits hourly_limit)
|
5
|
+
|
6
|
+
context "RateLimit" do
|
7
|
+
should_attr_accessor_for Tuiter::RateLimit, RATE_LIMIT_ATTRIBUTES
|
8
|
+
|
9
|
+
should_load_attribute_on_initialize Tuiter::RateLimit, "reset_time_in_seconds", Time.at(1234567890), 1234567890
|
10
|
+
|
11
|
+
|
12
|
+
end # context "RateLimit"
|
13
|
+
|
14
|
+
end
|
15
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manoel Lemos
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-04-
|
13
|
+
date: 2009-04-05 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- lib/tuiter/version.rb~
|
52
52
|
- lib/tuiter.log
|
53
53
|
- lib/tuiter.rb
|
54
|
-
- lib/tuiter.rb~
|
55
54
|
- examples/basic_example.rb
|
56
55
|
- test/fixtures
|
57
56
|
- test/fixtures/followers.json
|
@@ -64,6 +63,7 @@ files:
|
|
64
63
|
- test/test_helper.rb
|
65
64
|
- test/unit
|
66
65
|
- test/unit/client_test.rb
|
66
|
+
- test/unit/rate_limit_test.rb
|
67
67
|
- test/unit/status_test.rb
|
68
68
|
- test/unit/user_test.rb
|
69
69
|
has_rdoc: false
|
data/lib/tuiter.rb~
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'uri'
|
3
|
-
require 'net/http'
|
4
|
-
require 'logger'
|
5
|
-
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
libdir = File.dirname(__FILE__)
|
9
|
-
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
10
|
-
|
11
|
-
# Tuiter client and end points
|
12
|
-
require 'tuiter/client'
|
13
|
-
|
14
|
-
# Tuiter data structures
|
15
|
-
require 'tuiter/data/user'
|
16
|
-
require 'tuiter/data/status'
|
17
|
-
require 'tuiter/data/rate_limit'
|
18
|
-
require 'tuiter/data/direct_message'
|
19
|
-
|