rabbiter 2.0.2 → 2.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.
- checksums.yaml +4 -4
- data/bin/rabbiter +61 -9
- data/doc/en/index.rd +177 -0
- data/doc/en/news.rd +54 -0
- data/doc/ja/index.rd +183 -0
- data/doc/ja/news.rd +52 -0
- data/lib/rabbiter.rb +8 -153
- data/lib/rabbiter/version.rb +2 -2
- data/locale/ja/LC_MESSAGES/rabbiter.mo +0 -0
- data/po/ja/rabbiter.po +4 -21
- data/rabbiter.gemspec +3 -2
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c64d254c91883c38c15038cad942db2f369c980
|
4
|
+
data.tar.gz: dbbc7b955addd298e7fb3ebe6358158746acbf36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b132fbfdd0f515ea9d6620694ff689a55bc40dd1aa28d7f5d8f81f5acc00fedd67e5a89e19fcc23e335a5c6a8024937b427011fca431b99b2764e61acc07b5cc
|
7
|
+
data.tar.gz: 0e8933d5833f5b8d4a3f98bc80f3ac0071a706e69ed98eeb98b4d75210e26cdd7db6e40ee585c98a3a5d400b2a67af8d38498a0ea4f180fedee6bb566c236376
|
data/bin/rabbiter
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
3
|
#
|
4
|
-
# Copyright (C) 2010-
|
4
|
+
# Copyright (C) 2010-2016 Kouhei Sutou <kou@cozmixng.org>
|
5
5
|
# Copyright (C) 2010 OBATA Akio <obata@lins.jp>
|
6
6
|
#
|
7
7
|
# This program is free software; you can redistribute it and/or modify
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20
20
|
|
21
21
|
require "drb/drb"
|
22
|
+
require "uri"
|
22
23
|
|
23
24
|
require "rabbit/console"
|
24
25
|
require "rabbiter"
|
@@ -31,6 +32,7 @@ def parse(args=ARGV, logger=nil)
|
|
31
32
|
options.rabbit_uri = options.druby_uri
|
32
33
|
options.filters = []
|
33
34
|
options.user_languages = []
|
35
|
+
options.resolve_shorten_url = true
|
34
36
|
options.log_status = false
|
35
37
|
|
36
38
|
parser.separator ""
|
@@ -54,6 +56,12 @@ def parse(args=ARGV, logger=nil)
|
|
54
56
|
options.user_languages << language
|
55
57
|
end
|
56
58
|
|
59
|
+
parser.on("--[no-]resolve-shorten-url",
|
60
|
+
_("Resolve shorten URL such as https://t.co/XXX."),
|
61
|
+
"(#{options.resolve_shorten_url})") do |boolean|
|
62
|
+
options.resolve_shorten_url = boolean
|
63
|
+
end
|
64
|
+
|
57
65
|
parser.category(_("Debug"))
|
58
66
|
|
59
67
|
parser.on("--[no-]log-status",
|
@@ -65,15 +73,23 @@ end
|
|
65
73
|
|
66
74
|
def target?(status, options)
|
67
75
|
return true if options.user_languages.empty?
|
68
|
-
user = status
|
76
|
+
user = status.user
|
69
77
|
return false if user.nil?
|
70
|
-
user_lang = user
|
78
|
+
user_lang = user.lang
|
71
79
|
return false if user_lang.nil?
|
72
80
|
options.user_languages.include?(user_lang)
|
73
81
|
end
|
74
82
|
|
75
|
-
def clean_text(
|
76
|
-
|
83
|
+
def clean_text(status, options)
|
84
|
+
raw_text = status.full_text
|
85
|
+
if options.resolve_shorten_url
|
86
|
+
target_text = resolve_shorten_urls(raw_text, status, options)
|
87
|
+
else
|
88
|
+
target_text = raw_text
|
89
|
+
end
|
90
|
+
cleaned_text = remove_hash_tag(target_text, options.filters)
|
91
|
+
cleaned_text = remove_ustream_link(cleaned_text)
|
92
|
+
cleaned_text
|
77
93
|
end
|
78
94
|
|
79
95
|
def remove_hash_tag(text, filters)
|
@@ -87,8 +103,44 @@ def remove_hash_tag(text, filters)
|
|
87
103
|
text.gsub(Regexp.union(*hash_tag_regexps), "")
|
88
104
|
end
|
89
105
|
|
106
|
+
def resolve_t_co(url)
|
107
|
+
Net::HTTP.start(url.host, url.port) do |http|
|
108
|
+
response = http.head(url.path)
|
109
|
+
location = response["location"]
|
110
|
+
if location
|
111
|
+
URI(location)
|
112
|
+
else
|
113
|
+
url
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def resolve_shorten_url(url)
|
119
|
+
case url.host
|
120
|
+
when "t.co"
|
121
|
+
resolve_t_co
|
122
|
+
else
|
123
|
+
url
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def resolve_shorten_urls(raw_text, status, options)
|
128
|
+
resolved_text = raw_text.dup
|
129
|
+
target_urls = status.urls + status.media.uniq {|media| media.id}
|
130
|
+
reversed_urls = target_urls.sort_by do |url|
|
131
|
+
start_position, _ = url.indices
|
132
|
+
-start_position
|
133
|
+
end
|
134
|
+
reversed_urls.each do |url|
|
135
|
+
start_position, end_position = url.indices
|
136
|
+
resolved_url = resolve_shorten_url(url.expanded_url)
|
137
|
+
resolved_text[start_position...end_position] = resolved_url.to_s
|
138
|
+
end
|
139
|
+
resolved_text
|
140
|
+
end
|
141
|
+
|
90
142
|
def remove_ustream_link(text)
|
91
|
-
text.gsub(/\(.* live at
|
143
|
+
text.gsub(/\(.* live at https:\/\/ustre\.am\/.*\)/, "")
|
92
144
|
end
|
93
145
|
|
94
146
|
def main
|
@@ -101,11 +153,11 @@ def main
|
|
101
153
|
rabbit = DRbObject.new_with_uri(options.rabbit_uri)
|
102
154
|
client = Rabbiter::Client.new(logger)
|
103
155
|
client.start(*options.filters) do |status|
|
104
|
-
text = status
|
156
|
+
text = status.full_text
|
105
157
|
next if text.nil?
|
106
158
|
next unless target?(status, options)
|
107
|
-
text = clean_text(status
|
108
|
-
comment = "@#{status
|
159
|
+
text = clean_text(status, options)
|
160
|
+
comment = "@#{status.user.screen_name}: #{text}"
|
109
161
|
logger.info(comment)
|
110
162
|
begin
|
111
163
|
rabbit.append_comment(comment)
|
data/doc/en/index.rd
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
---
|
2
|
+
layout: en
|
3
|
+
title: Rabbiter
|
4
|
+
---
|
5
|
+
== About Rabbiter
|
6
|
+
|
7
|
+
Rabbiter is a tool that collects tweets related to the talk and sends
|
8
|
+
them to Rabbit as comments.
|
9
|
+
|
10
|
+
In public conference such as RubyKaigi, audiences tweet comments about
|
11
|
+
the listening talk to Twitter. To show the comments to your slide
|
12
|
+
showed by Rabbit, you can use Rabbiter.
|
13
|
+
|
14
|
+
If you have room to breathe, you can reply to the comments to reflect
|
15
|
+
audiences' opinions. An audience can listen your talk with some
|
16
|
+
different points of view because an audience can know other's
|
17
|
+
comments. Note that you have a risk that audiences are interested in
|
18
|
+
audiences' comments rather than your talk. You should ready your talk
|
19
|
+
to make very interesting talk rather than audiences' comments.
|
20
|
+
|
21
|
+
== Install
|
22
|
+
|
23
|
+
You can install Rabbiter by RubyGems. Required packages are also
|
24
|
+
installed.
|
25
|
+
|
26
|
+
% gem install rabbiter
|
27
|
+
|
28
|
+
=== Special OS X installation instructions
|
29
|
+
|
30
|
+
Most packages necessary for Rabbiter are commonly already installed.
|
31
|
+
|
32
|
+
You must install the ((%glib-networking%)) package. If you are using
|
33
|
+
Homebrew, use the following command to install the package:
|
34
|
+
|
35
|
+
% brew install glib-networking
|
36
|
+
|
37
|
+
== Usage
|
38
|
+
|
39
|
+
Rabbiter filters target tweets by specified keywords. It's good idea
|
40
|
+
that you use hash tag for the conference. Here is an example command
|
41
|
+
line for "#rubykaigi" hash tag:
|
42
|
+
|
43
|
+
% rabbiter --filter "#rubykaigi"
|
44
|
+
|
45
|
+
Rabbiter collects target tweets that have specified
|
46
|
+
keywords. ((-Because Rabbiter uses ((<Twitter's streaming API
|
47
|
+
API|URL:https://dev.twitter.com/docs/streaming-apis>)).-))
|
48
|
+
|
49
|
+
If you don't run Rabbit yet, the following error message will be
|
50
|
+
shown:
|
51
|
+
|
52
|
+
[ERROR]
|
53
|
+
Rabbiter: DRb::DRbConnError: druby://localhost:10101 - #<Errno::ECONNREFUSED: Connection refused - connect(2)>
|
54
|
+
|
55
|
+
You can run Rabbit before Rabbiter and Rabbiter before Rabbit. You can
|
56
|
+
show tweets from Twitter on your slide by running Rabbit after the
|
57
|
+
above error message is showen.
|
58
|
+
|
59
|
+
% rabbit rabbit-theme-bench-en.gem
|
60
|
+
|
61
|
+
This example hash tag "#rubykaigi" isn't suitable for test because
|
62
|
+
RubyKaigi isn't always sitting. "twitter" keyword is suitable for
|
63
|
+
test. Someone tweets a message that contain "twitter" at the world.
|
64
|
+
|
65
|
+
% rabbiter --filter "twitter"
|
66
|
+
|
67
|
+
Can you show tweets on your slide?
|
68
|
+
OK. Use your rest time to ready your talk.
|
69
|
+
|
70
|
+
== Advanced usage
|
71
|
+
|
72
|
+
Normally, the above description is enough. In some cases, you need
|
73
|
+
more description. The below is description for those cases.
|
74
|
+
|
75
|
+
=== Register multiple keywords
|
76
|
+
|
77
|
+
Many conferences use only one conference hash tag. But some
|
78
|
+
conferences use one ore more conference hash tags. For example, one
|
79
|
+
conference hash tag is for the whole conference and other conference
|
80
|
+
hash tag is for a session in the conference. Or you may want to
|
81
|
+
collect tweets that don't have hash tag but have related keyword. For
|
82
|
+
example, you want to collect not only "#rubykaigi" but also "Ruby".
|
83
|
+
|
84
|
+
You can use ((%--filter%)) option multiple times to specify multiple
|
85
|
+
keywords. Here is an example command line that specify "#rubykaigi"
|
86
|
+
and "Ruby" as keywords:
|
87
|
+
|
88
|
+
% rabbiter --filter "#rubykaigi" --filter "Ruby"
|
89
|
+
|
90
|
+
=== Filter by user's language
|
91
|
+
|
92
|
+
Global keyword is used all over the world. For example, "twitter" is
|
93
|
+
used all over the world. So you can collect many tweets in many
|
94
|
+
language by the keyword. If a conference is holed at Japan, tweets in
|
95
|
+
Japanese will be related to the conference but tweets in French will
|
96
|
+
not be related to the conference.
|
97
|
+
|
98
|
+
You may want to show many comments in your slides but you should show
|
99
|
+
only related comments to your talk. You can use user's language to
|
100
|
+
filter related tweets.
|
101
|
+
|
102
|
+
Here is an example command line that filters by Japanese:
|
103
|
+
|
104
|
+
% rabbiter --filter "#rubykaigi" --user-language "ja"
|
105
|
+
|
106
|
+
You can specify ((%--user-language%)) option multiple times like
|
107
|
+
((%--filter%)) option. You can collect only specified languages. Here
|
108
|
+
is an example command line that filters by Japanese or French.
|
109
|
+
|
110
|
+
% rabbiter --filter "#rubykaigi" --user-language "ja" --user-language "fr"
|
111
|
+
|
112
|
+
=== Sends comments to Rabbit that is run at other host
|
113
|
+
|
114
|
+
TODO
|
115
|
+
|
116
|
+
=== More information
|
117
|
+
|
118
|
+
You can see all available options by running with ((%--help%))
|
119
|
+
option. Look the output to find a feature what you want.
|
120
|
+
|
121
|
+
% rabbiter --help
|
122
|
+
|
123
|
+
== Authors
|
124
|
+
|
125
|
+
* Kouhei Sutou <kou@cozmixng.org>
|
126
|
+
* OBATA Akio <obata@lins.jp>
|
127
|
+
|
128
|
+
== Copyright
|
129
|
+
|
130
|
+
The code author retains copyright of the source code. In
|
131
|
+
other words the committer retains copyright of his or her
|
132
|
+
committed code and patch authors retain the copyright of
|
133
|
+
their submitted patch code.
|
134
|
+
|
135
|
+
== License
|
136
|
+
|
137
|
+
Licensed under GPLv2 or later. For more information see
|
138
|
+
'GPL' file. Provided patches, codes and so on are also
|
139
|
+
licensed under GPLv2 or later. Kouhei Sutou can change their
|
140
|
+
license. Authores of them are cosidered agreeing with those
|
141
|
+
rules when they contribute their patches, codes and so on.
|
142
|
+
|
143
|
+
== Mailing list
|
144
|
+
|
145
|
+
See ((<Rabbit's users page
|
146
|
+
|URL:http://rabbit-shocker.org/en/users.html>)).
|
147
|
+
|
148
|
+
== Join development
|
149
|
+
|
150
|
+
=== Repository
|
151
|
+
|
152
|
+
Rabbiter's repository is
|
153
|
+
((<GitHub|URL:https://github.com/rabbit-shocker/rabbiter/>)).
|
154
|
+
|
155
|
+
=== Commit mail
|
156
|
+
|
157
|
+
You can stay up to date on the latest development by
|
158
|
+
subscribing to the git commit ML. If you want to subscribe
|
159
|
+
to the ML, send an e-mail like the following.
|
160
|
+
|
161
|
+
To: commit@ml.rabbit-shocker.org
|
162
|
+
Cc: null@rabbit-shocker.org
|
163
|
+
Subject: Subscribe
|
164
|
+
|
165
|
+
Subscribe
|
166
|
+
|
167
|
+
=== Bug report
|
168
|
+
|
169
|
+
Use the mailing list or ((<Issues on
|
170
|
+
GitHub|URL:https://github.com/rabbit-shocker/rabbiter/issues>)) for
|
171
|
+
reporting a bug or a request.
|
172
|
+
|
173
|
+
== Thanks
|
174
|
+
|
175
|
+
Here is a contributor list. Thanks to them!!!
|
176
|
+
|
177
|
+
* OBATA Akio: He wrote the initial verison.
|
data/doc/en/news.rd
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
layout: en
|
3
|
+
title: News
|
4
|
+
apply_data: false
|
5
|
+
---
|
6
|
+
== 2.0.3: 2016-08-21
|
7
|
+
|
8
|
+
Un-twitter-stream-ize release!
|
9
|
+
|
10
|
+
=== Improvements
|
11
|
+
|
12
|
+
* doc: Added documents into gem.
|
13
|
+
[shocker-ja:1225] [Reported by Youhei SASAKI]
|
14
|
+
* Supported expanding shorten URLs by (({t.co})).
|
15
|
+
[shocker-ja:1228] [Suggested by OBATA Akio]
|
16
|
+
[GitHub#5] [Patch by OBATA Akio]
|
17
|
+
* Changed to use twitter gem instead of twitter-stream gem.
|
18
|
+
|
19
|
+
=== Thanks
|
20
|
+
|
21
|
+
* Youhei SASAKI
|
22
|
+
* OBATA Akio
|
23
|
+
|
24
|
+
== 2.0.2: 2014-06-05
|
25
|
+
|
26
|
+
Ruby/GIO2 2.2.0 supported release!
|
27
|
+
|
28
|
+
=== Improvements
|
29
|
+
|
30
|
+
* doc: Added description about ((%glib-networking%)) to install
|
31
|
+
documentation for OS X.
|
32
|
+
[GitHub#4] [Patch by Colin Dean]
|
33
|
+
[shocker-ja:1190] [Reported by Kazuhiro NISHIYAMA]
|
34
|
+
* Supported Ruby/GIO2 2.2.0.
|
35
|
+
|
36
|
+
=== Thanks
|
37
|
+
|
38
|
+
* Colin Dean
|
39
|
+
* Kazuhiro NISHIYAMA
|
40
|
+
|
41
|
+
== 2.0.1: 2013-08-29
|
42
|
+
|
43
|
+
A bug fix release for the first time in a year!
|
44
|
+
|
45
|
+
=== Improvements
|
46
|
+
|
47
|
+
* Supported initial setup on environments that don't support opening
|
48
|
+
a URI from GTK+ such as OS X.
|
49
|
+
|
50
|
+
== 2.0.0: 2012-08-29
|
51
|
+
|
52
|
+
The first release!
|
53
|
+
|
54
|
+
Rabbiter is derived from Rabbit package.
|
data/doc/ja/index.rd
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
---
|
2
|
+
layout: ja
|
3
|
+
title: Rabbiter
|
4
|
+
---
|
5
|
+
== Rabbiterとは
|
6
|
+
|
7
|
+
RabbiterはTwitterから発表に関連するツイートを収集して、それをコメントと
|
8
|
+
してRabbitに流しこむためのツールです。
|
9
|
+
|
10
|
+
日本Ruby会議など公開されたイベントで発表する場合は、観客が発表を聴きな
|
11
|
+
がらコメントをTwitterに書き込むことが増えてきました。Rabbiterを使うとそ
|
12
|
+
のようなコメントをRabbitで表示しているスライド中に表示することができま
|
13
|
+
す。
|
14
|
+
|
15
|
+
発表者に余裕がある場合は、発表中にそのコメントに返事をして観客の意見を
|
16
|
+
反映した発表にすることもできます。観客は他の観客のコメントも知ることが
|
17
|
+
でき、発表中に自分とは違った視点の考えを取り入れながら発表を聴くことが
|
18
|
+
できます。ただし、発表内容よりも観客のコメントの方に観客の注意が向いて
|
19
|
+
しまう危険もあることに注意してください。観客のコメントに負けないくらい
|
20
|
+
魅力的な発表となるように事前準備をしっかりしましょう。
|
21
|
+
|
22
|
+
== インストール
|
23
|
+
|
24
|
+
RubyGemsでインストールできます。関連パッケージも一緒にインストールされ
|
25
|
+
ます。
|
26
|
+
|
27
|
+
% gem install rabbiter
|
28
|
+
|
29
|
+
=== OS X特有のインストール手順
|
30
|
+
|
31
|
+
Rabbiterに必要なパッケージは自動でインストールされますが、OS Xでは足り
|
32
|
+
ないパッケージがあります。
|
33
|
+
|
34
|
+
((%glib-networking%))パッケージを自分でインストールする必要があります。
|
35
|
+
Homebrewを使っているなら以下のようにインストールしてください。
|
36
|
+
|
37
|
+
% brew install glib-networking
|
38
|
+
|
39
|
+
== 使い方
|
40
|
+
|
41
|
+
Rabbiterが収集するツイートは特定のキーワードで絞り込みます。最近のイベ
|
42
|
+
ントではイベント用のハッシュタグが指定されていることが多いので、それを
|
43
|
+
指定するのがよいでしょう。例えば、ハッシュタグが「#rubykaigi」の場合は
|
44
|
+
以下のように実行します。
|
45
|
+
|
46
|
+
% rabbiter --filter "#rubykaigi"
|
47
|
+
|
48
|
+
Rabbiterを起動した後にキーワードを含むツイートが投稿されるとすぐに収集
|
49
|
+
します((-これは((<Twitterのストリーミング
|
50
|
+
API|URL:https://dev.twitter.com/docs/streaming-apis>))というものを使っ
|
51
|
+
ているからです。-))。
|
52
|
+
|
53
|
+
Rabbitが起動していない場合は以下のようなエラーメッセージが表示されます。
|
54
|
+
|
55
|
+
[ERROR]
|
56
|
+
Rabbiter: DRb::DRbConnError: druby://localhost:10101 - #<Errno::ECONNREFUSED: 接続を拒否されました - connect(2)>
|
57
|
+
|
58
|
+
RabbitとRabbiterはどちらを先に起動しても大丈夫です。上記のエラーメッセー
|
59
|
+
ジが出力された後に以下のようにRabbitを起動してもスライド上にTwitterから
|
60
|
+
のメッセージが表示されます。
|
61
|
+
|
62
|
+
% rabbit rabbit-theme-bench-ja.gem
|
63
|
+
|
64
|
+
今回の例の「#rubykaigi」は日本Ruby会議中以外はあまり使われないのでテス
|
65
|
+
トには向いていません。動作確認をするなら「twitter」というキーワードがお
|
66
|
+
すすめです。常に世界中の誰かが「twitter」というキーワードをツイートして
|
67
|
+
います。
|
68
|
+
|
69
|
+
% rabbiter --filter "twitter"
|
70
|
+
|
71
|
+
スライドにツイートが表示されましたか?
|
72
|
+
それでは発表の準備をしっかりして発表に備えてください。
|
73
|
+
|
74
|
+
== より詳しい使い方
|
75
|
+
|
76
|
+
通常はここまで説明した使い方で十分ですが、それでは足りないこともありま
|
77
|
+
す。そのようなときのためにより詳しい使い方を説明します。
|
78
|
+
|
79
|
+
=== 複数のキーワードを登録する
|
80
|
+
|
81
|
+
多くのイベントではハッシュタグが1つですが、複数のハッシュタグを設定して
|
82
|
+
いる場合もあります。例えば、イベント全体のハッシュタグとセッションごと
|
83
|
+
のハッシュタグを設定している場合もあります。また、ハッシュタグだけでは
|
84
|
+
なく関連するキーワードを含むツイートもコメントとして取り込みたい場合が
|
85
|
+
あります。例えば、「#rubykaigi」を含むツイートだけではなく「Ruby」を含
|
86
|
+
むツイートも取り込みたいという場合です。
|
87
|
+
|
88
|
+
このように複数のキーワードを登録したい場合は((%--filter%))オプションを
|
89
|
+
キーワードの数だけ指定してください。例えば、「#rubykaigi」と「Ruby」を
|
90
|
+
キーワードとして登録したい場合は以下のようにします。
|
91
|
+
|
92
|
+
% rabbiter --filter "#rubykaigi" --filter "Ruby"
|
93
|
+
|
94
|
+
=== ユーザーの言語で絞り込む
|
95
|
+
|
96
|
+
世界的なキーワードは世界中で使われています。例えば、「twitter」というキー
|
97
|
+
ワードは世界中でツイートされているため、いろんな言語のツイートが収集さ
|
98
|
+
れます。日本で開催されているイベントでは、日本語のツイートは関連するツ
|
99
|
+
イートである可能性が高いですが、フランス語のツイートは関連する可能性は
|
100
|
+
低いでしょう。
|
101
|
+
|
102
|
+
スライドには多くのコメントを表示したくなるかもしれませんが、発表してい
|
103
|
+
る間は観客にはできるだけ発表に集中できるように、表示するコメントはでき
|
104
|
+
るだけ発表に関連するものだけにした方にしましょう。ツイートが関連するか
|
105
|
+
どうかをツイートしたユーザーの言語で絞り込むことができます。
|
106
|
+
|
107
|
+
例えば、自分の言語を日本語に設定しているユーザーのツイートだけにする場
|
108
|
+
合は以下のように((%--user-language "ja"%))を指定します。
|
109
|
+
|
110
|
+
% rabbiter --filter "#rubykaigi" --user-language "ja"
|
111
|
+
|
112
|
+
((%--filter%))と同じように((%--user-language%))も複数回指定することがで
|
113
|
+
きます。複数回指定すると指定したどれかの言語のユーザーのツイートのみが
|
114
|
+
収集されます。以下は日本語またはフランス語に設定したユーザーのツイート
|
115
|
+
のみを収集する例です。
|
116
|
+
|
117
|
+
% rabbiter --filter "#rubykaigi" --user-language "ja" --user-language "fr"
|
118
|
+
|
119
|
+
=== 違うホストで起動しているRabbitにコメントを送る
|
120
|
+
|
121
|
+
TODO
|
122
|
+
|
123
|
+
=== もっと知りたい
|
124
|
+
|
125
|
+
((%--help%))オプションを指定すると使えるオプションがすべて表示されます。
|
126
|
+
自分が使いたい機能がないか調べてみてください。
|
127
|
+
|
128
|
+
% rabbiter --help
|
129
|
+
|
130
|
+
== 作者
|
131
|
+
|
132
|
+
* Kouhei Sutou <kou@cozmixng.org>
|
133
|
+
* OBATA Akio <obata@lins.jp>
|
134
|
+
|
135
|
+
== 著作権
|
136
|
+
|
137
|
+
著作権はそれぞれのコードを書いた人が持っています。つまり、コミットされ
|
138
|
+
たコードの著作権はそのコミッタが持っていて、パッチのコードの著作権はそ
|
139
|
+
のパッチ作者が持っています。
|
140
|
+
|
141
|
+
== ライセンス
|
142
|
+
|
143
|
+
GPLv2 or laterです。詳しくはGPLファイルを見てください。取り込まれたパッ
|
144
|
+
チやコードなどを提供してもらった場合、それらのライセンスがGPLv2 or
|
145
|
+
laterとすることに同意してもらったこととします。また、それらも含めて須藤
|
146
|
+
がライセンスを変更できる権利を持つことに同意してもらったこととします。
|
147
|
+
|
148
|
+
== メーリングリスト
|
149
|
+
|
150
|
+
((<Rabbitのユーザーページ
|
151
|
+
|URL:http://rabbit-shocker.org/ja/users.html>))を参照してください。
|
152
|
+
|
153
|
+
== 開発への参加方法
|
154
|
+
|
155
|
+
=== リポジトリ
|
156
|
+
|
157
|
+
Rabbiterのリポジトリは((<GitHub|URL:https://github.com/rabbit-shocker/rabbiter/>))にあります。
|
158
|
+
|
159
|
+
=== コミットメール
|
160
|
+
|
161
|
+
以下のメーリングリストにコミットメール毎に変更点が流れます。メーリング
|
162
|
+
リストに参加することで開発状況を確認できます。メーリングリストに参加す
|
163
|
+
るには以下のようなメールを送信してください。
|
164
|
+
|
165
|
+
To: commit@ml.rabbit-shocker.org
|
166
|
+
Cc: null@rabbit-shocker.org
|
167
|
+
Subject: 登録
|
168
|
+
|
169
|
+
登録
|
170
|
+
|
171
|
+
=== バグの報告方法
|
172
|
+
|
173
|
+
ご意見ご要望不具合報告等は作者へのメール、メーリングリスト、((<GitHubの
|
174
|
+
Issues|URL:https://github.com/rabbit-shocker/rabbiter/issues>))をご利用くださ
|
175
|
+
い。
|
176
|
+
|
177
|
+
== 感謝
|
178
|
+
|
179
|
+
以下の方々はRabbiterを助けてくれたみなさんです。ありがとうございま
|
180
|
+
す!!!
|
181
|
+
|
182
|
+
* おばたさん: 最初のバージョンを書いてくれました。
|
183
|
+
|
data/doc/ja/news.rd
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
layout: ja
|
3
|
+
title: お知らせ
|
4
|
+
apply_data: false
|
5
|
+
---
|
6
|
+
== 2.0.3: 2016-08-21
|
7
|
+
|
8
|
+
脱twitter-streamリリース!
|
9
|
+
|
10
|
+
=== 改良
|
11
|
+
|
12
|
+
* doc: ドキュメントをgem内に入れるようにした。
|
13
|
+
[shocker-ja:1225] [Youhei SASAKIさんが報告]
|
14
|
+
* (({t.co}))の短縮URLを展開するようにした。
|
15
|
+
[shocker-ja:1228] [OBATA Akioさんが提案]
|
16
|
+
[GitHub#5] [OBATA Akioさんがパッチ提供]
|
17
|
+
* twitter-stream gemをやめてtwitter gemを使うようにした。
|
18
|
+
|
19
|
+
=== 感謝
|
20
|
+
|
21
|
+
* Youhei SASAKIさん
|
22
|
+
* OBATA Akioさん
|
23
|
+
|
24
|
+
== 2.0.2: 2014-06-05
|
25
|
+
|
26
|
+
Ruby/GIO2 2.2.0対応リリース!
|
27
|
+
|
28
|
+
=== 改良
|
29
|
+
|
30
|
+
* doc: OS Xのインストールドキュメントに((%glib-networking%))の説明を追加。
|
31
|
+
[GitHub#4] [Colin Deanさんがパッチ提供]
|
32
|
+
[shocker-ja:1190] [znzさんが報告]
|
33
|
+
* Ruby/GIO2 2.2.0に対応。
|
34
|
+
|
35
|
+
=== 感謝
|
36
|
+
|
37
|
+
* Colin Deanさん
|
38
|
+
* znzさん
|
39
|
+
|
40
|
+
== 2.0.1: 2013-08-29
|
41
|
+
|
42
|
+
1年ぶりのバグフィックスリリース!
|
43
|
+
|
44
|
+
=== 改良
|
45
|
+
|
46
|
+
* OS XなどGTK+からURLを開けない環境でも初期設定できるようにした。
|
47
|
+
|
48
|
+
== 2.0.0: 2012-08-29
|
49
|
+
|
50
|
+
初めてのリリース!
|
51
|
+
|
52
|
+
Rabbitパッケージから分離しました。
|
data/lib/rabbiter.rb
CHANGED
@@ -18,8 +18,7 @@ require "shellwords"
|
|
18
18
|
require "pathname"
|
19
19
|
require "yaml"
|
20
20
|
|
21
|
-
require "
|
22
|
-
require "twitter/json_stream"
|
21
|
+
require "twitter"
|
23
22
|
require "twitter_oauth"
|
24
23
|
|
25
24
|
require "rabbit/utils"
|
@@ -52,8 +51,6 @@ module Rabbiter
|
|
52
51
|
setup_access_token unless @config_file_path.exist?
|
53
52
|
oauth_access_parameters = YAML.load(@config_file_path.read)
|
54
53
|
@oauth_parameters = {
|
55
|
-
:consumer_key => CONSUMER_KEY,
|
56
|
-
:consumer_secret => CONSUMER_SECRET,
|
57
54
|
:access_key => oauth_access_parameters[:access_token],
|
58
55
|
:access_secret => oauth_access_parameters[:access_secret],
|
59
56
|
}
|
@@ -71,40 +68,18 @@ module Rabbiter
|
|
71
68
|
return if @oauth_parameters.nil?
|
72
69
|
|
73
70
|
stream_options = {
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
71
|
+
:access_token => @oauth_parameters[:access_key],
|
72
|
+
:access_token_secret => @oauth_parameters[:access_secret],
|
73
|
+
:consumer_key => CONSUMER_KEY,
|
74
|
+
:consumer_secret => CONSUMER_SECRET,
|
75
|
+
:user_agent => "Rabbiter #{Rabbiter::VERSION}",
|
78
76
|
}
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@stream.send(:reset_state)
|
82
|
-
@connection = GLibConnection.new(@logger, @stream)
|
83
|
-
|
84
|
-
@stream.each_item do |item|
|
85
|
-
status = JSON.parse(item)
|
77
|
+
@client = ::Twitter::Streaming::Client.new(stream_options)
|
78
|
+
@client.filter(:track => filters.join(",")) do |status|
|
86
79
|
@listeners.each do |listener|
|
87
80
|
listener.call(status)
|
88
81
|
end
|
89
82
|
end
|
90
|
-
|
91
|
-
@stream.on_error do |message|
|
92
|
-
@logger.error("[twitter] #{message}")
|
93
|
-
end
|
94
|
-
|
95
|
-
@stream.on_reconnect do |timeout, n_retries|
|
96
|
-
format = _("%{timeout} seconds (%{n_retries})")
|
97
|
-
message = format % {:timeout => timeout, :n_retries => retries}
|
98
|
-
@logger.info("[twitter][reconnect] #{message}")
|
99
|
-
end
|
100
|
-
|
101
|
-
@stream.on_max_reconnects do |timeout, n_retries|
|
102
|
-
format = _("Failed after %{n_retries} failed reconnects")
|
103
|
-
message = format % {:n_retries => retries}
|
104
|
-
@logger.info("[twitter][max-reconnects] #{message}")
|
105
|
-
end
|
106
|
-
|
107
|
-
@connection.connect
|
108
83
|
end
|
109
84
|
|
110
85
|
private
|
@@ -141,125 +116,5 @@ module Rabbiter
|
|
141
116
|
@logger.warning("[twitter][show-uri] #{$!}")
|
142
117
|
end
|
143
118
|
end
|
144
|
-
|
145
|
-
class GLibConnection
|
146
|
-
def initialize(logger, handler)
|
147
|
-
@logger = logger
|
148
|
-
@handler = handler
|
149
|
-
@options = @handler.instance_variable_get("@options")
|
150
|
-
@client = nil
|
151
|
-
@connection = nil
|
152
|
-
@socket = nil
|
153
|
-
@source_ids = []
|
154
|
-
end
|
155
|
-
|
156
|
-
def connect
|
157
|
-
close
|
158
|
-
@client = Gio::SocketClient.new
|
159
|
-
@client.tls = @options[:ssl]
|
160
|
-
@client.tls_validation_flags = :validate_all
|
161
|
-
if Rabbit::Utils.windows?
|
162
|
-
@client.tls_validation_flags -= :unknown_ca
|
163
|
-
end
|
164
|
-
@connection = @client.connect_to_host(@options[:host], @options[:port])
|
165
|
-
@input = @connection.input_stream
|
166
|
-
@output = @connection.output_stream
|
167
|
-
|
168
|
-
reader_source = @input.create_source do |stream|
|
169
|
-
@logger.debug("[twitter][read][start]")
|
170
|
-
begin
|
171
|
-
data = @input.read_nonblocking(8192)
|
172
|
-
rescue Gio::IOError::WouldBlock
|
173
|
-
data = ""
|
174
|
-
rescue => error
|
175
|
-
@logger.debug("[twitter][read][error] #{error}")
|
176
|
-
@handler.send(:receive_error, "#{error.class}: #{error}")
|
177
|
-
data = nil
|
178
|
-
end
|
179
|
-
if data
|
180
|
-
@logger.debug("[twitter][read][done] #{data.bytesize}")
|
181
|
-
@handler.receive_data(data) unless data.empty?
|
182
|
-
true
|
183
|
-
else
|
184
|
-
false
|
185
|
-
end
|
186
|
-
end
|
187
|
-
@source_ids << reader_source.attach
|
188
|
-
|
189
|
-
@handler.extend(GLibAdapter)
|
190
|
-
@handler.connection = self
|
191
|
-
@handler.connection_completed
|
192
|
-
end
|
193
|
-
|
194
|
-
def send_data(data)
|
195
|
-
rest = data.bytesize
|
196
|
-
writer_source = @output.create_source do |stream|
|
197
|
-
if rest.zero?
|
198
|
-
@logger.debug("[twitter][flush][start]")
|
199
|
-
@output.flush
|
200
|
-
@logger.debug("[twitter][flush][done]")
|
201
|
-
@source_ids.reject! {|id| id == writer_source.id}
|
202
|
-
false
|
203
|
-
else
|
204
|
-
@logger.debug("[twitter][write][start]")
|
205
|
-
written_size = @output.write_nonblocking(data)
|
206
|
-
@logger.debug("[twitter][write][done] #{written_size}")
|
207
|
-
rest -= written_size
|
208
|
-
data[0, written_size] = ""
|
209
|
-
true
|
210
|
-
end
|
211
|
-
end
|
212
|
-
@source_ids << writer_source.attach
|
213
|
-
end
|
214
|
-
|
215
|
-
def close
|
216
|
-
return if @client.nil?
|
217
|
-
@source_ids.reject! do |id|
|
218
|
-
GLib::Source.remove(id)
|
219
|
-
true
|
220
|
-
end
|
221
|
-
@input = nil
|
222
|
-
@output = nil
|
223
|
-
@connection = nil
|
224
|
-
@client = nil
|
225
|
-
end
|
226
|
-
|
227
|
-
def reconnect(options={})
|
228
|
-
close
|
229
|
-
after = options[:after] || 0
|
230
|
-
if after.zero?
|
231
|
-
connect
|
232
|
-
else
|
233
|
-
id = GLib::Timeout.add(after) do
|
234
|
-
connect
|
235
|
-
false
|
236
|
-
end
|
237
|
-
@source_ids << id
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
module GLibAdapter
|
243
|
-
attr_accessor :connection
|
244
|
-
def start_tls
|
245
|
-
end
|
246
|
-
|
247
|
-
def send_data(data)
|
248
|
-
@connection.send_data(data)
|
249
|
-
end
|
250
|
-
|
251
|
-
def reconnect_after(timeout)
|
252
|
-
@reconnect_callback.call(timeout, @reconnect_retries) if @reconnect_callback
|
253
|
-
@connection.reconnect(:after => timeout)
|
254
|
-
end
|
255
|
-
|
256
|
-
def reconnect(server, port)
|
257
|
-
@connection.reconnect
|
258
|
-
end
|
259
|
-
|
260
|
-
def close_connection
|
261
|
-
@connection.close
|
262
|
-
end
|
263
|
-
end
|
264
119
|
end
|
265
120
|
end
|
data/lib/rabbiter/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2014 Kouhei Sutou <kou@cozmixng.org>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -15,5 +15,5 @@
|
|
15
15
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
16
|
|
17
17
|
module Rabbiter
|
18
|
-
VERSION = "2.0.
|
18
|
+
VERSION = "2.0.3"
|
19
19
|
end
|
Binary file
|
data/po/ja/rabbiter.po
CHANGED
@@ -7,8 +7,7 @@ msgid ""
|
|
7
7
|
msgstr ""
|
8
8
|
"Project-Id-Version: rabbiter 2.0.0\n"
|
9
9
|
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"
|
11
|
-
"PO-Revision-Date: 2012-08-23 17:25+0900\n"
|
10
|
+
"PO-Revision-Date: 2016-08-21 16:42+0900\n"
|
12
11
|
"Last-Translator: Kouhei Sutou <kou@cozmixng.org>\n"
|
13
12
|
"Language-Team: Japanese\n"
|
14
13
|
"Language: ja\n"
|
@@ -17,54 +16,38 @@ msgstr ""
|
|
17
16
|
"Content-Transfer-Encoding: 8bit\n"
|
18
17
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
19
18
|
|
20
|
-
#: ../bin/rabbiter:39
|
21
19
|
msgid "Rabbit's dRuby URI"
|
22
20
|
msgstr "RabbitのdRuby URI"
|
23
21
|
|
24
|
-
#: ../bin/rabbiter:45
|
25
22
|
msgid "Filter by word."
|
26
23
|
msgstr "単語でフィルターします。"
|
27
24
|
|
28
|
-
#: ../bin/rabbiter:46
|
29
25
|
msgid "To use multiple filters, use this option multiple."
|
30
26
|
msgstr "複数のフィルターを使うときはこのオプションを複数回使ってください。"
|
31
27
|
|
32
|
-
#: ../bin/rabbiter:51
|
33
28
|
msgid "Filter by user language."
|
34
29
|
msgstr "ユーザーの言語でフィルターします。"
|
35
30
|
|
36
|
-
#: ../bin/rabbiter:52
|
37
31
|
msgid "(e.g.: ja, en)"
|
38
32
|
msgstr "(例: ja, en)"
|
39
33
|
|
40
|
-
#: ../bin/rabbiter:53
|
41
34
|
msgid "To use multiple language, use this option multiple."
|
42
35
|
msgstr "複数の言語を指定するときはこのオプションを複数回使ってください。"
|
43
36
|
|
44
|
-
|
37
|
+
msgid "Resolve shorten URL such as https://t.co/XXX."
|
38
|
+
msgstr "https://t.co/XXX のような短縮URLを展開します。"
|
39
|
+
|
45
40
|
msgid "Debug"
|
46
41
|
msgstr "デバッグ"
|
47
42
|
|
48
|
-
#: ../bin/rabbiter:60
|
49
43
|
msgid "Log target statuses."
|
50
44
|
msgstr "対象となるステータスをログに出力します。"
|
51
45
|
|
52
|
-
#: ../bin/rabbiter:97
|
53
46
|
msgid "must specify one or more filters by --filter"
|
54
47
|
msgstr "--filterで1つ以上のフィルターを指定してください。"
|
55
48
|
|
56
|
-
#: ../lib/rabbiter.rb:96
|
57
|
-
msgid "%{timeout} seconds (%{n_retries})"
|
58
|
-
msgstr "%{timeout}秒 (%{n_retries})"
|
59
|
-
|
60
|
-
#: ../lib/rabbiter.rb:102
|
61
|
-
msgid "Failed after %{n_retries} failed reconnects"
|
62
|
-
msgstr "%{n_retries}回再接続が失敗したので中断しました。"
|
63
|
-
|
64
|
-
#: ../lib/rabbiter.rb:121
|
65
49
|
msgid "1) Access this URL: %{url}"
|
66
50
|
msgstr "1) このURLにアクセスしてください: %{url}"
|
67
51
|
|
68
|
-
#: ../lib/rabbiter.rb:123
|
69
52
|
msgid "2) Enter the PIN: "
|
70
53
|
msgstr "2) PINを入力してください: "
|
data/rabbiter.gemspec
CHANGED
@@ -38,7 +38,8 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.files = ["Rakefile", "COPYING", "GPL", "README"]
|
39
39
|
spec.files += ["Gemfile", "#{spec.name}.gemspec"]
|
40
40
|
spec.files += Dir.glob("lib/**/*.rb")
|
41
|
-
spec.files += Dir.glob("
|
41
|
+
spec.files += Dir.glob("doc/**/*.*")
|
42
|
+
spec.files += Dir.glob("po/*/#{spec.name}.po")
|
42
43
|
spec.files += Dir.glob("locale/**/*.mo")
|
43
44
|
Dir.chdir("bin") do
|
44
45
|
spec.executables = Dir.glob("*")
|
@@ -47,7 +48,7 @@ Gem::Specification.new do |spec|
|
|
47
48
|
spec.add_runtime_dependency("rabbit", ">= 2.0.0")
|
48
49
|
spec.add_runtime_dependency("gio2", ">= 2.1.1")
|
49
50
|
spec.add_runtime_dependency("twitter_oauth")
|
50
|
-
spec.add_runtime_dependency("twitter
|
51
|
+
spec.add_runtime_dependency("twitter")
|
51
52
|
|
52
53
|
spec.add_development_dependency("rake")
|
53
54
|
spec.add_development_dependency("bundler")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbiter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rabbit
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: twitter
|
56
|
+
name: twitter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,10 @@ files:
|
|
123
123
|
- README
|
124
124
|
- Rakefile
|
125
125
|
- bin/rabbiter
|
126
|
+
- doc/en/index.rd
|
127
|
+
- doc/en/news.rd
|
128
|
+
- doc/ja/index.rd
|
129
|
+
- doc/ja/news.rd
|
126
130
|
- lib/rabbiter.rb
|
127
131
|
- lib/rabbiter/gettext.rb
|
128
132
|
- lib/rabbiter/version.rb
|
@@ -149,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
153
|
version: '0'
|
150
154
|
requirements: []
|
151
155
|
rubyforge_project: rabbit
|
152
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.5.1
|
153
157
|
signing_key:
|
154
158
|
specification_version: 4
|
155
159
|
summary: Rabbiter is a twitter client for Rabbit
|