tweetwine 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/{MIT-LICENSE.txt → LICENSE.txt} +1 -1
- data/README.md +122 -0
- data/Rakefile +59 -78
- data/bin/tweetwine +1 -0
- data/example/example_helper.rb +3 -1
- data/example/search_statuses_example.rb +2 -0
- data/example/show_followers_example.rb +2 -0
- data/example/show_friends_example.rb +2 -0
- data/example/show_home_example.rb +2 -0
- data/example/show_mentions_example.rb +2 -0
- data/example/show_metadata_example.rb +2 -0
- data/example/show_user_example.rb +2 -0
- data/example/update_status_example.rb +2 -0
- data/example/use_http_proxy_example.rb +2 -0
- data/lib/tweetwine/cli.rb +2 -0
- data/lib/tweetwine/client.rb +2 -0
- data/lib/tweetwine/io.rb +16 -11
- data/lib/tweetwine/meta.rb +3 -1
- data/lib/tweetwine/options.rb +2 -0
- data/lib/tweetwine/retrying_http.rb +2 -0
- data/lib/tweetwine/startup_config.rb +2 -0
- data/lib/tweetwine/url_shortener.rb +2 -0
- data/lib/tweetwine/util.rb +9 -6
- data/lib/tweetwine.rb +2 -0
- data/man/tweetwine.1 +109 -0
- data/man/tweetwine.1.ronn +69 -0
- data/man/tweetwine.7 +216 -0
- data/man/tweetwine.7.ronn +122 -0
- data/test/cli_test.rb +3 -1
- data/test/client_test.rb +3 -1
- data/test/io_test.rb +38 -31
- data/test/options_test.rb +3 -1
- data/test/retrying_http_test.rb +11 -11
- data/test/startup_config_test.rb +4 -2
- data/test/test_helper.rb +57 -47
- data/test/url_shortener_test.rb +3 -1
- data/test/util_test.rb +10 -3
- metadata +145 -20
- data/README.rdoc +0 -117
- /data/example/{fixtures → fixture}/home.json +0 -0
- /data/example/{fixtures → fixture}/mentions.json +0 -0
- /data/example/{fixtures → fixture}/search.json +0 -0
- /data/example/{fixtures → fixture}/update.json +0 -0
- /data/example/{fixtures → fixture}/user.json +0 -0
- /data/example/{fixtures → fixture}/users.json +0 -0
- /data/test/{fixtures → fixture}/test_config.yaml +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
tweetwine(1) -- a simple Twitter command line agent
|
2
|
+
===================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
tweetwine [ <GLOBAL_OPTIONS> ]
|
7
|
+
tweetwine [ <GLOBAL_OPTIONS> ] <COMMAND> [ <COMMAND_OPTIONS> ]
|
8
|
+
|
9
|
+
## DESCRIPTION
|
10
|
+
|
11
|
+
Tweetwine supports showing the home timeline of the authenticated user, the
|
12
|
+
latest statuses of friends and followers, and the latest statuses that mention
|
13
|
+
the user. If that's not enough, statuses can be searched with arbitrary terms.
|
14
|
+
In addition, new statuses can be sent.
|
15
|
+
|
16
|
+
<COMMAND> is one of
|
17
|
+
|
18
|
+
* `followers`,
|
19
|
+
* `friends`,
|
20
|
+
* `home`,
|
21
|
+
* `mentions`,
|
22
|
+
* `search`,
|
23
|
+
* `update`, or
|
24
|
+
* `user`.
|
25
|
+
|
26
|
+
The default is `home`.
|
27
|
+
|
28
|
+
## OPTIONS
|
29
|
+
|
30
|
+
Options given from command line override corresponding settings from
|
31
|
+
configuration (`~/.tweetwine`).
|
32
|
+
|
33
|
+
<GLOBAL_OPTIONS> are:
|
34
|
+
|
35
|
+
* `-a`, `--auth USERNAME:PASSWORD`:
|
36
|
+
Authentication.
|
37
|
+
|
38
|
+
* `-c`, `--[no-]colors`:
|
39
|
+
Colorize output with ANSI escape codes.
|
40
|
+
|
41
|
+
* `-n`, `--num N`:
|
42
|
+
The number of statuses in page, default 20.
|
43
|
+
|
44
|
+
* `--[no-]http-proxy URL`:
|
45
|
+
Use proxy for HTTP and HTTPS.
|
46
|
+
|
47
|
+
* `--no-url-shorten`:
|
48
|
+
Do not shorten URLs for status update.
|
49
|
+
|
50
|
+
* `-p`, `--page N`:
|
51
|
+
The page number for statuses, default 1.
|
52
|
+
|
53
|
+
* `-v`, `--version`:
|
54
|
+
Show version information and exit.
|
55
|
+
|
56
|
+
* `-h`, `--help`:
|
57
|
+
Show help message and exit.
|
58
|
+
|
59
|
+
In order to see <COMMAND_OPTIONS>, enter:
|
60
|
+
|
61
|
+
$ tweetwine help <COMMAND>
|
62
|
+
|
63
|
+
## COPYRIGHT
|
64
|
+
|
65
|
+
Tweetwine is Copyright (c) 2009-2010 Tuomas Kareinen
|
66
|
+
|
67
|
+
## SEE ALSO
|
68
|
+
|
69
|
+
tweetwine(7), <http://github.com/tuomas/tweetwine>
|
data/man/tweetwine.7
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
.\" generated with Ronn/v0.5
|
2
|
+
.\" http://github.com/rtomayko/ronn/
|
3
|
+
.
|
4
|
+
.TH "TWEETWINE" "7" "April 2010" "Tuomas Kareinen" "Tweetwine Manual"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBtweetwine\fR \-\- a simple Twitter command line agent
|
8
|
+
.
|
9
|
+
.SH "DESCRIPTION"
|
10
|
+
Tweetwine supports showing the home timeline of the authenticated user, the
|
11
|
+
latest statuses of friends and followers, and the latest statuses that mention
|
12
|
+
the user. If that's not enough, statuses can be searched with arbitrary terms.
|
13
|
+
In addition, new statuses can be sent.
|
14
|
+
.
|
15
|
+
.P
|
16
|
+
Features:
|
17
|
+
.
|
18
|
+
.IP "\(bu" 4
|
19
|
+
Simple to use command line interface, with Bash completion support
|
20
|
+
.
|
21
|
+
.IP "\(bu" 4
|
22
|
+
ANSI coloring of statuses, but in discreet manner
|
23
|
+
.
|
24
|
+
.IP "\(bu" 4
|
25
|
+
Supports shortening URLs in a status update with a configurable shortening
|
26
|
+
service
|
27
|
+
.
|
28
|
+
.IP "\(bu" 4
|
29
|
+
Configuration file for preferred settings
|
30
|
+
.
|
31
|
+
.IP "" 0
|
32
|
+
.
|
33
|
+
.SH "INSTALL"
|
34
|
+
Install Tweetwine with RubyGems:
|
35
|
+
.
|
36
|
+
.IP "" 4
|
37
|
+
.
|
38
|
+
.nf
|
39
|
+
|
40
|
+
$ gem install tweetwine
|
41
|
+
.
|
42
|
+
.fi
|
43
|
+
.
|
44
|
+
.IP "" 0
|
45
|
+
.
|
46
|
+
.P
|
47
|
+
The program is compatible with both Ruby 1.8 and 1.9.
|
48
|
+
.
|
49
|
+
.P
|
50
|
+
The program requires \fIrest\-client\fR
|
51
|
+
gem to be installed. In addition, the program needs \fIjson\fR gem on Ruby 1.8.
|
52
|
+
.
|
53
|
+
.P
|
54
|
+
Documentation is provided as gem man pages. Use \fIgem\-man\fR to see them:
|
55
|
+
.
|
56
|
+
.IP "" 4
|
57
|
+
.
|
58
|
+
.nf
|
59
|
+
|
60
|
+
$ gem man tweetwine
|
61
|
+
.
|
62
|
+
.fi
|
63
|
+
.
|
64
|
+
.IP "" 0
|
65
|
+
.
|
66
|
+
.SH "BASIC USAGE AND CONFIGURATION"
|
67
|
+
In the command line, run the program by entering
|
68
|
+
.
|
69
|
+
.IP "" 4
|
70
|
+
.
|
71
|
+
.nf
|
72
|
+
|
73
|
+
$ tweetwine [ <GLOBAL_OPTIONS> ] [ <COMMAND> ] [ <COMMAND_OPTIONS> ]
|
74
|
+
.
|
75
|
+
.fi
|
76
|
+
.
|
77
|
+
.IP "" 0
|
78
|
+
.
|
79
|
+
.P
|
80
|
+
The program needs the user's username and password for authentication. This
|
81
|
+
information can be supplied either via a configuration file or as an option
|
82
|
+
(\fB\-a USERNAME:PASSWORD\fR) to the program. It is recommended to use the former
|
83
|
+
method over the latter.
|
84
|
+
.
|
85
|
+
.P
|
86
|
+
The configuration file, in \fB~/.tweetwine\fR, is in YAML syntax. The program
|
87
|
+
recognizes the following basic settings:
|
88
|
+
.
|
89
|
+
.IP "" 4
|
90
|
+
.
|
91
|
+
.nf
|
92
|
+
|
93
|
+
username: <your_username>
|
94
|
+
password: <your_password>
|
95
|
+
colors: true|false
|
96
|
+
.
|
97
|
+
.fi
|
98
|
+
.
|
99
|
+
.IP "" 0
|
100
|
+
.
|
101
|
+
.P
|
102
|
+
For all the global options and commands, see:
|
103
|
+
.
|
104
|
+
.IP "" 4
|
105
|
+
.
|
106
|
+
.nf
|
107
|
+
|
108
|
+
$ tweetwine help
|
109
|
+
.
|
110
|
+
.fi
|
111
|
+
.
|
112
|
+
.IP "" 0
|
113
|
+
.
|
114
|
+
.P
|
115
|
+
For information about a specific command and its options, enter:
|
116
|
+
.
|
117
|
+
.IP "" 4
|
118
|
+
.
|
119
|
+
.nf
|
120
|
+
|
121
|
+
$ tweetwine help <COMMAND>
|
122
|
+
.
|
123
|
+
.fi
|
124
|
+
.
|
125
|
+
.IP "" 0
|
126
|
+
.
|
127
|
+
.SS "URL shortening for status update"
|
128
|
+
Before actually sending a status update, it is possible for the software to
|
129
|
+
shorten the URLs in the update by using an external web service. This can be
|
130
|
+
enabled via the \fBshorten_urls\fR key in configuration file; for example:
|
131
|
+
.
|
132
|
+
.IP "" 4
|
133
|
+
.
|
134
|
+
.nf
|
135
|
+
|
136
|
+
username: spoonman
|
137
|
+
password: withyourhands
|
138
|
+
colors: true
|
139
|
+
shorten_urls:
|
140
|
+
enable: true
|
141
|
+
service_url: http://is.gd/create.php
|
142
|
+
method: post
|
143
|
+
url_param_name: URL
|
144
|
+
xpath_selector: //input[@id='short_url']/@value
|
145
|
+
.
|
146
|
+
.fi
|
147
|
+
.
|
148
|
+
.IP "" 0
|
149
|
+
.
|
150
|
+
.P
|
151
|
+
The supported methods (in \fBmethod\fR) are \fBget\fR and \fBpost\fR. The method chosen
|
152
|
+
affects whether parameters are passed as URL query parameters or as payload
|
153
|
+
in the HTTP request, respectively. Extra parameters can be given via \fBextra_params\fR key, as a hash.
|
154
|
+
.
|
155
|
+
.P
|
156
|
+
The \fBxpath_selector\fR is needed to extract the shortened URL from the result.
|
157
|
+
.
|
158
|
+
.P
|
159
|
+
URL shortening can be disabled by
|
160
|
+
.
|
161
|
+
.IP "\(bu" 4
|
162
|
+
not defining \fBshorten_urls\fR key in the configuration file,
|
163
|
+
.
|
164
|
+
.IP "\(bu" 4
|
165
|
+
setting key \fBenable\fR to \fBfalse\fR, or
|
166
|
+
.
|
167
|
+
.IP "\(bu" 4
|
168
|
+
using the command line option \fB\-\-no\-url\-shorten\fR.
|
169
|
+
.
|
170
|
+
.IP "" 0
|
171
|
+
.
|
172
|
+
.P
|
173
|
+
\fINOTE:\fR The use of the feature requires \fInokogiri\fR gem
|
174
|
+
to be installed.
|
175
|
+
.
|
176
|
+
.SS "HTTP proxy setting"
|
177
|
+
If \fB$http_proxy\fR environment variable is set, Tweetwine attempts to use the
|
178
|
+
URL in the environment variable as HTTP proxy for all its HTTP connections.
|
179
|
+
This setting can be overridden with \fB\-\-http\-proxy\fR and \fB\-\-no\-http\-proxy\fR
|
180
|
+
command line options.
|
181
|
+
.
|
182
|
+
.SS "Bash command line completion support"
|
183
|
+
Bash shell supports command line completion via tab character. If you want to
|
184
|
+
enable Tweetwine specific completion with Bash, source the file \fBtweetwine\-completion.bash\fR, located in \fBcontrib\fR directory:
|
185
|
+
.
|
186
|
+
.IP "" 4
|
187
|
+
.
|
188
|
+
.nf
|
189
|
+
|
190
|
+
. contrib/tweetwine\-completion.bash
|
191
|
+
.
|
192
|
+
.fi
|
193
|
+
.
|
194
|
+
.IP "" 0
|
195
|
+
.
|
196
|
+
.P
|
197
|
+
In order to do this automatically when your shell starts, insert the following
|
198
|
+
snippet to your Bash initialization script (such as \fB~/.bashrc\fR):
|
199
|
+
.
|
200
|
+
.IP "" 4
|
201
|
+
.
|
202
|
+
.nf
|
203
|
+
|
204
|
+
if [ \-f <path_to_tweetwine>/contrib/tweetwine\-completion.bash ]; then
|
205
|
+
. <path_to_tweetwine>/contrib/tweetwine\-completion.bash
|
206
|
+
fi
|
207
|
+
.
|
208
|
+
.fi
|
209
|
+
.
|
210
|
+
.IP "" 0
|
211
|
+
.
|
212
|
+
.SH "COPYRIGHT"
|
213
|
+
Tweetwine is Copyright (c) 2009\-2010 Tuomas Kareinen
|
214
|
+
.
|
215
|
+
.SH "SEE ALSO"
|
216
|
+
tweetwine(1), \fIhttp://github.com/tuomas/tweetwine\fR
|
@@ -0,0 +1,122 @@
|
|
1
|
+
tweetwine -- a simple Twitter command line agent
|
2
|
+
================================================
|
3
|
+
|
4
|
+
## DESCRIPTION
|
5
|
+
|
6
|
+
Tweetwine supports showing the home timeline of the authenticated user, the
|
7
|
+
latest statuses of friends and followers, and the latest statuses that mention
|
8
|
+
the user. If that's not enough, statuses can be searched with arbitrary terms.
|
9
|
+
In addition, new statuses can be sent.
|
10
|
+
|
11
|
+
Features:
|
12
|
+
|
13
|
+
* Simple to use command line interface, with Bash completion support
|
14
|
+
* ANSI coloring of statuses, but in discreet manner
|
15
|
+
* Supports shortening URLs in a status update with a configurable shortening
|
16
|
+
service
|
17
|
+
* Configuration file for preferred settings
|
18
|
+
|
19
|
+
## INSTALL
|
20
|
+
|
21
|
+
Install Tweetwine with RubyGems:
|
22
|
+
|
23
|
+
$ gem install tweetwine
|
24
|
+
|
25
|
+
The program is compatible with both Ruby 1.8 and 1.9.
|
26
|
+
|
27
|
+
The program requires [rest-client](http://github.com/archiloque/rest-client)
|
28
|
+
gem to be installed. In addition, the program needs
|
29
|
+
[json](http://json.rubyforge.org/) gem on Ruby 1.8.
|
30
|
+
|
31
|
+
Documentation is provided as gem man pages. Use
|
32
|
+
[gem-man](http://github.com/defunkt/gem-man) to see them:
|
33
|
+
|
34
|
+
$ gem man tweetwine
|
35
|
+
|
36
|
+
## BASIC USAGE AND CONFIGURATION
|
37
|
+
|
38
|
+
In the command line, run the program by entering
|
39
|
+
|
40
|
+
$ tweetwine [ <GLOBAL_OPTIONS> ] [ <COMMAND> ] [ <COMMAND_OPTIONS> ]
|
41
|
+
|
42
|
+
The program needs the user's username and password for authentication. This
|
43
|
+
information can be supplied either via a configuration file or as an option
|
44
|
+
(`-a USERNAME:PASSWORD`) to the program. It is recommended to use the former
|
45
|
+
method over the latter.
|
46
|
+
|
47
|
+
The configuration file, in `~/.tweetwine`, is in YAML syntax. The program
|
48
|
+
recognizes the following basic settings:
|
49
|
+
|
50
|
+
username: <your_username>
|
51
|
+
password: <your_password>
|
52
|
+
colors: true|false
|
53
|
+
|
54
|
+
For all the global options and commands, see:
|
55
|
+
|
56
|
+
$ tweetwine help
|
57
|
+
|
58
|
+
For information about a specific command and its options, enter:
|
59
|
+
|
60
|
+
$ tweetwine help <COMMAND>
|
61
|
+
|
62
|
+
### URL shortening for status update
|
63
|
+
|
64
|
+
Before actually sending a status update, it is possible for the software to
|
65
|
+
shorten the URLs in the update by using an external web service. This can be
|
66
|
+
enabled via the `shorten_urls` key in configuration file; for example:
|
67
|
+
|
68
|
+
username: spoonman
|
69
|
+
password: withyourhands
|
70
|
+
colors: true
|
71
|
+
shorten_urls:
|
72
|
+
enable: true
|
73
|
+
service_url: http://is.gd/create.php
|
74
|
+
method: post
|
75
|
+
url_param_name: URL
|
76
|
+
xpath_selector: //input[@id='short_url']/@value
|
77
|
+
|
78
|
+
The supported methods (in `method`) are `get` and `post`. The method chosen
|
79
|
+
affects whether parameters are passed as URL query parameters or as payload
|
80
|
+
in the HTTP request, respectively. Extra parameters can be given via
|
81
|
+
`extra_params` key, as a hash.
|
82
|
+
|
83
|
+
The `xpath_selector` is needed to extract the shortened URL from the result.
|
84
|
+
|
85
|
+
URL shortening can be disabled by
|
86
|
+
|
87
|
+
* not defining `shorten_urls` key in the configuration file,
|
88
|
+
* setting key `enable` to `false`, or
|
89
|
+
* using the command line option `--no-url-shorten`.
|
90
|
+
|
91
|
+
*NOTE:* The use of the feature requires [nokogiri](http://nokogiri.org/) gem
|
92
|
+
to be installed.
|
93
|
+
|
94
|
+
### HTTP proxy setting
|
95
|
+
|
96
|
+
If `$http_proxy` environment variable is set, Tweetwine attempts to use the
|
97
|
+
URL in the environment variable as HTTP proxy for all its HTTP connections.
|
98
|
+
This setting can be overridden with `--http-proxy` and `--no-http-proxy`
|
99
|
+
command line options.
|
100
|
+
|
101
|
+
### Bash command line completion support
|
102
|
+
|
103
|
+
Bash shell supports command line completion via tab character. If you want to
|
104
|
+
enable Tweetwine specific completion with Bash, source the file
|
105
|
+
`tweetwine-completion.bash`, located in `contrib` directory:
|
106
|
+
|
107
|
+
. contrib/tweetwine-completion.bash
|
108
|
+
|
109
|
+
In order to do this automatically when your shell starts, insert the following
|
110
|
+
snippet to your Bash initialization script (such as `~/.bashrc`):
|
111
|
+
|
112
|
+
if [ -f <path_to_tweetwine>/contrib/tweetwine-completion.bash ]; then
|
113
|
+
. <path_to_tweetwine>/contrib/tweetwine-completion.bash
|
114
|
+
fi
|
115
|
+
|
116
|
+
## COPYRIGHT
|
117
|
+
|
118
|
+
Tweetwine is Copyright (c) 2009-2010 Tuomas Kareinen
|
119
|
+
|
120
|
+
## SEE ALSO
|
121
|
+
|
122
|
+
tweetwine(1), <http://github.com/tuomas/tweetwine>
|
data/test/cli_test.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
module Tweetwine
|
4
6
|
|
5
|
-
class CLITest <
|
7
|
+
class CLITest < TweetwineTestCase
|
6
8
|
context "A CLI, upon initialization" do
|
7
9
|
should "disallow using #new to create a new instance" do
|
8
10
|
assert_raise(NoMethodError) { CLI.new("-v", "test", "") {} }
|
data/test/client_test.rb
CHANGED
data/test/io_test.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
module Tweetwine
|
4
6
|
|
5
|
-
class IOTest <
|
7
|
+
class IOTest < TweetwineTestCase
|
6
8
|
context "An IO instance" do
|
7
9
|
setup do
|
8
10
|
@input = mock()
|
@@ -216,42 +218,47 @@ Lulz, so happy! \e[35m#{hashtags[0]}\e[0m \e[35m#{hashtags[1]}\e[0m
|
|
216
218
|
@io.show_record(record)
|
217
219
|
end
|
218
220
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
221
|
+
%w{http://is.gd/1qLk3 http://is.gd/1qLk3?id=foo}.each do |url|
|
222
|
+
should "highlight HTTP and HTTPS URLs in a status, given #{url}" do
|
223
|
+
from_user = "barman"
|
224
|
+
record = {
|
225
|
+
:from_user => from_user,
|
226
|
+
:status => "New Rails³ - #{url}",
|
227
|
+
:created_at => Time.at(1),
|
228
|
+
:to_user => nil
|
229
|
+
}
|
230
|
+
Util.expects(:humanize_time_diff).returns([2, "secs"])
|
231
|
+
@output.expects(:puts).with(<<-END
|
230
232
|
\e[32m#{from_user}\e[0m, 2 secs ago:
|
231
|
-
|
233
|
+
New Rails³ - \e[36m#{url}\e[0m
|
232
234
|
|
233
|
-
|
234
|
-
|
235
|
-
|
235
|
+
END
|
236
|
+
)
|
237
|
+
@io.show_record(record)
|
238
|
+
end
|
236
239
|
end
|
237
240
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
241
|
+
[
|
242
|
+
%w{http://is.gd/1qLk3 http://is.gd/1qLk3},
|
243
|
+
%w{http://is.gd/1qLk3 http://is.gd/1q}
|
244
|
+
].each do |(first_url, second_url)|
|
245
|
+
should "highlight HTTP and HTTPS URLs in a status, given #{first_url} and #{second_url}" do
|
246
|
+
from_user = "barman"
|
247
|
+
record = {
|
248
|
+
:from_user => from_user,
|
249
|
+
:status => "Links: #{first_url} and #{second_url} np",
|
250
|
+
:created_at => Time.at(1),
|
251
|
+
:to_user => nil
|
252
|
+
}
|
253
|
+
Util.expects(:humanize_time_diff).returns([2, "secs"])
|
254
|
+
@output.expects(:puts).with(<<-END
|
249
255
|
\e[32m#{from_user}\e[0m, 2 secs ago:
|
250
|
-
|
256
|
+
Links: \e[36m#{first_url}\e[0m and \e[36m#{second_url}\e[0m np
|
251
257
|
|
252
|
-
|
253
|
-
|
254
|
-
|
258
|
+
END
|
259
|
+
)
|
260
|
+
@io.show_record(record)
|
261
|
+
end
|
255
262
|
end
|
256
263
|
|
257
264
|
should "highlight usernames in a status" do
|
data/test/options_test.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
module Tweetwine
|
4
6
|
|
5
|
-
class OptionsTest <
|
7
|
+
class OptionsTest < TweetwineTestCase
|
6
8
|
context "An Options instance" do
|
7
9
|
should "get the value corresponding to a key or nil (the default value)" do
|
8
10
|
assert_equal "alpha", Options.new({:a => "alpha"})[:a]
|
data/test/retrying_http_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
require "rest_client"
|
3
5
|
|
@@ -6,9 +8,8 @@ class Object
|
|
6
8
|
end
|
7
9
|
|
8
10
|
module Tweetwine
|
9
|
-
module RetryingHttp
|
10
11
|
|
11
|
-
class
|
12
|
+
class RetryingHttpModuleTest < TweetwineTestCase
|
12
13
|
context "When using HTTP proxy" do
|
13
14
|
setup do
|
14
15
|
RetryingHttp.proxy = "http://proxy.net:8080"
|
@@ -24,11 +25,11 @@ class ModuleTest < Test::Unit::TestCase
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
class
|
28
|
+
class RetryingHttpClientTest < TweetwineTestCase
|
28
29
|
context "A Client instance" do
|
29
30
|
setup do
|
30
31
|
@io = mock()
|
31
|
-
@client = Client.new(@io)
|
32
|
+
@client = RetryingHttp::Client.new(@io)
|
32
33
|
end
|
33
34
|
|
34
35
|
should "wrap RestClient.get" do
|
@@ -68,10 +69,10 @@ class ClientTest < Test::Unit::TestCase
|
|
68
69
|
should "retry connection a maximum of certain number of times, case #{error_class}" do
|
69
70
|
retrying_calls = sequence("Retrying Client calls")
|
70
71
|
io_calls = sequence("IO")
|
71
|
-
(Client::MAX_RETRIES + 1).times do
|
72
|
+
(RetryingHttp::Client::MAX_RETRIES + 1).times do
|
72
73
|
RestClient.expects(:get).with("https://unresponsive.org").in_sequence(retrying_calls).raises(error_class)
|
73
74
|
end
|
74
|
-
Client::MAX_RETRIES.times do
|
75
|
+
RetryingHttp::Client::MAX_RETRIES.times do
|
75
76
|
@io.expects(:warn).in_sequence(io_calls)
|
76
77
|
end
|
77
78
|
assert_raise(HttpError) { @client.get("https://unresponsive.org") }
|
@@ -85,12 +86,12 @@ class ClientTest < Test::Unit::TestCase
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
|
-
class
|
89
|
+
class RetryingHttpResourceTest < TweetwineTestCase
|
89
90
|
context "A Resource instance" do
|
90
91
|
setup do
|
91
92
|
@io = mock()
|
92
93
|
@wrapped = mock()
|
93
|
-
@resource = Resource.new(@wrapped)
|
94
|
+
@resource = RetryingHttp::Resource.new(@wrapped)
|
94
95
|
@resource.io = @io
|
95
96
|
end
|
96
97
|
|
@@ -131,10 +132,10 @@ class ResourceTest < Test::Unit::TestCase
|
|
131
132
|
should "retry connection a maximum of certain number of times, case #{error_class}" do
|
132
133
|
retrying_calls = sequence("Retrying Resource calls")
|
133
134
|
io_calls = sequence("IO")
|
134
|
-
(Resource::MAX_RETRIES + 1).times do
|
135
|
+
(RetryingHttp::Resource::MAX_RETRIES + 1).times do
|
135
136
|
@wrapped.expects(:get).in_sequence(retrying_calls).raises(error_class)
|
136
137
|
end
|
137
|
-
Resource::MAX_RETRIES.times do
|
138
|
+
RetryingHttp::Resource::MAX_RETRIES.times do
|
138
139
|
@io.expects(:warn).in_sequence(io_calls)
|
139
140
|
end
|
140
141
|
assert_raise(HttpError) { @resource.get }
|
@@ -144,4 +145,3 @@ class ResourceTest < Test::Unit::TestCase
|
|
144
145
|
end
|
145
146
|
|
146
147
|
end
|
147
|
-
end
|
data/test/startup_config_test.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
module Tweetwine
|
4
6
|
|
5
|
-
class StartupConfigTest <
|
6
|
-
TEST_CONFIG_FILE =
|
7
|
+
class StartupConfigTest < TweetwineTestCase
|
8
|
+
TEST_CONFIG_FILE = Helper.fixture_file("test_config.yaml")
|
7
9
|
|
8
10
|
context "A StartupConfig instance" do
|
9
11
|
context "upon initialization" do
|