t 0.9.1 → 0.9.2
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 +6 -5
- data/lib/t/printable.rb +19 -10
- data/lib/t/stream.rb +33 -5
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +3 -3
- metadata +1 -1
data/README.md
CHANGED
@@ -30,9 +30,9 @@ consumer key and secret, which you can use to authorize your Twitter account.
|
|
30
30
|
|
31
31
|
This command directs you to a URL where you can sign-in to Twitter and then
|
32
32
|
enter the returned PIN back into the terminal. If you type the PIN correctly,
|
33
|
-
you should now be authorized
|
34
|
-
|
35
|
-
|
33
|
+
you should now be authorized to use `t` as that user. To authorize multiple
|
34
|
+
accounts, simply repeat the last step, signing into Twitter as a different
|
35
|
+
user.
|
36
36
|
|
37
37
|
You can see a list of all the accounts you've authorized by typing the command:
|
38
38
|
|
@@ -48,12 +48,13 @@ The output of which will be structured like this:
|
|
48
48
|
|
49
49
|
**Note**: One of your authorized accounts (specifically, the last one
|
50
50
|
authorized) will be set as active. To change the active account, use the `set`
|
51
|
-
subcommand, passing either just
|
52
|
-
|
51
|
+
subcommand, passing either just a username, if it's unambiguous, or a username
|
52
|
+
and consumer key pair, like this:
|
53
53
|
|
54
54
|
t set active sferik UDfNTpOz5ZDG4a6w7dIWj
|
55
55
|
|
56
56
|
Account information is stored in a YAML-formatted file located at `~/.trc`.
|
57
|
+
|
57
58
|
**Note**: Anyone with access to this file can masquerade as you on Twitter, so
|
58
59
|
it's important to keep it secure, just as you would treat your SSH private key.
|
59
60
|
For this reason, the file is hidden and has the permission bits set to `0600`.
|
data/lib/t/printable.rb
CHANGED
@@ -17,7 +17,7 @@ module T
|
|
17
17
|
|
18
18
|
def build_long_list(list)
|
19
19
|
created_at = list.created_at > 6.months.ago ? list.created_at.strftime("%b %e %H:%M") : list.created_at.strftime("%b %e %Y")
|
20
|
-
[list.id, created_at, list.
|
20
|
+
[list.id, created_at, "@#{list.user.screen_name}", list.slug, number_with_delimiter(list.member_count), number_with_delimiter(list.subscriber_count), list.mode, list.description]
|
21
21
|
end
|
22
22
|
|
23
23
|
def build_long_status(status)
|
@@ -55,6 +55,14 @@ module T
|
|
55
55
|
puts
|
56
56
|
end
|
57
57
|
|
58
|
+
def list_headings
|
59
|
+
["ID", "Created at", "Screen name", "Slug", "Members", "Subscribers", "Mode", "Description"]
|
60
|
+
end
|
61
|
+
|
62
|
+
def status_headings
|
63
|
+
["ID", "Posted at", "Screen name", "Text"]
|
64
|
+
end
|
65
|
+
|
58
66
|
def print_lists(lists)
|
59
67
|
lists = lists.sort_by{|list| list.slug.downcase} unless options['unsorted']
|
60
68
|
if options['posted']
|
@@ -68,7 +76,7 @@ module T
|
|
68
76
|
end
|
69
77
|
lists.reverse! if options['reverse']
|
70
78
|
if options['csv']
|
71
|
-
say
|
79
|
+
say list_headings.to_csv unless lists.empty?
|
72
80
|
lists.each do |list|
|
73
81
|
print_csv_list(list)
|
74
82
|
end
|
@@ -77,8 +85,7 @@ module T
|
|
77
85
|
build_long_list(list)
|
78
86
|
end
|
79
87
|
if STDOUT.tty?
|
80
|
-
|
81
|
-
array.unshift(headings) unless lists.empty?
|
88
|
+
array.unshift(list_headings) unless lists.empty?
|
82
89
|
print_table(array, :truncate => true)
|
83
90
|
else
|
84
91
|
print_table(array)
|
@@ -108,7 +115,7 @@ module T
|
|
108
115
|
def print_statuses(statuses)
|
109
116
|
statuses.reverse! if options['reverse'] || options['stream']
|
110
117
|
if options['csv']
|
111
|
-
say
|
118
|
+
say status_headings.to_csv unless statuses.empty?
|
112
119
|
statuses.each do |status|
|
113
120
|
print_csv_status(status)
|
114
121
|
end
|
@@ -117,8 +124,7 @@ module T
|
|
117
124
|
build_long_status(status)
|
118
125
|
end
|
119
126
|
if STDOUT.tty?
|
120
|
-
|
121
|
-
array.unshift(headings) unless statuses.empty?
|
127
|
+
array.unshift(status_headings) unless statuses.empty?
|
122
128
|
print_table(array, :truncate => true)
|
123
129
|
else
|
124
130
|
print_table(array)
|
@@ -130,6 +136,10 @@ module T
|
|
130
136
|
end
|
131
137
|
end
|
132
138
|
|
139
|
+
def user_headings
|
140
|
+
["ID", "Since", "Tweets", "Favorites", "Listed", "Following", "Followers", "Screen name", "Name"]
|
141
|
+
end
|
142
|
+
|
133
143
|
def print_users(users)
|
134
144
|
users = users.sort_by{|user| user.screen_name.downcase} unless options['unsorted']
|
135
145
|
if options['posted']
|
@@ -147,7 +157,7 @@ module T
|
|
147
157
|
end
|
148
158
|
users.reverse! if options['reverse']
|
149
159
|
if options['csv']
|
150
|
-
say
|
160
|
+
say user_headings.to_csv unless users.empty?
|
151
161
|
users.each do |user|
|
152
162
|
print_csv_user(user)
|
153
163
|
end
|
@@ -156,8 +166,7 @@ module T
|
|
156
166
|
build_long_user(user)
|
157
167
|
end
|
158
168
|
if STDOUT.tty?
|
159
|
-
|
160
|
-
array.unshift(headings) unless users.empty?
|
169
|
+
array.unshift(user_headings) unless users.empty?
|
161
170
|
print_table(array, :truncate => true)
|
162
171
|
else
|
163
172
|
print_table(array)
|
data/lib/t/stream.rb
CHANGED
@@ -15,9 +15,17 @@ module T
|
|
15
15
|
end
|
16
16
|
|
17
17
|
desc "all", "Stream a random sample of all Tweets (Control-C to stop)"
|
18
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
18
19
|
def all
|
20
|
+
if options['csv']
|
21
|
+
say status_headings.to_csv
|
22
|
+
end
|
19
23
|
client.on_timeline_status do |status|
|
20
|
-
|
24
|
+
if options['csv']
|
25
|
+
print_csv_status(status)
|
26
|
+
else
|
27
|
+
print_status(status)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
Signal.trap("TERM") do
|
23
31
|
client.stop
|
@@ -39,15 +47,21 @@ module T
|
|
39
47
|
end
|
40
48
|
|
41
49
|
desc "search KEYWORD [KEYWORD...]", "Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)"
|
50
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
42
51
|
def search(keyword, *keywords)
|
43
52
|
keywords.unshift(keyword)
|
44
53
|
client.on_inited do
|
45
|
-
search= T::Search.new
|
54
|
+
search = T::Search.new
|
55
|
+
search.options = search.options.merge(options)
|
46
56
|
search.options = search.options.merge(:reverse => true)
|
47
57
|
search.all(keywords.join(' OR '))
|
48
58
|
end
|
49
59
|
client.on_timeline_status do |status|
|
50
|
-
|
60
|
+
if options['csv']
|
61
|
+
print_csv_status(status)
|
62
|
+
else
|
63
|
+
print_status(status)
|
64
|
+
end
|
51
65
|
end
|
52
66
|
Signal.trap("TERM") do
|
53
67
|
client.stop
|
@@ -57,14 +71,20 @@ module T
|
|
57
71
|
end
|
58
72
|
|
59
73
|
desc "timeline", "Stream your timeline (Control-C to stop)"
|
74
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
60
75
|
def timeline
|
61
76
|
client.on_inited do
|
62
77
|
cli = T::CLI.new
|
78
|
+
cli.options = cli.options.merge(options)
|
63
79
|
cli.options = cli.options.merge(:reverse => true)
|
64
80
|
cli.timeline
|
65
81
|
end
|
66
82
|
client.on_timeline_status do |status|
|
67
|
-
|
83
|
+
if options['csv']
|
84
|
+
print_csv_status(status)
|
85
|
+
else
|
86
|
+
print_status(status)
|
87
|
+
end
|
68
88
|
end
|
69
89
|
Signal.trap("TERM") do
|
70
90
|
client.stop
|
@@ -74,10 +94,18 @@ module T
|
|
74
94
|
end
|
75
95
|
|
76
96
|
desc "users SCREEN_NAME [SCREEN_NAME...]", "Stream Tweets either from or in reply to specified users (Control-C to stop)"
|
97
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
77
98
|
def users(screen_name, *screen_names)
|
99
|
+
if options['csv']
|
100
|
+
say status_headings.to_csv
|
101
|
+
end
|
78
102
|
screen_names.unshift(screen_name)
|
79
103
|
client.on_timeline_status do |status|
|
80
|
-
|
104
|
+
if options['csv']
|
105
|
+
print_csv_status(status)
|
106
|
+
else
|
107
|
+
print_status(status)
|
108
|
+
end
|
81
109
|
end
|
82
110
|
Signal.trap("TERM") do
|
83
111
|
client.stop
|
data/lib/t/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -1596,9 +1596,9 @@ ID,Created at,Screen name,Slug,Members,Subscribers,Mode,Description
|
|
1596
1596
|
it "should output in long format" do
|
1597
1597
|
@cli.lists
|
1598
1598
|
$stdout.string.should == <<-eos
|
1599
|
-
ID Created at Slug
|
1600
|
-
21718825 Sep 14 2010 @sferik
|
1601
|
-
8863586 Mar 15 2010 @sferik
|
1599
|
+
ID Created at Screen name Slug Members Subscribers ...
|
1600
|
+
21718825 Sep 14 2010 @sferik code-for-america 26 5 ...
|
1601
|
+
8863586 Mar 15 2010 @sferik presidents 2 1 ...
|
1602
1602
|
eos
|
1603
1603
|
end
|
1604
1604
|
end
|