t 2.3.0 → 2.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.tar.gz.sig +0 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/t/cli.rb +16 -6
- data/lib/t/delete.rb +5 -5
- data/lib/t/list.rb +22 -22
- data/lib/t/printable.rb +1 -1
- data/lib/t/search.rb +3 -3
- data/lib/t/stream.rb +52 -12
- data/lib/t/utils.rb +5 -5
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +59 -7
- data/spec/delete_spec.rb +2 -2
- data/spec/helper.rb +1 -1
- data/spec/list_spec.rb +7 -7
- data/spec/rcfile_spec.rb +1 -1
- data/spec/search_spec.rb +7 -7
- data/spec/set_spec.rb +2 -2
- data/spec/stream_spec.rb +127 -132
- data/spec/utils_spec.rb +1 -1
- data/t.gemspec +1 -1
- metadata +27 -9
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
data/spec/delete_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe T::Delete do
|
5
5
|
|
6
|
-
before
|
6
|
+
before do
|
7
7
|
T::RCFile.instance.path = fixture_path + '/.trc'
|
8
8
|
@delete = T::Delete.new
|
9
9
|
@old_stderr = $stderr
|
@@ -12,7 +12,7 @@ describe T::Delete do
|
|
12
12
|
$stdout = StringIO.new
|
13
13
|
end
|
14
14
|
|
15
|
-
after
|
15
|
+
after do
|
16
16
|
T::RCFile.instance.reset
|
17
17
|
$stderr = @old_stderr
|
18
18
|
$stdout = @old_stdout
|
data/spec/helper.rb
CHANGED
data/spec/list_spec.rb
CHANGED
@@ -8,12 +8,7 @@ describe T::List do
|
|
8
8
|
T.utc_offset = 'PST'
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
T.utc_offset = nil
|
13
|
-
Timecop.return
|
14
|
-
end
|
15
|
-
|
16
|
-
before :each do
|
11
|
+
before do
|
17
12
|
T::RCFile.instance.path = fixture_path + '/.trc'
|
18
13
|
@list = T::List.new
|
19
14
|
@old_stderr = $stderr
|
@@ -22,12 +17,17 @@ describe T::List do
|
|
22
17
|
$stdout = StringIO.new
|
23
18
|
end
|
24
19
|
|
25
|
-
after
|
20
|
+
after do
|
26
21
|
T::RCFile.instance.reset
|
27
22
|
$stderr = @old_stderr
|
28
23
|
$stdout = @old_stdout
|
29
24
|
end
|
30
25
|
|
26
|
+
after :all do
|
27
|
+
T.utc_offset = nil
|
28
|
+
Timecop.return
|
29
|
+
end
|
30
|
+
|
31
31
|
describe '#add' do
|
32
32
|
before do
|
33
33
|
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
data/spec/rcfile_spec.rb
CHANGED
data/spec/search_spec.rb
CHANGED
@@ -8,12 +8,7 @@ describe T::Search do
|
|
8
8
|
T.utc_offset = 'PST'
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
T.utc_offset = nil
|
13
|
-
Timecop.return
|
14
|
-
end
|
15
|
-
|
16
|
-
before :each do
|
11
|
+
before do
|
17
12
|
T::RCFile.instance.path = fixture_path + '/.trc'
|
18
13
|
@search = T::Search.new
|
19
14
|
@search.options = @search.options.merge('color' => 'always')
|
@@ -23,12 +18,17 @@ describe T::Search do
|
|
23
18
|
$stdout = StringIO.new
|
24
19
|
end
|
25
20
|
|
26
|
-
after
|
21
|
+
after do
|
27
22
|
T::RCFile.instance.reset
|
28
23
|
$stderr = @old_stderr
|
29
24
|
$stdout = @old_stdout
|
30
25
|
end
|
31
26
|
|
27
|
+
after :all do
|
28
|
+
T.utc_offset = nil
|
29
|
+
Timecop.return
|
30
|
+
end
|
31
|
+
|
32
32
|
describe '#all' do
|
33
33
|
before do
|
34
34
|
stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter', :count => '100', :include_entities => 'false'}).to_return(:body => fixture('search.json'))
|
data/spec/set_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe T::Set do
|
5
5
|
|
6
|
-
before
|
6
|
+
before do
|
7
7
|
T::RCFile.instance.path = fixture_path + '/.trc'
|
8
8
|
@set = T::Set.new
|
9
9
|
@old_stderr = $stderr
|
@@ -12,7 +12,7 @@ describe T::Set do
|
|
12
12
|
$stdout = StringIO.new
|
13
13
|
end
|
14
14
|
|
15
|
-
after
|
15
|
+
after do
|
16
16
|
T::RCFile.instance.reset
|
17
17
|
$stderr = @old_stderr
|
18
18
|
$stdout = @old_stdout
|
data/spec/stream_spec.rb
CHANGED
@@ -12,270 +12,265 @@ describe T::Stream do
|
|
12
12
|
@status = status_from_fixture('status.json')
|
13
13
|
end
|
14
14
|
|
15
|
-
before
|
15
|
+
before do
|
16
16
|
T::RCFile.instance.path = fixture_path + '/.trc'
|
17
|
-
@
|
17
|
+
@streaming_client = double('Twitter::Streaming::Client').as_null_object
|
18
18
|
@stream = T::Stream.new
|
19
|
-
allow(@stream).to receive(:
|
19
|
+
allow(@stream).to receive(:streaming_client) { @streaming_client }
|
20
20
|
allow(@stream).to receive(:say).and_return
|
21
21
|
allow(STDOUT).to receive(:tty?).and_return(true)
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#all' do
|
25
|
+
before do
|
26
|
+
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
27
|
+
end
|
28
|
+
it 'prints the tweet status' do
|
29
|
+
expect(@stream).to receive(:print_message)
|
30
|
+
@stream.all
|
31
|
+
end
|
25
32
|
context '--csv' do
|
26
|
-
before
|
33
|
+
before do
|
27
34
|
@stream.options = @stream.options.merge('csv' => true)
|
28
35
|
end
|
29
36
|
it 'outputs headings when the stream initializes' do
|
30
|
-
allow(@
|
31
|
-
allow(@
|
37
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
38
|
+
allow(@streaming_client).to receive(:sample).and_return
|
32
39
|
expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
|
33
40
|
@stream.all
|
34
41
|
end
|
35
42
|
it 'outputs in CSV format' do
|
36
|
-
allow(@
|
37
|
-
allow(@
|
38
|
-
and_yield(@status)
|
43
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
44
|
+
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
39
45
|
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
40
46
|
@stream.all
|
41
47
|
end
|
42
48
|
end
|
43
|
-
|
44
49
|
context '--long' do
|
45
|
-
before
|
50
|
+
before do
|
46
51
|
@stream.options = @stream.options.merge('long' => true)
|
47
52
|
end
|
48
|
-
|
49
53
|
it 'outputs headings when the stream initializes' do
|
50
|
-
allow(@
|
51
|
-
allow(@
|
54
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
55
|
+
allow(@streaming_client).to receive(:sample).and_return
|
52
56
|
expect(@stream).to receive(:print_table).with(any_args)
|
53
57
|
@stream.all
|
54
58
|
end
|
55
|
-
|
56
59
|
it 'outputs in long text format' do
|
57
|
-
allow(@
|
58
|
-
allow(@
|
59
|
-
and_yield(@status)
|
60
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
61
|
+
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
60
62
|
expect(@stream).to receive(:print_table).with(any_args)
|
61
63
|
@stream.all
|
62
64
|
end
|
63
65
|
end
|
66
|
+
it 'invokes Twitter::Streaming::Client#sample' do
|
67
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
68
|
+
allow(@streaming_client).to receive(:sample).and_return
|
69
|
+
expect(@streaming_client).to receive(:sample)
|
70
|
+
@stream.all
|
71
|
+
end
|
72
|
+
end
|
64
73
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
74
|
+
describe '#list' do
|
75
|
+
before do
|
76
|
+
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
|
77
|
+
end
|
78
|
+
it 'prints the tweet status' do
|
79
|
+
expect(@stream).to receive(:print_message)
|
80
|
+
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
81
|
+
@stream.list('presidents')
|
82
|
+
end
|
83
|
+
it 'requests the correct resource' do
|
84
|
+
@stream.list('presidents')
|
85
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
86
|
+
end
|
87
|
+
context '--csv' do
|
88
|
+
before do
|
89
|
+
@stream.options = @stream.options.merge('csv' => true)
|
69
90
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@stream.
|
91
|
+
it 'outputs in CSV format' do
|
92
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
93
|
+
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
94
|
+
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
95
|
+
@stream.list('presidents')
|
96
|
+
end
|
97
|
+
it 'requests the correct resource' do
|
98
|
+
@stream.list('presidents')
|
99
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
74
100
|
end
|
75
101
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
102
|
+
context '--long' do
|
103
|
+
before do
|
104
|
+
@stream.options = @stream.options.merge('long' => true)
|
105
|
+
end
|
106
|
+
it 'outputs in long text format' do
|
107
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
108
|
+
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
109
|
+
expect(@stream).to receive(:print_table).with(any_args)
|
110
|
+
@stream.list('presidents')
|
111
|
+
end
|
112
|
+
it 'requests the correct resource' do
|
113
|
+
@stream.list('presidents')
|
114
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
115
|
+
end
|
116
|
+
end
|
117
|
+
it 'performs a REST search when the stream initializes' do
|
118
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
119
|
+
allow(@streaming_client).to receive(:filter).and_return
|
120
|
+
allow(T::List).to receive(:new).and_return(t_class)
|
121
|
+
expect(t_class).to receive(:timeline).and_return
|
122
|
+
@stream.list('presidents')
|
123
|
+
end
|
124
|
+
it 'invokes Twitter::Streaming::Client#userstream' do
|
125
|
+
allow(@streaming_client).to receive(:filter).and_return
|
126
|
+
expect(@streaming_client).to receive(:filter)
|
127
|
+
@stream.list('presidents')
|
80
128
|
end
|
81
129
|
end
|
82
130
|
|
83
131
|
describe '#matrix' do
|
84
|
-
before
|
85
|
-
allow(@
|
86
|
-
and_yield(@status)
|
132
|
+
before do
|
133
|
+
allow(@streaming_client).to receive(:sample).and_yield(@status)
|
87
134
|
end
|
88
|
-
|
89
135
|
it 'outputs the tweet status' do
|
90
136
|
expect(@stream).to receive(:say).with(any_args)
|
91
137
|
@stream.matrix
|
92
138
|
end
|
93
|
-
|
94
139
|
it 'invokes Twitter::Streaming::Client.sample' do
|
95
|
-
expect(@
|
140
|
+
expect(@streaming_client).to receive(:sample)
|
96
141
|
@stream.matrix
|
97
142
|
end
|
98
143
|
end
|
99
144
|
|
100
145
|
describe '#search' do
|
101
|
-
before
|
102
|
-
allow(@
|
103
|
-
|
146
|
+
before do
|
147
|
+
allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
|
148
|
+
end
|
149
|
+
it 'prints the tweet status' do
|
150
|
+
expect(@stream).to receive(:print_message)
|
151
|
+
@stream.search(%w[twitter gem])
|
104
152
|
end
|
105
|
-
|
106
153
|
context '--csv' do
|
107
|
-
before
|
154
|
+
before do
|
108
155
|
@stream.options = @stream.options.merge('csv' => true)
|
109
156
|
end
|
110
|
-
|
111
157
|
it 'outputs in CSV format' do
|
112
|
-
allow(@
|
158
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
113
159
|
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
114
160
|
@stream.search(%w[twitter gem])
|
115
161
|
end
|
116
162
|
end
|
117
|
-
|
118
163
|
context '--long' do
|
119
|
-
before
|
164
|
+
before do
|
120
165
|
@stream.options = @stream.options.merge('long' => true)
|
121
166
|
end
|
122
|
-
|
123
167
|
it 'outputs in long text format' do
|
124
|
-
allow(@
|
125
|
-
allow(@
|
126
|
-
and_yield(@status)
|
168
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
169
|
+
allow(@streaming_client).to receive(:filter).with(:track => 'twitter,gem').and_yield(@status)
|
127
170
|
expect(@stream).to receive(:print_table).with(any_args)
|
128
171
|
@stream.search(%w[twitter gem])
|
129
172
|
end
|
130
173
|
end
|
131
|
-
|
132
|
-
context 'normal usage' do
|
133
|
-
before :each do
|
134
|
-
allow(@client).to receive(:filter).with(:track => 'twitter,gem').
|
135
|
-
and_yield(@status)
|
136
|
-
end
|
137
|
-
it 'prints the tweet status' do
|
138
|
-
expect(@stream).to receive(:print_message)
|
139
|
-
@stream.search(%w[twitter gem])
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
174
|
it 'performs a REST search when the stream initializes' do
|
144
|
-
allow(@
|
145
|
-
allow(@
|
175
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
176
|
+
allow(@streaming_client).to receive(:filter).and_return
|
146
177
|
allow(T::Search).to receive(:new).and_return(t_class)
|
147
178
|
expect(t_class).to receive(:all).with('t OR gem').and_return
|
148
179
|
@stream.search('t', 'gem')
|
149
180
|
end
|
150
|
-
|
151
181
|
it 'invokes Twitter::Streaming::Client#filter' do
|
152
|
-
allow(@
|
153
|
-
expect(@
|
182
|
+
allow(@streaming_client).to receive(:filter).and_return
|
183
|
+
expect(@streaming_client).to receive(:filter).with(:track => 'twitter,gem')
|
154
184
|
@stream.search(%w[twitter gem])
|
155
185
|
end
|
156
186
|
end
|
157
187
|
|
158
188
|
describe '#timeline' do
|
159
|
-
before
|
160
|
-
allow(@
|
161
|
-
|
189
|
+
before do
|
190
|
+
allow(@streaming_client).to receive(:user).and_yield(@status)
|
191
|
+
end
|
192
|
+
it 'prints the tweet status' do
|
193
|
+
expect(@stream).to receive(:print_message)
|
194
|
+
@stream.timeline
|
162
195
|
end
|
163
|
-
|
164
196
|
context '--csv' do
|
165
|
-
before
|
197
|
+
before do
|
166
198
|
@stream.options = @stream.options.merge('csv' => true)
|
167
199
|
end
|
168
|
-
|
169
200
|
it 'outputs in CSV format' do
|
170
|
-
allow(@
|
201
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
171
202
|
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
172
203
|
@stream.timeline
|
173
204
|
end
|
174
205
|
end
|
175
|
-
|
176
206
|
context '--long' do
|
177
|
-
before
|
207
|
+
before do
|
178
208
|
@stream.options = @stream.options.merge('long' => true)
|
179
209
|
end
|
180
|
-
|
181
210
|
it 'outputs in long text format' do
|
182
|
-
allow(@
|
183
|
-
allow(@client).to receive(:user).
|
184
|
-
and_yield(@status)
|
211
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
185
212
|
expect(@stream).to receive(:print_table).with(any_args)
|
186
213
|
@stream.timeline
|
187
214
|
end
|
188
215
|
end
|
189
|
-
|
190
|
-
context 'normal usage' do
|
191
|
-
before :each do
|
192
|
-
allow(@client).to receive(:user).
|
193
|
-
and_yield(@status)
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'prints the tweet status' do
|
197
|
-
expect(@stream).to receive(:print_message)
|
198
|
-
@stream.timeline
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
216
|
it 'performs a REST search when the stream initializes' do
|
203
|
-
allow(@
|
204
|
-
allow(@
|
217
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
218
|
+
allow(@streaming_client).to receive(:user).and_return
|
205
219
|
allow(T::CLI).to receive(:new).and_return(t_class)
|
206
220
|
expect(t_class).to receive(:timeline).and_return
|
207
|
-
|
208
221
|
@stream.timeline
|
209
222
|
end
|
210
|
-
|
211
223
|
it 'invokes Twitter::Streaming::Client#userstream' do
|
212
|
-
allow(@
|
213
|
-
expect(@
|
224
|
+
allow(@streaming_client).to receive(:user).and_return
|
225
|
+
expect(@streaming_client).to receive(:user)
|
214
226
|
@stream.timeline
|
215
227
|
end
|
216
228
|
end
|
217
229
|
|
218
230
|
describe '#users' do
|
219
|
-
before
|
220
|
-
allow(@
|
221
|
-
|
231
|
+
before do
|
232
|
+
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
233
|
+
end
|
234
|
+
it 'prints the tweet status' do
|
235
|
+
expect(@stream).to receive(:print_message)
|
236
|
+
@stream.users('123')
|
222
237
|
end
|
223
|
-
|
224
238
|
context '--csv' do
|
225
|
-
before
|
239
|
+
before do
|
226
240
|
@stream.options = @stream.options.merge('csv' => true)
|
227
241
|
end
|
228
|
-
|
229
242
|
it 'outputs headings when the stream initializes' do
|
230
|
-
allow(@
|
231
|
-
allow(@
|
243
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
244
|
+
allow(@streaming_client).to receive(:filter).and_return
|
232
245
|
expect(@stream).to receive(:say).with("ID,Posted at,Screen name,Text\n")
|
233
246
|
@stream.users('123')
|
234
247
|
end
|
235
|
-
|
236
248
|
it 'outputs in CSV format' do
|
237
|
-
allow(@
|
249
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
238
250
|
expect(@stream).to receive(:print_csv_tweet).with(any_args)
|
239
251
|
@stream.users('123')
|
240
252
|
end
|
241
253
|
end
|
242
|
-
|
243
254
|
context '--long' do
|
244
|
-
before
|
255
|
+
before do
|
245
256
|
@stream.options = @stream.options.merge('long' => true)
|
246
257
|
end
|
247
|
-
|
248
258
|
it 'outputs headings when the stream initializes' do
|
249
|
-
allow(@
|
250
|
-
allow(@
|
259
|
+
allow(@streaming_client).to receive(:before_request).and_yield
|
260
|
+
allow(@streaming_client).to receive(:filter).and_return
|
251
261
|
expect(@stream).to receive(:print_table).with(any_args)
|
252
262
|
@stream.users('123')
|
253
263
|
end
|
254
|
-
|
255
264
|
it 'outputs in long text format' do
|
256
|
-
allow(@
|
257
|
-
allow(@
|
258
|
-
and_yield(@status)
|
265
|
+
allow(@streaming_client).to receive(:before_request).and_return
|
266
|
+
allow(@streaming_client).to receive(:filter).and_yield(@status)
|
259
267
|
expect(@stream).to receive(:print_table).with(any_args)
|
260
268
|
@stream.users('123')
|
261
269
|
end
|
262
270
|
end
|
263
|
-
|
264
|
-
context 'normal usage' do
|
265
|
-
before :each do
|
266
|
-
allow(@client).to receive(:filter).
|
267
|
-
and_yield(@status)
|
268
|
-
end
|
269
|
-
|
270
|
-
it 'prints the tweet status' do
|
271
|
-
expect(@stream).to receive(:print_message)
|
272
|
-
@stream.users('123')
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
271
|
it 'invokes Twitter::Streaming::Client#follow' do
|
277
|
-
allow(@
|
278
|
-
expect(@
|
272
|
+
allow(@streaming_client).to receive(:filter).and_return
|
273
|
+
expect(@streaming_client).to receive(:filter).with(:follow => '123,456,789')
|
279
274
|
@stream.users('123', '456', '789')
|
280
275
|
end
|
281
276
|
end
|