rubytter 0.3.5 → 0.4.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/Rakefile +43 -0
- data/examples/direct_message.rb +12 -0
- data/examples/favorite.rb +12 -0
- data/examples/follow.rb +12 -0
- data/examples/limit.rb +19 -0
- data/examples/replies.rb +14 -0
- data/examples/update_status.rb +1 -1
- data/examples/user.rb +26 -0
- data/lib/rubytter.rb +9 -8
- data/spec/rubytter_spec.rb +6 -6
- metadata +11 -4
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/lib/'
|
2
|
+
require 'rubytter'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
desc 'run all specs'
|
6
|
+
Spec::Rake::SpecTask.new do |t|
|
7
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
t.spec_opts = ['-c']
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Generate gemspec'
|
12
|
+
task :gemspec do |t|
|
13
|
+
open('rubytter.gemspec', "wb" ) do |file|
|
14
|
+
file << <<-EOS
|
15
|
+
Gem::Specification.new do |s|
|
16
|
+
s.name = 'rubytter'
|
17
|
+
s.version = '#{Rubytter::VERSION}'
|
18
|
+
s.summary = "Simple twitter client."
|
19
|
+
s.description = "Rubytter is a simple twitter client."
|
20
|
+
s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
|
21
|
+
#{Dir['spec/**/*.rb'].join(' ')}
|
22
|
+
#{Dir['examples/**/*.rb'].join(' ')}
|
23
|
+
README.rdoc
|
24
|
+
History.txt
|
25
|
+
Rakefile )
|
26
|
+
s.add_dependency("json_pure", ">= 1.1.3")
|
27
|
+
s.author = 'jugyo'
|
28
|
+
s.email = 'jugyo.org@gmail.com'
|
29
|
+
s.homepage = 'http://github.com/jugyo/rubytter'
|
30
|
+
s.rubyforge_project = 'rubytter'
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
33
|
+
s.extra_rdoc_files = ["README.rdoc", "History.txt"]
|
34
|
+
end
|
35
|
+
EOS
|
36
|
+
end
|
37
|
+
puts "Generate gemspec"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'Generate gem'
|
41
|
+
task :gem => :gemspec do |t|
|
42
|
+
system 'gem', 'build', 'rubytter.gemspec'
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubytter'
|
5
|
+
|
6
|
+
if ARGV.size < 3
|
7
|
+
puts "Usage: ruby #{File.basename(__FILE__)} user_id password id message"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
client = Rubytter.new(ARGV[0], ARGV[1])
|
12
|
+
p client.direct_message(ARGV[2], ARGV[3])
|
data/examples/follow.rb
ADDED
data/examples/limit.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubytter'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
if ARGV.size < 2
|
8
|
+
puts "Usage: ruby #{File.basename(__FILE__)} user_id password"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
client = Rubytter.new(ARGV[0], ARGV[1])
|
13
|
+
limit_status = client.limit_status
|
14
|
+
puts <<EOS
|
15
|
+
reset_time_in_seconds: #{limit_status.reset_time_in_seconds}
|
16
|
+
remaining_hits: #{limit_status.remaining_hits}
|
17
|
+
hourly_limit: #{limit_status.hourly_limit}
|
18
|
+
reset_time: #{Time.parse(limit_status.reset_time).strftime('%Y/%m/%d %X')}
|
19
|
+
EOS
|
data/examples/replies.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubytter'
|
5
|
+
|
6
|
+
if ARGV.size < 2
|
7
|
+
puts "Usage: ruby #{File.basename(__FILE__)} user_id password"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
client = Rubytter.new(ARGV[0], ARGV[1])
|
12
|
+
client.replies.each do |status|
|
13
|
+
puts "#{status.user.screen_name}: #{status.text}"
|
14
|
+
end
|
data/examples/update_status.rb
CHANGED
data/examples/user.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubytter'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
if ARGV.size < 3
|
8
|
+
puts "Usage: ruby #{File.basename(__FILE__)} user_id password id"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
client = Rubytter.new(ARGV[0], ARGV[1])
|
13
|
+
user = client.user(ARGV[2])
|
14
|
+
|
15
|
+
puts <<EOS
|
16
|
+
id: #{user.id}
|
17
|
+
name: #{user.name}
|
18
|
+
screen_name: #{user.screen_name}
|
19
|
+
url: #{user.url}
|
20
|
+
description: #{user.description}
|
21
|
+
followers: #{user.followers_count}
|
22
|
+
followings: #{user.friends_count}
|
23
|
+
time_zone: #{user.time_zone}
|
24
|
+
location: #{user.location}
|
25
|
+
created_at: #{Time.parse(user.created_at).strftime('%Y/%m/%d %X')}
|
26
|
+
EOS
|
data/lib/rubytter.rb
CHANGED
@@ -7,6 +7,7 @@ require 'rubytter/connection'
|
|
7
7
|
|
8
8
|
class Rubytter
|
9
9
|
APP_NAME = 'Rubytter'
|
10
|
+
VERSION = '0.4.0'
|
10
11
|
HOMEPAGE = 'http://github.com/jugyo/rubytter'
|
11
12
|
|
12
13
|
def initialize(login, password, options = {})
|
@@ -19,8 +20,8 @@ class Rubytter
|
|
19
20
|
def self.api_settings
|
20
21
|
# method name path for API http method
|
21
22
|
"
|
22
|
-
|
23
|
-
|
23
|
+
update_status /statuses/update post
|
24
|
+
remove_status /statuses/destroy/%s delete
|
24
25
|
public_timeline /statuses/public_timeline
|
25
26
|
friends_timeline /statuses/friends_timeline
|
26
27
|
replies /statuses/replies
|
@@ -32,20 +33,20 @@ class Rubytter
|
|
32
33
|
direct_messages /direct_messages
|
33
34
|
sent_direct_messages /direct_messages/sent
|
34
35
|
send_direct_message /direct_messages/new post
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
remove_direct_message /direct_messages/destroy/%s delete
|
37
|
+
follow /friendships/create/%s post
|
38
|
+
leave /friendships/destroy/%s delete
|
38
39
|
friendship_exists /friendships/exists
|
39
40
|
followers_ids /followers/ids/%s
|
40
41
|
friends_ids /friends/ids/%s
|
41
42
|
favorites /favorites
|
42
43
|
favorite /favorites/create/%s post
|
43
|
-
|
44
|
+
remove_favorite /favorites/destroy/%s delete
|
44
45
|
verify_credentials /account/verify_credentials get
|
45
46
|
end_session /account/end_session post
|
46
47
|
update_delivery_device /account/update_delivery_device post
|
47
48
|
update_profile_colors /account/update_profile_colors post
|
48
|
-
|
49
|
+
limit_status /account/rate_limit_status
|
49
50
|
update_profile /account/update_profile post
|
50
51
|
enable_notification /notifications/follow/%s post
|
51
52
|
disable_notification /notifications/leave/%s post
|
@@ -73,7 +74,7 @@ class Rubytter
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def update(status, params = {})
|
76
|
-
|
77
|
+
update_status(params.merge({:status => status}))
|
77
78
|
end
|
78
79
|
|
79
80
|
def direct_message(user, text, params = {})
|
data/spec/rubytter_spec.rb
CHANGED
@@ -33,7 +33,7 @@ class Rubytter
|
|
33
33
|
@rubytter.user(1)
|
34
34
|
|
35
35
|
@rubytter.should_receive(:delete).with('/statuses/destroy/1', {})
|
36
|
-
@rubytter.
|
36
|
+
@rubytter.remove_status(1)
|
37
37
|
end
|
38
38
|
|
39
39
|
# direct_messages
|
@@ -55,7 +55,7 @@ class Rubytter
|
|
55
55
|
|
56
56
|
it 'should respond to destroy_direct_message' do
|
57
57
|
@rubytter.should_receive(:delete).with('/direct_messages/destroy/1', {})
|
58
|
-
@rubytter.
|
58
|
+
@rubytter.remove_direct_message(1)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should respond to direct_message' do
|
@@ -70,21 +70,21 @@ class Rubytter
|
|
70
70
|
@rubytter.update('test')
|
71
71
|
end
|
72
72
|
|
73
|
-
it 'should respond to
|
73
|
+
it 'should respond to update_status' do
|
74
74
|
@rubytter.should_receive(:post).with('/statuses/update', {:status => 'test'})
|
75
|
-
@rubytter.
|
75
|
+
@rubytter.update_status(:status => 'test')
|
76
76
|
end
|
77
77
|
|
78
78
|
# friendship
|
79
79
|
|
80
80
|
it 'should respond to create_friendship' do
|
81
81
|
@rubytter.should_receive(:post).with('/friendships/create/test', {})
|
82
|
-
@rubytter.
|
82
|
+
@rubytter.follow('test')
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should respond to destroy_friendship' do
|
86
86
|
@rubytter.should_receive(:delete).with('/friendships/destroy/test', {})
|
87
|
-
@rubytter.
|
87
|
+
@rubytter.remove_follow('test')
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should respond to friendship_exists' do
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -32,14 +32,21 @@ extra_rdoc_files:
|
|
32
32
|
- README.rdoc
|
33
33
|
- History.txt
|
34
34
|
files:
|
35
|
-
- lib/rubytter.rb
|
36
35
|
- lib/rubytter/connection.rb
|
37
|
-
-
|
38
|
-
- examples/update_status.rb
|
36
|
+
- lib/rubytter.rb
|
39
37
|
- spec/rubytter_spec.rb
|
40
38
|
- spec/spec_helper.rb
|
39
|
+
- examples/direct_message.rb
|
40
|
+
- examples/favorite.rb
|
41
|
+
- examples/follow.rb
|
42
|
+
- examples/friends_timeline.rb
|
43
|
+
- examples/limit.rb
|
44
|
+
- examples/replies.rb
|
45
|
+
- examples/update_status.rb
|
46
|
+
- examples/user.rb
|
41
47
|
- README.rdoc
|
42
48
|
- History.txt
|
49
|
+
- Rakefile
|
43
50
|
has_rdoc: true
|
44
51
|
homepage: http://github.com/jugyo/rubytter
|
45
52
|
post_install_message:
|