webco-tuiter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
- == Tuiter 0.0.1
2
- * extracting tuiter from tuitersfera
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/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.error!}")
27
+ log("update() error: #{res.to_s}")
28
28
  res.error!
29
29
  end
30
30
  end
@@ -102,6 +102,25 @@ module Tuiter
102
102
  end
103
103
  end
104
104
 
105
+ def get_friends(options = {})
106
+ if options[:id]
107
+ query = "http://twitter.com/statuses/friends/#{options[:id]}.json"
108
+ else
109
+ query = "http://twitter.com/statuses/friends.json"
110
+ end
111
+ if options[:page]
112
+ params = "?page=#{options[:page]}"
113
+ else
114
+ params = ""
115
+ end
116
+ if res = request(query+params)
117
+ data = JSON.parse(res)
118
+ return data.map { |d| User.new(d) }
119
+ else
120
+ return nil
121
+ end
122
+ end
123
+
105
124
  def get_replies(options = {})
106
125
  query = "http://twitter.com/statuses/replies.json"
107
126
  if options[:since]
@@ -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
@@ -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}}")
@@ -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
- should "allow the user to post an update to Twitter" do
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
- @response = @client.update(@update_message)
25
-
26
- assert_instance_of Net::HTTPOK, @response
27
- end
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
- end
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
- end
64
+
65
+ end # context "A valid Tuiter client"
32
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webco-tuiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
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-04 00:00:00 -07:00
13
+ date: 2009-04-09 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency