t 0.9.9 → 1.0.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/README.md +51 -20
- data/bin/t +2 -1
- data/lib/t.rb +0 -7
- data/lib/t/cli.rb +188 -241
- data/lib/t/collectable.rb +11 -3
- data/lib/t/core_ext/string.rb +1 -1
- data/lib/t/delete.rb +36 -30
- data/lib/t/list.rb +19 -82
- data/lib/t/printable.rb +43 -38
- data/lib/t/rcfile.rb +76 -70
- data/lib/t/search.rb +57 -44
- data/lib/t/set.rb +3 -3
- data/lib/t/stream.rb +9 -9
- data/lib/t/{format_helpers.rb → utils.rb} +40 -3
- data/lib/t/version.rb +3 -3
- data/spec/cli_spec.rb +918 -436
- data/spec/delete_spec.rb +4 -4
- data/spec/fixtures/sferik.json +46 -62
- data/spec/fixtures/status_no_attributes.json +4 -4
- data/spec/fixtures/status_no_country.json +4 -4
- data/spec/fixtures/status_no_full_name.json +4 -4
- data/spec/fixtures/status_no_locality.json +4 -4
- data/spec/fixtures/status_no_street_address.json +4 -4
- data/spec/fixtures/users.json +105 -75
- data/spec/fixtures/users_list.json +105 -75
- data/spec/helper.rb +0 -1
- data/spec/list_spec.rb +125 -49
- data/spec/rcfile_spec.rb +28 -27
- data/spec/search_spec.rb +272 -249
- data/spec/set_spec.rb +24 -24
- data/spec/{format_helpers_spec.rb → utils_spec.rb} +7 -7
- data/t.gemspec +3 -5
- metadata +12 -54
- data/lib/t/authorizable.rb +0 -38
- data/lib/t/core_ext/enumerable.rb +0 -19
- data/spec/t_spec.rb +0 -31
data/spec/set_spec.rb
CHANGED
@@ -3,122 +3,122 @@ require 'helper'
|
|
3
3
|
|
4
4
|
describe T::Set do
|
5
5
|
|
6
|
-
before do
|
7
|
-
|
8
|
-
|
9
|
-
@t = T::CLI.new
|
6
|
+
before :each do
|
7
|
+
T::RCFile.instance.path = fixture_path + "/.trc"
|
8
|
+
@set = T::Set.new
|
10
9
|
@old_stderr = $stderr
|
11
10
|
$stderr = StringIO.new
|
12
11
|
@old_stdout = $stdout
|
13
12
|
$stdout = StringIO.new
|
14
13
|
end
|
15
14
|
|
16
|
-
after do
|
15
|
+
after :each do
|
16
|
+
T::RCFile.instance.reset
|
17
17
|
$stderr = @old_stderr
|
18
18
|
$stdout = @old_stdout
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#active" do
|
22
22
|
before do
|
23
|
-
@
|
23
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
24
24
|
end
|
25
25
|
it "should have the correct output" do
|
26
|
-
@
|
26
|
+
@set.active("testcli", "abc123")
|
27
27
|
$stdout.string.chomp.should == "Active account has been updated."
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "#bio" do
|
32
32
|
before do
|
33
|
-
@
|
33
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
34
34
|
stub_post("/1/account/update_profile.json").
|
35
|
-
with(:body => {:description => "
|
35
|
+
with(:body => {:description => "Vagabond."}).
|
36
36
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
37
37
|
end
|
38
38
|
it "should request the correct resource" do
|
39
|
-
@
|
39
|
+
@set.bio("Vagabond.")
|
40
40
|
a_post("/1/account/update_profile.json").
|
41
|
-
with(:body => {:description => "
|
41
|
+
with(:body => {:description => "Vagabond."}).
|
42
42
|
should have_been_made
|
43
43
|
end
|
44
44
|
it "should have the correct output" do
|
45
|
-
@
|
45
|
+
@set.bio("Vagabond.")
|
46
46
|
$stdout.string.chomp.should == "@testcli's bio has been updated."
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "#language" do
|
51
51
|
before do
|
52
|
-
@
|
52
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
53
53
|
stub_post("/1/account/settings.json").
|
54
54
|
with(:body => {:lang => "en"}).
|
55
55
|
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
56
56
|
end
|
57
57
|
it "should request the correct resource" do
|
58
|
-
@
|
58
|
+
@set.language("en")
|
59
59
|
a_post("/1/account/settings.json").
|
60
60
|
with(:body => {:lang => "en"}).
|
61
61
|
should have_been_made
|
62
62
|
end
|
63
63
|
it "should have the correct output" do
|
64
|
-
@
|
64
|
+
@set.language("en")
|
65
65
|
$stdout.string.chomp.should == "@testcli's language has been updated."
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#location" do
|
70
70
|
before do
|
71
|
-
@
|
71
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
72
72
|
stub_post("/1/account/update_profile.json").
|
73
73
|
with(:body => {:location => "San Francisco"}).
|
74
74
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
75
75
|
end
|
76
76
|
it "should request the correct resource" do
|
77
|
-
@
|
77
|
+
@set.location("San Francisco")
|
78
78
|
a_post("/1/account/update_profile.json").
|
79
79
|
with(:body => {:location => "San Francisco"}).
|
80
80
|
should have_been_made
|
81
81
|
end
|
82
82
|
it "should have the correct output" do
|
83
|
-
@
|
83
|
+
@set.location("San Francisco")
|
84
84
|
$stdout.string.chomp.should == "@testcli's location has been updated."
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "#name" do
|
89
89
|
before do
|
90
|
-
@
|
90
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
91
91
|
stub_post("/1/account/update_profile.json").
|
92
92
|
with(:body => {:name => "Erik Michaels-Ober"}).
|
93
93
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
94
94
|
end
|
95
95
|
it "should request the correct resource" do
|
96
|
-
@
|
96
|
+
@set.name("Erik Michaels-Ober")
|
97
97
|
a_post("/1/account/update_profile.json").
|
98
98
|
with(:body => {:name => "Erik Michaels-Ober"}).
|
99
99
|
should have_been_made
|
100
100
|
end
|
101
101
|
it "should have the correct output" do
|
102
|
-
@
|
102
|
+
@set.name("Erik Michaels-Ober")
|
103
103
|
$stdout.string.chomp.should == "@testcli's name has been updated."
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe "#url" do
|
108
108
|
before do
|
109
|
-
@
|
109
|
+
@set.options = @set.options.merge("profile" => fixture_path + "/.trc")
|
110
110
|
stub_post("/1/account/update_profile.json").
|
111
111
|
with(:body => {:url => "https://github.com/sferik"}).
|
112
112
|
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
113
113
|
end
|
114
114
|
it "should request the correct resource" do
|
115
|
-
@
|
115
|
+
@set.url("https://github.com/sferik")
|
116
116
|
a_post("/1/account/update_profile.json").
|
117
117
|
with(:body => {:url => "https://github.com/sferik"}).
|
118
118
|
should have_been_made
|
119
119
|
end
|
120
120
|
it "should have the correct output" do
|
121
|
-
@
|
121
|
+
@set.url("https://github.com/sferik")
|
122
122
|
$stdout.string.chomp.should == "@testcli's URL has been updated."
|
123
123
|
end
|
124
124
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
describe T::
|
4
|
+
describe T::Utils do
|
5
5
|
|
6
6
|
before :all do
|
7
7
|
Timecop.freeze(Time.utc(2011, 11, 24, 16, 20, 0))
|
8
8
|
T.utc_offset = 'PST'
|
9
|
+
class Test; end
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
@test = Test.new
|
14
|
+
@test.extend(T::Utils)
|
9
15
|
end
|
10
16
|
|
11
17
|
after :all do
|
@@ -13,12 +19,6 @@ describe T::FormatHelpers do
|
|
13
19
|
Timecop.return
|
14
20
|
end
|
15
21
|
|
16
|
-
before do
|
17
|
-
class Test; end
|
18
|
-
@test = Test.new
|
19
|
-
@test.extend(T::FormatHelpers)
|
20
|
-
end
|
21
|
-
|
22
22
|
describe "#distance_of_time_in_words" do
|
23
23
|
it "returns \"a split second\" if difference is less than a second" do
|
24
24
|
@test.send(:distance_of_time_in_words, (Time.utc(2011, 11, 24, 16, 20, 0))).should == "a split second"
|
data/t.gemspec
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require File.expand_path("../lib/t/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.add_dependency 'activesupport', ['>= 2.3.11', '< 4']
|
6
5
|
gem.add_dependency 'launchy', '~> 2.0'
|
7
6
|
gem.add_dependency 'fastercsv', '~> 1.5'
|
8
7
|
gem.add_dependency 'geokit', '~> 1.6'
|
@@ -10,10 +9,9 @@ Gem::Specification.new do |gem|
|
|
10
9
|
gem.add_dependency 'json', '~> 1.6'
|
11
10
|
gem.add_dependency 'oauth', '~> 0.4'
|
12
11
|
gem.add_dependency 'retryable', '~> 1.2'
|
13
|
-
gem.add_dependency 'thor', ['>= 0.
|
14
|
-
gem.add_dependency 'tweetstream', '~>
|
15
|
-
gem.add_dependency 'twitter', '~>
|
16
|
-
gem.add_dependency 'twitter-text', '~> 1.4'
|
12
|
+
gem.add_dependency 'thor', ['>= 0.16', '< 2']
|
13
|
+
gem.add_dependency 'tweetstream', '~> 2.0'
|
14
|
+
gem.add_dependency 'twitter', '~> 3.4'
|
17
15
|
gem.add_development_dependency 'pry'
|
18
16
|
gem.add_development_dependency 'rake'
|
19
17
|
gem.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: activesupport
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.3.11
|
22
|
-
- - <
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '4'
|
25
|
-
type: :runtime
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 2.3.11
|
33
|
-
- - <
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '4'
|
36
14
|
- !ruby/object:Gem::Dependency
|
37
15
|
name: launchy
|
38
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +130,7 @@ dependencies:
|
|
152
130
|
requirements:
|
153
131
|
- - ! '>='
|
154
132
|
- !ruby/object:Gem::Version
|
155
|
-
version: 0.
|
133
|
+
version: '0.16'
|
156
134
|
- - <
|
157
135
|
- !ruby/object:Gem::Version
|
158
136
|
version: '2'
|
@@ -163,7 +141,7 @@ dependencies:
|
|
163
141
|
requirements:
|
164
142
|
- - ! '>='
|
165
143
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
144
|
+
version: '0.16'
|
167
145
|
- - <
|
168
146
|
- !ruby/object:Gem::Version
|
169
147
|
version: '2'
|
@@ -174,7 +152,7 @@ dependencies:
|
|
174
152
|
requirements:
|
175
153
|
- - ~>
|
176
154
|
- !ruby/object:Gem::Version
|
177
|
-
version: '
|
155
|
+
version: '2.0'
|
178
156
|
type: :runtime
|
179
157
|
prerelease: false
|
180
158
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -182,7 +160,7 @@ dependencies:
|
|
182
160
|
requirements:
|
183
161
|
- - ~>
|
184
162
|
- !ruby/object:Gem::Version
|
185
|
-
version: '
|
163
|
+
version: '2.0'
|
186
164
|
- !ruby/object:Gem::Dependency
|
187
165
|
name: twitter
|
188
166
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,23 +168,7 @@ dependencies:
|
|
190
168
|
requirements:
|
191
169
|
- - ~>
|
192
170
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
194
|
-
type: :runtime
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
none: false
|
198
|
-
requirements:
|
199
|
-
- - ~>
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '2.4'
|
202
|
-
- !ruby/object:Gem::Dependency
|
203
|
-
name: twitter-text
|
204
|
-
requirement: !ruby/object:Gem::Requirement
|
205
|
-
none: false
|
206
|
-
requirements:
|
207
|
-
- - ~>
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: '1.4'
|
171
|
+
version: '3.4'
|
210
172
|
type: :runtime
|
211
173
|
prerelease: false
|
212
174
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -214,7 +176,7 @@ dependencies:
|
|
214
176
|
requirements:
|
215
177
|
- - ~>
|
216
178
|
- !ruby/object:Gem::Version
|
217
|
-
version: '
|
179
|
+
version: '3.4'
|
218
180
|
- !ruby/object:Gem::Dependency
|
219
181
|
name: pry
|
220
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -323,14 +285,11 @@ files:
|
|
323
285
|
- Rakefile
|
324
286
|
- t.gemspec
|
325
287
|
- bin/t
|
326
|
-
- lib/t/authorizable.rb
|
327
288
|
- lib/t/cli.rb
|
328
289
|
- lib/t/collectable.rb
|
329
|
-
- lib/t/core_ext/enumerable.rb
|
330
290
|
- lib/t/core_ext/kernel.rb
|
331
291
|
- lib/t/core_ext/string.rb
|
332
292
|
- lib/t/delete.rb
|
333
|
-
- lib/t/format_helpers.rb
|
334
293
|
- lib/t/list.rb
|
335
294
|
- lib/t/printable.rb
|
336
295
|
- lib/t/rcfile.rb
|
@@ -338,6 +297,7 @@ files:
|
|
338
297
|
- lib/t/search.rb
|
339
298
|
- lib/t/set.rb
|
340
299
|
- lib/t/stream.rb
|
300
|
+
- lib/t/utils.rb
|
341
301
|
- lib/t/version.rb
|
342
302
|
- lib/t.rb
|
343
303
|
- spec/cli_spec.rb
|
@@ -378,13 +338,12 @@ files:
|
|
378
338
|
- spec/fixtures/users.json
|
379
339
|
- spec/fixtures/users_list.json
|
380
340
|
- spec/fixtures/xml.gp
|
381
|
-
- spec/format_helpers_spec.rb
|
382
341
|
- spec/helper.rb
|
383
342
|
- spec/list_spec.rb
|
384
343
|
- spec/rcfile_spec.rb
|
385
344
|
- spec/search_spec.rb
|
386
345
|
- spec/set_spec.rb
|
387
|
-
- spec/
|
346
|
+
- spec/utils_spec.rb
|
388
347
|
homepage: http://sferik.github.com/t/
|
389
348
|
licenses: []
|
390
349
|
post_install_message:
|
@@ -405,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
364
|
version: 1.3.6
|
406
365
|
requirements: []
|
407
366
|
rubyforge_project:
|
408
|
-
rubygems_version: 1.8.
|
367
|
+
rubygems_version: 1.8.23
|
409
368
|
signing_key:
|
410
369
|
specification_version: 3
|
411
370
|
summary: CLI for Twitter
|
@@ -448,11 +407,10 @@ test_files:
|
|
448
407
|
- spec/fixtures/users.json
|
449
408
|
- spec/fixtures/users_list.json
|
450
409
|
- spec/fixtures/xml.gp
|
451
|
-
- spec/format_helpers_spec.rb
|
452
410
|
- spec/helper.rb
|
453
411
|
- spec/list_spec.rb
|
454
412
|
- spec/rcfile_spec.rb
|
455
413
|
- spec/search_spec.rb
|
456
414
|
- spec/set_spec.rb
|
457
|
-
- spec/
|
415
|
+
- spec/utils_spec.rb
|
458
416
|
has_rdoc:
|
data/lib/t/authorizable.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'oauth'
|
2
|
-
|
3
|
-
module T
|
4
|
-
module Authorizable
|
5
|
-
|
6
|
-
DEFAULT_HOST = 'api.twitter.com'
|
7
|
-
DEFAULT_PROTOCOL = 'https'
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def base_url
|
12
|
-
"#{protocol}://#{host}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def consumer
|
16
|
-
OAuth::Consumer.new(
|
17
|
-
options['consumer-key'],
|
18
|
-
options['consumer-secret'],
|
19
|
-
:site => base_url
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def generate_authorize_url(request_token)
|
24
|
-
request = consumer.create_signed_request(:get, consumer.authorize_path, request_token, pin_auth_parameters)
|
25
|
-
params = request['Authorization'].sub(/^OAuth\s+/, '').split(/,\s+/).map do |param|
|
26
|
-
key, value = param.split('=')
|
27
|
-
value =~ /"(.*?)"/
|
28
|
-
"#{key}=#{CGI::escape($1)}"
|
29
|
-
end.join('&')
|
30
|
-
"#{base_url}#{request.path}?#{params}"
|
31
|
-
end
|
32
|
-
|
33
|
-
def pin_auth_parameters
|
34
|
-
{:oauth_callback => 'oob'}
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Enumerable
|
2
|
-
|
3
|
-
def threaded_each
|
4
|
-
threads = []
|
5
|
-
each do |object|
|
6
|
-
threads << Thread.new{yield object}
|
7
|
-
end
|
8
|
-
threads.each(&:value)
|
9
|
-
end
|
10
|
-
|
11
|
-
def threaded_map
|
12
|
-
threads = []
|
13
|
-
each do |object|
|
14
|
-
threads << Thread.new{yield object}
|
15
|
-
end
|
16
|
-
threads.map(&:value)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
data/spec/t_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
describe T do
|
5
|
-
|
6
|
-
describe "#env" do
|
7
|
-
before do
|
8
|
-
T.env = "value"
|
9
|
-
end
|
10
|
-
after do
|
11
|
-
T.env = "test"
|
12
|
-
end
|
13
|
-
it "returns the value" do
|
14
|
-
T.env.should == "value"
|
15
|
-
end
|
16
|
-
it "is inquirable" do
|
17
|
-
T.env.value?.should be_true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#env=" do
|
22
|
-
after do
|
23
|
-
T.env = "test"
|
24
|
-
end
|
25
|
-
it "sets the value" do
|
26
|
-
T.env = "value"
|
27
|
-
T.env.should == "value"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|