rubytter 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -7
- data/Rakefile +1 -0
- data/examples/direct_message.rb +1 -1
- data/examples/favorite.rb +1 -1
- data/examples/follow.rb +1 -1
- data/examples/friends_timeline.rb +1 -1
- data/examples/limit.rb +1 -1
- data/examples/replies.rb +1 -1
- data/examples/search.rb +1 -1
- data/examples/update_status.rb +1 -1
- data/examples/user.rb +1 -1
- data/lib/rubytter/connection.rb +1 -0
- data/lib/rubytter.rb +11 -4
- data/spec/rubytter_spec.rb +22 -5
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -46,14 +46,16 @@ implemented API methods:
|
|
46
46
|
|
47
47
|
== SYNOPSIS:
|
48
48
|
|
49
|
-
|
49
|
+
initialize:
|
50
50
|
|
51
51
|
client = Rubytter.new(user_id, password)
|
52
|
+
|
53
|
+
update status:
|
54
|
+
|
52
55
|
client.update('hello twitter!!')
|
53
56
|
|
54
|
-
get friends timeline
|
57
|
+
get friends timeline:
|
55
58
|
|
56
|
-
client = Rubytter.new(user_id, password)
|
57
59
|
client.friends_timeline.each do |status|
|
58
60
|
puts "#{status.user.screen_name}: #{status.text}"
|
59
61
|
end
|
@@ -75,10 +77,6 @@ or
|
|
75
77
|
gem source -a http://gems.github.com
|
76
78
|
sudo gem install jugyo-rubytter
|
77
79
|
|
78
|
-
== TODO:
|
79
|
-
|
80
|
-
- search
|
81
|
-
|
82
80
|
== LICENSE:
|
83
81
|
|
84
82
|
(The MIT License)
|
data/Rakefile
CHANGED
data/examples/direct_message.rb
CHANGED
data/examples/favorite.rb
CHANGED
data/examples/follow.rb
CHANGED
data/examples/limit.rb
CHANGED
data/examples/replies.rb
CHANGED
data/examples/search.rb
CHANGED
data/examples/update_status.rb
CHANGED
data/examples/user.rb
CHANGED
data/lib/rubytter/connection.rb
CHANGED
data/lib/rubytter.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'rubygems'
|
2
3
|
require 'json'
|
3
4
|
require 'net/https'
|
@@ -15,9 +16,7 @@ class Rubytter
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
VERSION = '0.4.8'
|
20
|
-
HOMEPAGE = 'http://github.com/jugyo/rubytter'
|
19
|
+
VERSION = '0.5.0'
|
21
20
|
|
22
21
|
attr_reader :login
|
23
22
|
attr_accessor :host, :header
|
@@ -26,7 +25,9 @@ class Rubytter
|
|
26
25
|
@login = login
|
27
26
|
@password = password
|
28
27
|
@host = options[:host] || 'twitter.com'
|
29
|
-
@header =
|
28
|
+
@header = {'User-Agent' => "Rubytter/#{VERSION} (http://github.com/jugyo/rubytter)"}
|
29
|
+
@header.merge!(options[:header]) if options[:header]
|
30
|
+
@app_name = options[:app_name]
|
30
31
|
@connection = Connection.new(options)
|
31
32
|
end
|
32
33
|
|
@@ -86,6 +87,12 @@ class Rubytter
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
90
|
+
alias_method :__update_status, :update_status
|
91
|
+
def update_status(params = {})
|
92
|
+
params[:source] = @app_name if @app_name
|
93
|
+
__update_status(params)
|
94
|
+
end
|
95
|
+
|
89
96
|
def update(status, params = {})
|
90
97
|
update_status(params.merge({:status => status}))
|
91
98
|
end
|
data/spec/rubytter_spec.rb
CHANGED
@@ -135,17 +135,29 @@ class Rubytter
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'should raise when call to_param_str with invalid arg' do
|
138
|
-
lambda { @rubytter.to_param_str(nil) }.should raise_error
|
139
|
-
lambda { @rubytter.to_param_str('foo') }.should raise_error
|
140
|
-
lambda { @rubytter.to_param_str(:bar) }.should raise_error
|
138
|
+
lambda { @rubytter.to_param_str(nil) }.should raise_error(ArgumentError)
|
139
|
+
lambda { @rubytter.to_param_str('foo') }.should raise_error(ArgumentError)
|
140
|
+
lambda { @rubytter.to_param_str(:bar) }.should raise_error(ArgumentError)
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should set default header' do
|
144
144
|
rubytter = Rubytter.new('test', 'test')
|
145
|
-
rubytter.header.should == {'User-Agent', "
|
145
|
+
rubytter.header.should == {'User-Agent', "Rubytter/#{VERSION} (http://github.com/jugyo/rubytter)"}
|
146
146
|
end
|
147
147
|
|
148
|
-
it 'should able to set custom header' do
|
148
|
+
it 'should able to set custom header 1' do
|
149
|
+
rubytter = Rubytter.new('test', 'test',
|
150
|
+
{
|
151
|
+
:header => {
|
152
|
+
'foo' => 'bar'
|
153
|
+
}
|
154
|
+
}
|
155
|
+
)
|
156
|
+
rubytter.header['foo'].should == 'bar'
|
157
|
+
rubytter.header.has_key?('User-Agent').should == true
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should able to set custom header 2' do
|
149
161
|
rubytter = Rubytter.new('test', 'test',
|
150
162
|
{
|
151
163
|
:header => {
|
@@ -180,5 +192,10 @@ class Rubytter
|
|
180
192
|
lambda {struct.regex}.should raise_error(NoMethodError)
|
181
193
|
end
|
182
194
|
|
195
|
+
it 'should be set app_name' do
|
196
|
+
rubytter = Rubytter.new('test', 'teat', :app_name => "Foo")
|
197
|
+
rubytter.should_receive(:__update_status).with({:status => 'test', :source => "Foo"})
|
198
|
+
rubytter.update('test')
|
199
|
+
end
|
183
200
|
end
|
184
201
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubytter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-19 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|