pupil 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -1
- data/README.ja.md +104 -0
- data/README.md +7 -6
- data/VERSION +1 -1
- data/lib/pupil/account.rb +1 -1
- data/lib/pupil/direct_messages.rb +18 -37
- data/lib/pupil/essentials.rb +6 -0
- data/lib/pupil/friendships.rb +32 -0
- data/lib/pupil/general.rb +33 -0
- data/lib/pupil/help.rb +6 -0
- data/lib/pupil/lists.rb +2 -2
- data/lib/pupil/schemes.rb +45 -3
- data/lib/pupil/statuses.rb +62 -2
- data/lib/pupil/stream/base.rb +14 -7
- data/lib/pupil/users.rb +10 -5
- data/lib/pupil.rb +3 -1
- data/pupil.gemspec +7 -3
- data/samples/key-generator.rb +8 -0
- data/samples/userstream-test.rb +19 -0
- metadata +21 -17
- data/samples/ff-dumper.rb +0 -19
- data/samples/generate-key.rb +0 -8
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.3
|
2
|
+
----------------
|
3
|
+
|
4
|
+
* Unknown resistance function are supported.<br />
|
5
|
+
If called method is not implemented, Pupil recognize API endpoint by method name and tries access to unknown API automatically.<br />
|
6
|
+
e.g. pupil.account_totals => GET /1/account/totals.json
|
7
|
+
* Stream::Hash support
|
8
|
+
|
1
9
|
0.2.2
|
2
10
|
----------------
|
3
11
|
|
@@ -10,6 +18,7 @@
|
|
10
18
|
----------------
|
11
19
|
|
12
20
|
* Some bug fixed.
|
21
|
+
>>>>>>> e610d08ead13da72fbda4b280c421d0c2ab6c77d
|
13
22
|
|
14
23
|
0.2.0
|
15
24
|
----------------
|
@@ -24,7 +33,7 @@
|
|
24
33
|
`status.destroy`
|
25
34
|
* Mutable scheme are supported. When Twitter REST API is changed, Schemes correspond to it automatically.
|
26
35
|
* New ways to distinguish screen_name from user_id.
|
27
|
-
If methods catch parameter of number, recognize it as
|
36
|
+
If methods catch parameter of number, recognize it as user_id.
|
28
37
|
* Almost Lists API are supported.
|
29
38
|
|
30
39
|
0.1.5
|
data/README.ja.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
Pupil
|
2
|
+
=============
|
3
|
+
|
4
|
+
Pupil はRuby 1.9.xのための"怠惰"なTwitter APIライブラリです。
|
5
|
+
|
6
|
+
フューチャー
|
7
|
+
-------------
|
8
|
+
|
9
|
+
* 殆どのREST APIをサポートしていますが、一部のAPIはサポートされていません。
|
10
|
+
* Twitter Streaming APIを実験的にサポート
|
11
|
+
* Rubyライクな直感的で書きやすい文法
|
12
|
+
|
13
|
+
問題
|
14
|
+
-------------
|
15
|
+
|
16
|
+
* 一部のAPIをサポートしていません
|
17
|
+
|
18
|
+
動作環境
|
19
|
+
-------------
|
20
|
+
|
21
|
+
* json及びoauth gem
|
22
|
+
* Ruby 1.9.x
|
23
|
+
|
24
|
+
インストール
|
25
|
+
-------------
|
26
|
+
|
27
|
+
gem install pupil
|
28
|
+
|
29
|
+
簡単な使用例
|
30
|
+
-------------
|
31
|
+
|
32
|
+
require "pupil"
|
33
|
+
|
34
|
+
oauth_key = {
|
35
|
+
:consumer_key => "something",
|
36
|
+
:consumer_secret => "something",
|
37
|
+
:access_token => "something",
|
38
|
+
:access_token_secret => "something"
|
39
|
+
}
|
40
|
+
|
41
|
+
pupil = Pupil.new oauth_key
|
42
|
+
|
43
|
+
# リプライが含まれないタイムラインを取得する
|
44
|
+
pupil.timeline :count => 50, :exclude => :replies
|
45
|
+
|
46
|
+
# @twitterapi をフォローする
|
47
|
+
pupil.follow :twitterapi
|
48
|
+
|
49
|
+
# プロフィールのURLをアップデートする
|
50
|
+
pupil.update_profile :url => "http://oameya.com"
|
51
|
+
|
52
|
+
Streaming API を使ってみる
|
53
|
+
|
54
|
+
require "pupil/stream"
|
55
|
+
|
56
|
+
oauth_key = {
|
57
|
+
:consumer_key => "something",
|
58
|
+
:consumer_secret => "something",
|
59
|
+
:access_token => "something",
|
60
|
+
:access_token_secret => "something"
|
61
|
+
}
|
62
|
+
|
63
|
+
stream = Pupil::Stream.new oauth_key
|
64
|
+
|
65
|
+
# ユーザーストリーム
|
66
|
+
stream.start :userstream do |status|
|
67
|
+
if status.event == :retweeted
|
68
|
+
puts "これはリツイートされた呟きです! => #{status.text}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# 検索ストリーム
|
73
|
+
stream.start :search, :track => "#メリークリスマス" do |status|
|
74
|
+
puts "メリー・クリスマス、#{status.user.screen_name}!"
|
75
|
+
end
|
76
|
+
|
77
|
+
`oauth_key` を作る
|
78
|
+
|
79
|
+
require "pupil/keygen"
|
80
|
+
|
81
|
+
keygen = Pupil::Keygen.new
|
82
|
+
keygen.interactive #=> インタラクティブにoauth_keyを生成
|
83
|
+
|
84
|
+
協力
|
85
|
+
-------------
|
86
|
+
|
87
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
88
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
89
|
+
* Fork the project
|
90
|
+
* Start a feature/bugfix branch
|
91
|
+
* Commit and push until you are happy with your contribution
|
92
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
93
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
94
|
+
|
95
|
+
クレジット
|
96
|
+
-------------
|
97
|
+
|
98
|
+
開発者: [おおあめ](http://twitter.com/o_ame)
|
99
|
+
|
100
|
+
ライセンス
|
101
|
+
-------------
|
102
|
+
|
103
|
+
Copyright (c) 2011 おおあめ. LICENSE.txt を見て詳しい情報を得てください。
|
104
|
+
|
data/README.md
CHANGED
@@ -28,15 +28,16 @@ Installation
|
|
28
28
|
|
29
29
|
Examples
|
30
30
|
-------------
|
31
|
+
|
31
32
|
require "pupil"
|
32
33
|
|
33
34
|
oauth_key = {
|
34
|
-
|
35
|
-
:consumer_secret => "something",
|
36
|
-
:access_token => "something",
|
37
|
-
:access_token_secret => "something"
|
35
|
+
:consumer_key => "something",
|
36
|
+
:consumer_secret => "something",
|
37
|
+
:access_token => "something",
|
38
|
+
:access_token_secret => "something"
|
38
39
|
}
|
39
|
-
|
40
|
+
|
40
41
|
pupil = Pupil.new oauth_key
|
41
42
|
|
42
43
|
# Get timeline statuses without replies
|
@@ -73,7 +74,7 @@ Using Streaming API
|
|
73
74
|
puts "Merry christmas, #{status.user.screen_name}!"
|
74
75
|
end
|
75
76
|
|
76
|
-
Making `
|
77
|
+
Making `oauth_key`
|
77
78
|
|
78
79
|
require "pupil/keygen"
|
79
80
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/pupil/account.rb
CHANGED
@@ -35,7 +35,7 @@ class Pupil
|
|
35
35
|
# @option param [String] :colors #=> :sidebar_border
|
36
36
|
# @option param [String] :colors #=> :sidebar_fill
|
37
37
|
# @option param [String] :colors #=> :text
|
38
|
-
def update_profile
|
38
|
+
def update_profile(param)
|
39
39
|
if param.key? :colors
|
40
40
|
opt = Hash.new
|
41
41
|
opt.update({:profile_background_color => param[:colors][:background]}) if param[:colors][:background]
|
@@ -2,21 +2,14 @@ class Pupil
|
|
2
2
|
# Returning direct messages
|
3
3
|
# @param [Hash] param
|
4
4
|
# @return [Hash] directmessages
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
response = @access_token.get("http://api.twitter.com/1/direct_messages.xml"+param_s)
|
9
|
-
rescue
|
10
|
-
return false
|
11
|
-
end
|
12
|
-
doc = REXML::Document.new(response.body)
|
13
|
-
return false if doc.is_error?
|
5
|
+
def direct_messages(param = {})
|
6
|
+
response = self.get("/1/direct_messages.json", param)
|
7
|
+
return false unless response
|
14
8
|
directmessages = Array.new
|
15
|
-
|
16
|
-
|
17
|
-
dm = DirectMessage.new(element)
|
9
|
+
response.each do |element|
|
10
|
+
dm = DirectMessage.new(element, @access_token)
|
18
11
|
directmessages << dm
|
19
|
-
|
12
|
+
end
|
20
13
|
|
21
14
|
return directmessages
|
22
15
|
end
|
@@ -24,34 +17,22 @@ class Pupil
|
|
24
17
|
# Returning direct messages you sent
|
25
18
|
# @param [Hash] param
|
26
19
|
# @return [Hash] directmessage you sent
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
response = @access_token.get("http://api.twitter.com/1/direct_messages/sent.xml"+param_s)
|
31
|
-
rescue
|
32
|
-
return false
|
33
|
-
end
|
34
|
-
doc = REXML::Document.new(response.body)
|
35
|
-
return false if doc.is_error?
|
20
|
+
def sent_direct_messages(param = {})
|
21
|
+
response = self.get("/1/direct_messages/sent.json", param)
|
22
|
+
return false unless response
|
36
23
|
directmessages = Array.new
|
37
|
-
|
38
|
-
|
39
|
-
dm = DirectMessage.new(element)
|
24
|
+
response.each do |element|
|
25
|
+
dm = DirectMessage.new(element, @access_token)
|
40
26
|
directmessages << dm
|
41
|
-
|
27
|
+
end
|
42
28
|
|
43
29
|
return directmessages
|
44
30
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
response = @access_token.post("http://api.twitter.com/1/direct_messages/destroy/#{dm_id}.xml")
|
52
|
-
rescue
|
53
|
-
return false
|
54
|
-
end
|
55
|
-
return response
|
31
|
+
|
32
|
+
def send_direct_message(sentence, opts)
|
33
|
+
raise ArgumentError, ":to parameter not given" unless opts[:to]
|
34
|
+
response = self.post("/1/direct_messages/new.json", {:text => sentence, guess_parameter(opts[:to]) => opts[:to]})
|
35
|
+
return false unless response
|
36
|
+
response
|
56
37
|
end
|
57
38
|
end
|
data/lib/pupil/essentials.rb
CHANGED
data/lib/pupil/friendships.rb
CHANGED
@@ -21,6 +21,32 @@ class Pupil
|
|
21
21
|
return ids
|
22
22
|
end
|
23
23
|
|
24
|
+
def no_retweet_ids()
|
25
|
+
response = self.get("/1/friendships/no_retweet_ids.json")
|
26
|
+
return false unless response
|
27
|
+
return response
|
28
|
+
end
|
29
|
+
|
30
|
+
def outgoing(param={})
|
31
|
+
response = self.get("/1/friendships/outgoing.json")
|
32
|
+
return false unless response
|
33
|
+
ids = []
|
34
|
+
response["ids"].each do |element|
|
35
|
+
ids << element
|
36
|
+
end
|
37
|
+
return ids
|
38
|
+
end
|
39
|
+
|
40
|
+
def incoming(param={})
|
41
|
+
response = self.get("/1/friendships/incoming.json")
|
42
|
+
return false unless response
|
43
|
+
ids = []
|
44
|
+
response["ids"].each do |element|
|
45
|
+
ids << element
|
46
|
+
end
|
47
|
+
return ids
|
48
|
+
end
|
49
|
+
|
24
50
|
# Check friendships
|
25
51
|
# @param [String] src source screen_name
|
26
52
|
# @param [String] dst destination screen_name
|
@@ -38,6 +64,12 @@ class Pupil
|
|
38
64
|
|
39
65
|
alias_method "relationship?", "friendship?"
|
40
66
|
alias_method "friendships_exists?", "friendship?"
|
67
|
+
|
68
|
+
def update_friendships(target, param)
|
69
|
+
response = self.post("/1/friendships/update.json", param)
|
70
|
+
return false unless response
|
71
|
+
return response
|
72
|
+
end
|
41
73
|
|
42
74
|
# Follow user for screen_name
|
43
75
|
# @param [String] name screen_name
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Pupil
|
2
|
+
def lookup(opts, option={})
|
3
|
+
target, source = opts.to_a.first
|
4
|
+
case target
|
5
|
+
when :users
|
6
|
+
response = self.get("/1/users/lookup.json", {guess_parameter(source[0]) => source.join(",")}.update(option))
|
7
|
+
return false unless response
|
8
|
+
users = Array.new
|
9
|
+
response.each do |element|
|
10
|
+
user = User.new(element, @access_token)
|
11
|
+
users << user
|
12
|
+
end
|
13
|
+
return users
|
14
|
+
when :friendships
|
15
|
+
response = self.get("/1/friendships/lookup.json", {guess_parameter(source[0]) => source.join(",")}.update(option))
|
16
|
+
return false unless response
|
17
|
+
fs = Array.new
|
18
|
+
response.each do |element|
|
19
|
+
fs << element
|
20
|
+
end
|
21
|
+
return fs
|
22
|
+
else
|
23
|
+
raise ArgumentError, "#{target} is invalid parameter"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(action, *args)
|
28
|
+
# e.g. pupil.users_search("username", :method => :post)
|
29
|
+
url = "/1/#{action.to_s.split('_').join('/')}.json"
|
30
|
+
response = self.get(url, args)
|
31
|
+
return response
|
32
|
+
end
|
33
|
+
end
|
data/lib/pupil/help.rb
ADDED
data/lib/pupil/lists.rb
CHANGED
@@ -15,8 +15,8 @@ class Pupil
|
|
15
15
|
return lists
|
16
16
|
end
|
17
17
|
|
18
|
-
def create_list(name,
|
19
|
-
response = self.post("/1/lists/create.json", {:name => name}.update(
|
18
|
+
def create_list(name, option={})
|
19
|
+
response = self.post("/1/lists/create.json", {:name => name}.update(option))
|
20
20
|
return List.new(response, @access_token)
|
21
21
|
end
|
22
22
|
end
|
data/lib/pupil/schemes.rb
CHANGED
@@ -14,7 +14,7 @@ class Pupil
|
|
14
14
|
@element = element
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def params() @element.keys.map{|k|k.to_sym} ; end
|
18
18
|
end
|
19
19
|
|
20
20
|
class User < Scheme
|
@@ -42,11 +42,41 @@ class Pupil
|
|
42
42
|
|
43
43
|
def entities() Pupil::Entities.new(@element["entities"]) rescue nil; end
|
44
44
|
|
45
|
-
def destroy()
|
46
|
-
self.post("/1/statuses/destroy/#{@element["id"]}.json")
|
45
|
+
def destroy(param={})
|
46
|
+
self.post("/1/statuses/destroy/#{@element["id"]}.json", param)
|
47
47
|
end
|
48
48
|
|
49
49
|
alias_method :delete, :destroy
|
50
|
+
|
51
|
+
def retweet(param={})
|
52
|
+
self.post("/1/statuses/retweet/#{@element["id"]}.json", param)
|
53
|
+
end
|
54
|
+
|
55
|
+
def retweets(param={})
|
56
|
+
response = self.get("/1/statuses/retweets/#{@element["id"]}.json", param)
|
57
|
+
return false unless response
|
58
|
+
statuses = []
|
59
|
+
response.each do |status|
|
60
|
+
statuses << Pupil::Status.new(status, @access_token)
|
61
|
+
end
|
62
|
+
return statuses
|
63
|
+
end
|
64
|
+
|
65
|
+
def retweeted_by(param={})
|
66
|
+
response = self.get("/1/statuses/#{@element["id"]}/retweeted_by.json", param)
|
67
|
+
return false unless response
|
68
|
+
users = []
|
69
|
+
response.each do |user|
|
70
|
+
users << Pupil::User.new(user, @access_token)
|
71
|
+
end
|
72
|
+
return users
|
73
|
+
end
|
74
|
+
|
75
|
+
def retweeted_by_user_ids(param={})
|
76
|
+
response = self.get("/1/statuses/#{@element["id"]}/retweeted_by/ids.json", param)
|
77
|
+
return false unless response
|
78
|
+
return response
|
79
|
+
end
|
50
80
|
end
|
51
81
|
|
52
82
|
class List < Scheme
|
@@ -145,5 +175,17 @@ class Pupil
|
|
145
175
|
class DirectMessage < Scheme
|
146
176
|
def sender() Pupil::User.new(@element["sender"], @access_token) rescue nil; end
|
147
177
|
def recipient() Pupil::User.new(@element["recipient"], @access_token) rescue nil; end
|
178
|
+
|
179
|
+
# Delete direct message
|
180
|
+
# @param [Fixnum] dm_id message id that you want to delete
|
181
|
+
# @return [Hash] response
|
182
|
+
def destroy()
|
183
|
+
begin
|
184
|
+
response = self.post("/1/direct_messages/destroy/#{@element["id"]}.json")
|
185
|
+
rescue
|
186
|
+
return false
|
187
|
+
end
|
188
|
+
return response
|
189
|
+
end
|
148
190
|
end
|
149
191
|
end
|
data/lib/pupil/statuses.rb
CHANGED
@@ -53,8 +53,8 @@ class Pupil
|
|
53
53
|
# twitter.user_timeline(:screen_name => 'o_ame', :exclude => :replies).each do |status|
|
54
54
|
# puts "#{status.user.screen_name}: #{status.text}"
|
55
55
|
# end
|
56
|
-
def user_timeline(
|
57
|
-
response = self.get("/1/statuses/user_timeline.json", {guess_parameter(
|
56
|
+
def user_timeline(target, option={})
|
57
|
+
response = self.get("/1/statuses/user_timeline.json", {guess_parameter(target) => target}.update(option))
|
58
58
|
return false unless response
|
59
59
|
statuses = []
|
60
60
|
response.each do |element|
|
@@ -80,6 +80,66 @@ class Pupil
|
|
80
80
|
return statuses
|
81
81
|
end
|
82
82
|
|
83
|
+
def retweeted_by_me(param={})
|
84
|
+
response = self.get("/1/statuses/retweeted_by_me.json", param)
|
85
|
+
return false unless response
|
86
|
+
statuses = Array.new
|
87
|
+
response.each do |element|
|
88
|
+
status = Status.new(element, @access_token)
|
89
|
+
statuses << status
|
90
|
+
end
|
91
|
+
return statuses
|
92
|
+
end
|
93
|
+
|
94
|
+
def retweeted_to_me(param={})
|
95
|
+
response = self.get("/1/statuses/retweeted_to_me.json", param)
|
96
|
+
return false unless response
|
97
|
+
statuses = Array.new
|
98
|
+
response.each do |element|
|
99
|
+
status = Status.new(element, @access_token)
|
100
|
+
statuses << status
|
101
|
+
end
|
102
|
+
return statuses
|
103
|
+
end
|
104
|
+
|
105
|
+
def retweets_of_me(param={})
|
106
|
+
response = self.get("/1/statuses/retweets_of_me.json", param)
|
107
|
+
return false unless response
|
108
|
+
statuses = Array.new
|
109
|
+
response.each do |element|
|
110
|
+
status = Status.new(element, @access_token)
|
111
|
+
statuses << status
|
112
|
+
end
|
113
|
+
return statuses
|
114
|
+
end
|
115
|
+
|
116
|
+
def retweeted_to_user(param={})
|
117
|
+
response = self.get("/1/statuses/retweeted_to_user.json", param)
|
118
|
+
return false unless response
|
119
|
+
statuses = Array.new
|
120
|
+
response.each do |element|
|
121
|
+
status = Status.new(element, @access_token)
|
122
|
+
statuses << status
|
123
|
+
end
|
124
|
+
return statuses
|
125
|
+
end
|
126
|
+
|
127
|
+
def retweeted_by_user(param={})
|
128
|
+
response = self.get("/1/statuses/retweeted_by_user.json", param)
|
129
|
+
return false unless response
|
130
|
+
statuses = Array.new
|
131
|
+
response.each do |element|
|
132
|
+
status = Status.new(element, @access_token)
|
133
|
+
statuses << status
|
134
|
+
end
|
135
|
+
return statuses
|
136
|
+
end
|
137
|
+
|
138
|
+
def oembed(param={})
|
139
|
+
response = self.get("/1/statuses/oembed.json", param)
|
140
|
+
return response
|
141
|
+
end
|
142
|
+
|
83
143
|
def status(status_id)
|
84
144
|
response = self.get("/statuses/show/#{status_id}.json")
|
85
145
|
return false unless response
|
data/lib/pupil/stream/base.rb
CHANGED
@@ -26,9 +26,10 @@ class Pupil
|
|
26
26
|
# @return [Pupil::Stream::Shash, Pupil::Stream::Status] event variable supported :status, :retweeted, :favorite, :friends and :delete
|
27
27
|
def start(type, param=nil, &block)
|
28
28
|
raise ArgumentError unless block_given?
|
29
|
-
|
30
|
-
run_get_stream type, param, &block
|
29
|
+
run_get_stream(type, param, &block)
|
31
30
|
end
|
31
|
+
|
32
|
+
alias_method :run, :start
|
32
33
|
|
33
34
|
def run_get_stream(type, param=nil, &block)
|
34
35
|
uri = URI.parse(STREAM_APIS[type] % serialize_parameter(param))
|
@@ -65,12 +66,14 @@ class Pupil
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def guess_event status
|
68
|
-
if status["
|
69
|
-
return Pupil::Stream::Hash.new(status["
|
69
|
+
if status["event"]
|
70
|
+
return Pupil::Stream::Hash.new(status, status["event"].to_sym)
|
70
71
|
elsif status["friends"]
|
71
72
|
return Pupil::Stream::Array.new(status["friends"], :friends)
|
72
|
-
elsif status["
|
73
|
-
return Pupil::Stream::Hash.new(status, :
|
73
|
+
elsif status["delete"]
|
74
|
+
return Pupil::Stream::Hash.new(status["delete"]["status"], :delete)
|
75
|
+
elsif status["direct_message"]
|
76
|
+
return Pupil::Stream::Hash.new(status["direct_message"], :direct_message)
|
74
77
|
elsif status["retweeted_status"]
|
75
78
|
return Pupil::Stream::Status.new(status, @access_token, :retweeted)
|
76
79
|
elsif status["text"]
|
@@ -88,7 +91,7 @@ class Pupil
|
|
88
91
|
def initialize(status, access_token, event=nil)
|
89
92
|
super(status, access_token)
|
90
93
|
@event = (event)? event : :status
|
91
|
-
|
94
|
+
@retweeted_status = (event == :retweeted)? status["retweeted_status"] : nil
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
@@ -101,6 +104,10 @@ class Pupil
|
|
101
104
|
self.update(status)
|
102
105
|
@event = event
|
103
106
|
end
|
107
|
+
|
108
|
+
def method_missing(action, *args)
|
109
|
+
return self[action.to_s] rescue nil
|
110
|
+
end
|
104
111
|
end
|
105
112
|
|
106
113
|
# Stream Array
|
data/lib/pupil/users.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
class Pupil
|
2
|
-
def
|
3
|
-
response = self.get("/users/
|
2
|
+
def user(target, option={})
|
3
|
+
response = self.get("/1/users/show.json", {guess_parameter(target) => target}.update(option))
|
4
|
+
return false unless response
|
5
|
+
user = User.new(response, @access_token)
|
6
|
+
return user
|
7
|
+
end
|
8
|
+
|
9
|
+
def search_user(keyword, option={})
|
10
|
+
response = self.get("/1/users/search.json", {:q => keyword}.update(option))
|
4
11
|
users = Array.new
|
5
12
|
response.each do |element|
|
6
|
-
user = User.new
|
13
|
+
user = User.new(element, @access_token)
|
7
14
|
users << user
|
8
15
|
end
|
9
16
|
return users
|
10
17
|
end
|
11
|
-
|
12
|
-
|
13
18
|
end
|
data/lib/pupil.rb
CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH << File.dirname(File.expand_path(__FILE__)) if RUBY_VERSION >= "1.9.0
|
|
4
4
|
require "pupil/essentials"
|
5
5
|
require "pupil/base"
|
6
6
|
require "pupil/schemes"
|
7
|
+
require "pupil/general"
|
7
8
|
require "pupil/account"
|
8
9
|
require "pupil/statuses"
|
9
10
|
require "pupil/users"
|
@@ -11,4 +12,5 @@ require "pupil/direct_messages"
|
|
11
12
|
require "pupil/lists"
|
12
13
|
require "pupil/friendships"
|
13
14
|
require "pupil/blocks"
|
14
|
-
require "pupil/search"
|
15
|
+
require "pupil/search"
|
16
|
+
require "pupil/help"
|
data/pupil.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "pupil"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oame"]
|
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = "oame@oameya.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
+
"README.ja.md",
|
17
18
|
"README.md"
|
18
19
|
]
|
19
20
|
s.files = [
|
@@ -21,6 +22,7 @@ Gem::Specification.new do |s|
|
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
25
|
+
"README.ja.md",
|
24
26
|
"README.md",
|
25
27
|
"Rakefile",
|
26
28
|
"VERSION",
|
@@ -31,6 +33,8 @@ Gem::Specification.new do |s|
|
|
31
33
|
"lib/pupil/direct_messages.rb",
|
32
34
|
"lib/pupil/essentials.rb",
|
33
35
|
"lib/pupil/friendships.rb",
|
36
|
+
"lib/pupil/general.rb",
|
37
|
+
"lib/pupil/help.rb",
|
34
38
|
"lib/pupil/keygen.rb",
|
35
39
|
"lib/pupil/keygen/base.rb",
|
36
40
|
"lib/pupil/lists.rb",
|
@@ -41,8 +45,8 @@ Gem::Specification.new do |s|
|
|
41
45
|
"lib/pupil/stream/base.rb",
|
42
46
|
"lib/pupil/users.rb",
|
43
47
|
"pupil.gemspec",
|
44
|
-
"samples/
|
45
|
-
"samples/
|
48
|
+
"samples/key-generator.rb",
|
49
|
+
"samples/userstream-test.rb",
|
46
50
|
"spec/pupil_spec.rb",
|
47
51
|
"spec/spec_helper.rb"
|
48
52
|
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
# tested on 1.9.x
|
4
|
+
|
5
|
+
require "pupil/stream"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
oauth_key = {
|
9
|
+
:consumer_key => "",
|
10
|
+
:consumer_secret => "",
|
11
|
+
:access_token => "",
|
12
|
+
:access_token_secret => ""
|
13
|
+
}
|
14
|
+
|
15
|
+
ps = Pupil::Stream.new oauth_key
|
16
|
+
|
17
|
+
ps.start :userstream do |status|
|
18
|
+
puts "#{status.user.screen_name}: #{status.text}"
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &70217554580580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70217554580580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70217554579980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70217554579980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70217554579380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.3.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70217554579380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70217554242140 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.6.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70217554242140
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70217554241480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70217554241480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70217554240640 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.6.4
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70217554240640
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rcov
|
82
|
-
requirement: &
|
82
|
+
requirement: &70217554239780 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,19 +87,21 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70217554239780
|
91
91
|
description: The "Lazy" Twitter API Library for Ruby 1.9.x. Easy to use.
|
92
92
|
email: oame@oameya.com
|
93
93
|
executables: []
|
94
94
|
extensions: []
|
95
95
|
extra_rdoc_files:
|
96
96
|
- LICENSE.txt
|
97
|
+
- README.ja.md
|
97
98
|
- README.md
|
98
99
|
files:
|
99
100
|
- CHANGELOG.md
|
100
101
|
- Gemfile
|
101
102
|
- Gemfile.lock
|
102
103
|
- LICENSE.txt
|
104
|
+
- README.ja.md
|
103
105
|
- README.md
|
104
106
|
- Rakefile
|
105
107
|
- VERSION
|
@@ -110,6 +112,8 @@ files:
|
|
110
112
|
- lib/pupil/direct_messages.rb
|
111
113
|
- lib/pupil/essentials.rb
|
112
114
|
- lib/pupil/friendships.rb
|
115
|
+
- lib/pupil/general.rb
|
116
|
+
- lib/pupil/help.rb
|
113
117
|
- lib/pupil/keygen.rb
|
114
118
|
- lib/pupil/keygen/base.rb
|
115
119
|
- lib/pupil/lists.rb
|
@@ -120,8 +124,8 @@ files:
|
|
120
124
|
- lib/pupil/stream/base.rb
|
121
125
|
- lib/pupil/users.rb
|
122
126
|
- pupil.gemspec
|
123
|
-
- samples/
|
124
|
-
- samples/
|
127
|
+
- samples/key-generator.rb
|
128
|
+
- samples/userstream-test.rb
|
125
129
|
- spec/pupil_spec.rb
|
126
130
|
- spec/spec_helper.rb
|
127
131
|
homepage: http://github.com/oame/pupil
|
data/samples/ff-dumper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# only 1.9.2
|
4
|
-
|
5
|
-
$LOAD_PATH << File.join(File.dirname(File.expand_path(__FILE__)), "../")
|
6
|
-
require "lib/pupil"
|
7
|
-
require "yaml"
|
8
|
-
|
9
|
-
keygen = Pupil::Keygen.new({:consumer_key => "yIyK3TaGo5VJX7MdkS95g", :consumer_secret => "ukIvD6yqP8SNbFfaIqVNkqg08J33uvRvpGa1ktuRc"})
|
10
|
-
tokens = keygen.interactive
|
11
|
-
|
12
|
-
pupil = Pupil.new tokens
|
13
|
-
user = pupil.verify_credentials
|
14
|
-
friends = pupil.friends_ids user.screen_name
|
15
|
-
followers = pupil.followers_ids user.screen_name
|
16
|
-
|
17
|
-
open("ff.yml", "w") do |f|
|
18
|
-
f.puts({:friends => friends, :followers => followers}.to_yaml)
|
19
|
-
end
|