t 2.0.1 → 2.0.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.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +12 -12
- data/Rakefile +11 -1
- data/bin/t +11 -11
- data/lib/t.rb +7 -9
- data/lib/t/cli.rb +299 -360
- data/lib/t/collectable.rb +2 -4
- data/lib/t/core_ext/kernel.rb +3 -5
- data/lib/t/core_ext/string.rb +4 -6
- data/lib/t/delete.rb +27 -29
- data/lib/t/editor.rb +1 -3
- data/lib/t/list.rb +44 -45
- data/lib/t/printable.rb +43 -44
- data/lib/t/rcfile.rb +4 -5
- data/lib/t/requestable.rb +1 -3
- data/lib/t/search.rb +42 -55
- data/lib/t/set.rb +11 -12
- data/lib/t/stream.rb +24 -20
- data/lib/t/utils.rb +20 -28
- data/lib/t/version.rb +1 -3
- data/spec/cli_spec.rb +1241 -1242
- data/spec/delete_spec.rb +122 -122
- data/spec/editor_spec.rb +42 -42
- data/spec/fixtures/lists.json +1 -1
- data/spec/fixtures/locations.json +1 -1
- data/spec/helper.rb +17 -13
- data/spec/list_spec.rb +202 -202
- data/spec/rcfile_spec.rb +73 -73
- data/spec/search_spec.rb +398 -398
- data/spec/set_spec.rb +72 -72
- data/spec/stream_spec.rb +56 -56
- data/spec/utils_spec.rb +29 -29
- data/t.gemspec +1 -1
- metadata +56 -32
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
data/lib/t/collectable.rb
CHANGED
@@ -3,10 +3,9 @@ require 'retryable'
|
|
3
3
|
|
4
4
|
module T
|
5
5
|
module Collectable
|
6
|
-
|
7
6
|
MAX_NUM_RESULTS = 200
|
8
7
|
|
9
|
-
def collect_with_max_id(collection=[], max_id=nil, &block)
|
8
|
+
def collect_with_max_id(collection = [], max_id = nil, &block)
|
10
9
|
tweets = retryable(:tries => 3, :on => Twitter::Error, :sleep => 0) do
|
11
10
|
yield(max_id)
|
12
11
|
end
|
@@ -29,7 +28,7 @@ module T
|
|
29
28
|
end.flatten.compact
|
30
29
|
end
|
31
30
|
|
32
|
-
def collect_with_page(collection=[], page=1, &block)
|
31
|
+
def collect_with_page(collection = [], page = 1, &block)
|
33
32
|
tweets = retryable(:tries => 3, :on => Twitter::Error, :sleep => 0) do
|
34
33
|
yield page
|
35
34
|
end
|
@@ -37,6 +36,5 @@ module T
|
|
37
36
|
collection += tweets
|
38
37
|
tweets.empty? ? collection.flatten.uniq : collect_with_page(collection, page + 1, &block)
|
39
38
|
end
|
40
|
-
|
41
39
|
end
|
42
40
|
end
|
data/lib/t/core_ext/kernel.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
module Kernel
|
2
|
-
|
3
|
-
def Bignum(arg, base=0)
|
2
|
+
def Bignum(arg, base = 0) # rubocop:disable MethodName
|
4
3
|
Integer(arg, base)
|
5
4
|
end
|
6
5
|
|
7
|
-
def Fixnum(arg, base=0)
|
6
|
+
def Fixnum(arg, base = 0) # rubocop:disable MethodName
|
8
7
|
Integer(arg, base)
|
9
8
|
end
|
10
9
|
|
11
|
-
def NilClass(arg)
|
10
|
+
def NilClass(arg) # rubocop:disable MethodName
|
12
11
|
nil
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
data/lib/t/core_ext/string.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
class String
|
2
|
-
|
3
2
|
def prepend_at
|
4
3
|
"@#{self}"
|
5
4
|
end
|
6
5
|
|
7
6
|
def strip_ats
|
8
|
-
|
7
|
+
tr('@', '')
|
9
8
|
end
|
10
9
|
|
11
|
-
|
10
|
+
alias_method :old_to_i, :to_i
|
12
11
|
|
13
|
-
def to_i(base=10)
|
14
|
-
|
12
|
+
def to_i(base = 10)
|
13
|
+
tr(',', '').old_to_i(base)
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
data/lib/t/delete.rb
CHANGED
@@ -16,43 +16,42 @@ module T
|
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
desc
|
20
|
-
method_option
|
21
|
-
method_option
|
19
|
+
desc 'block USER [USER...]', 'Unblock users.'
|
20
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
21
|
+
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
22
22
|
def block(user, *users)
|
23
|
-
|
24
|
-
client.unblock(
|
23
|
+
unblocked_users, number = fetch_users(users.unshift(user), options) do |users_to_unblock|
|
24
|
+
client.unblock(users_to_unblock)
|
25
25
|
end
|
26
26
|
say "@#{@rcfile.active_profile[0]} unblocked #{pluralize(number, 'user')}."
|
27
27
|
say
|
28
|
-
say "Run `#{File.basename($
|
28
|
+
say "Run `#{File.basename($PROGRAM_NAME)} block #{unblocked_users.map { |unblocked_user| "@#{unblocked_user.screen_name}" }.join(' ')}` to block."
|
29
29
|
end
|
30
30
|
|
31
|
-
desc
|
32
|
-
method_option
|
31
|
+
desc 'dm [DIRECT_MESSAGE_ID] [DIRECT_MESSAGE_ID...]', 'Delete the last Direct Message sent.'
|
32
|
+
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
33
33
|
def dm(direct_message_id, *direct_message_ids)
|
34
34
|
direct_message_ids.unshift(direct_message_id)
|
35
35
|
require 't/core_ext/string'
|
36
36
|
direct_message_ids.map!(&:to_i)
|
37
37
|
if options['force']
|
38
|
-
direct_messages = client.
|
38
|
+
direct_messages = client.destroy_direct_message(direct_message_ids)
|
39
39
|
direct_messages.each do |direct_message|
|
40
40
|
say "@#{@rcfile.active_profile[0]} deleted the direct message sent to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\""
|
41
41
|
end
|
42
42
|
else
|
43
|
-
direct_message_ids.each do |
|
44
|
-
direct_message = client.direct_message(
|
43
|
+
direct_message_ids.each do |direct_message_id_to_delete|
|
44
|
+
direct_message = client.direct_message(direct_message_id_to_delete)
|
45
45
|
return unless yes? "Are you sure you want to permanently delete the direct message to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\"? [y/N]"
|
46
|
-
client.
|
46
|
+
client.destroy_direct_message(direct_message_id_to_delete)
|
47
47
|
say "@#{@rcfile.active_profile[0]} deleted the direct message sent to @#{direct_message.recipient.screen_name}: \"#{direct_message.text}\""
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
51
50
|
end
|
52
51
|
map %w(d m) => :dm
|
53
52
|
|
54
|
-
desc
|
55
|
-
method_option
|
53
|
+
desc 'favorite TWEET_ID [TWEET_ID...]', 'Delete favorites.'
|
54
|
+
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
56
55
|
def favorite(status_id, *status_ids)
|
57
56
|
status_ids.unshift(status_id)
|
58
57
|
require 't/core_ext/string'
|
@@ -63,19 +62,19 @@ module T
|
|
63
62
|
say "@#{@rcfile.active_profile[0]} unfavorited @#{status.user.screen_name}'s status: \"#{status.full_text}\""
|
64
63
|
end
|
65
64
|
else
|
66
|
-
status_ids.each do |
|
67
|
-
status = client.status(
|
65
|
+
status_ids.each do |status_id_to_unfavorite|
|
66
|
+
status = client.status(status_id_to_unfavorite, :include_my_retweet => false)
|
68
67
|
return unless yes? "Are you sure you want to remove @#{status.user.screen_name}'s status: \"#{status.full_text}\" from your favorites? [y/N]"
|
69
|
-
client.unfavorite(
|
68
|
+
client.unfavorite(status_id_to_unfavorite)
|
70
69
|
say "@#{@rcfile.active_profile[0]} unfavorited @#{status.user.screen_name}'s status: \"#{status.full_text}\""
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
74
73
|
map %w(fave favourite) => :favorite
|
75
74
|
|
76
|
-
desc
|
77
|
-
method_option
|
78
|
-
method_option
|
75
|
+
desc 'list LIST', 'Delete a list.'
|
76
|
+
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
77
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify list via ID instead of slug.'
|
79
78
|
def list(list)
|
80
79
|
if options['id']
|
81
80
|
require 't/core_ext/string'
|
@@ -85,31 +84,30 @@ module T
|
|
85
84
|
unless options['force']
|
86
85
|
return unless yes? "Are you sure you want to permanently delete the list \"#{list.name}\"? [y/N]"
|
87
86
|
end
|
88
|
-
client.
|
87
|
+
client.destroy_list(list)
|
89
88
|
say "@#{@rcfile.active_profile[0]} deleted the list \"#{list.name}\"."
|
90
89
|
end
|
91
90
|
|
92
|
-
desc
|
93
|
-
method_option
|
91
|
+
desc 'status TWEET_ID [TWEET_ID...]', 'Delete Tweets.'
|
92
|
+
method_option 'force', :aliases => '-f', :type => :boolean, :default => false
|
94
93
|
def status(status_id, *status_ids)
|
95
94
|
status_ids.unshift(status_id)
|
96
95
|
require 't/core_ext/string'
|
97
96
|
status_ids.map!(&:to_i)
|
98
97
|
if options['force']
|
99
|
-
tweets = client.
|
98
|
+
tweets = client.destroy_status(status_ids, :trim_user => true)
|
100
99
|
tweets.each do |status|
|
101
100
|
say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\""
|
102
101
|
end
|
103
102
|
else
|
104
|
-
status_ids.each do |
|
105
|
-
status = client.status(
|
103
|
+
status_ids.each do |status_id_to_delete|
|
104
|
+
status = client.status(status_id_to_delete, :include_my_retweet => false)
|
106
105
|
return unless yes? "Are you sure you want to permanently delete @#{status.user.screen_name}'s status: \"#{status.full_text}\"? [y/N]"
|
107
|
-
client.
|
106
|
+
client.destroy_status(status_id_to_delete, :trim_user => true)
|
108
107
|
say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\""
|
109
108
|
end
|
110
109
|
end
|
111
110
|
end
|
112
111
|
map %w(post tweet update) => :status
|
113
|
-
|
114
112
|
end
|
115
113
|
end
|
data/lib/t/editor.rb
CHANGED
@@ -4,7 +4,6 @@ require 'shellwords'
|
|
4
4
|
module T
|
5
5
|
class Editor
|
6
6
|
class << self
|
7
|
-
|
8
7
|
def gets
|
9
8
|
file = tempfile
|
10
9
|
edit(file.path)
|
@@ -15,7 +14,7 @@ module T
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def tempfile
|
18
|
-
Tempfile.new(
|
17
|
+
Tempfile.new('TWEET_EDITMSG')
|
19
18
|
end
|
20
19
|
|
21
20
|
def edit(path)
|
@@ -29,7 +28,6 @@ module T
|
|
29
28
|
def system_editor
|
30
29
|
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'notepad' : 'vi'
|
31
30
|
end
|
32
|
-
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
data/lib/t/list.rb
CHANGED
@@ -24,92 +24,92 @@ module T
|
|
24
24
|
super
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
28
|
-
method_option
|
27
|
+
desc 'add LIST USER [USER...]', 'Add members to a list.'
|
28
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
29
29
|
def add(list, user, *users)
|
30
|
-
|
31
|
-
client.
|
32
|
-
|
30
|
+
added_users, number = fetch_users(users.unshift(user), options) do |users_to_add|
|
31
|
+
client.add_list_members(list, users_to_add)
|
32
|
+
users_to_add
|
33
33
|
end
|
34
34
|
say "@#{@rcfile.active_profile[0]} added #{pluralize(number, 'member')} to the list \"#{list}\"."
|
35
35
|
say
|
36
36
|
if options['id']
|
37
|
-
say "Run `#{File.basename($
|
37
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list remove --id #{list} #{added_users.join(' ')}` to undo."
|
38
38
|
else
|
39
|
-
say "Run `#{File.basename($
|
39
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list remove #{list} #{added_users.map { |added_user| "@#{added_user}" }.join(' ')}` to undo."
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
desc
|
44
|
-
method_option
|
45
|
-
def create(list, description=nil)
|
43
|
+
desc 'create LIST [DESCRIPTION]', 'Create a new list.'
|
44
|
+
method_option 'private', :aliases => '-p', :type => :boolean
|
45
|
+
def create(list, description = nil)
|
46
46
|
opts = description ? {:description => description} : {}
|
47
47
|
opts.merge!(:mode => 'private') if options['private']
|
48
|
-
client.
|
48
|
+
client.create_list(list, opts)
|
49
49
|
say "@#{@rcfile.active_profile[0]} created the list \"#{list}\"."
|
50
50
|
end
|
51
51
|
|
52
|
-
desc
|
53
|
-
method_option
|
52
|
+
desc 'information [USER/]LIST', 'Retrieves detailed information about a Twitter list.'
|
53
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :default => false, :desc => 'Output in CSV format.'
|
54
54
|
def information(list)
|
55
55
|
owner, list = extract_owner(list, options)
|
56
56
|
list = client.list(owner, list)
|
57
57
|
if options['csv']
|
58
58
|
require 'csv'
|
59
|
-
say [
|
59
|
+
say ['ID', 'Description', 'Slug', 'Screen name', 'Created at', 'Members', 'Subscribers', 'Following', 'Mode', 'URL'].to_csv
|
60
60
|
say [list.id, list.description, list.slug, list.user.screen_name, csv_formatted_time(list), list.member_count, list.subscriber_count, list.following?, list.mode, list.uri].to_csv
|
61
61
|
else
|
62
62
|
array = []
|
63
|
-
array << [
|
64
|
-
array << [
|
65
|
-
array << [
|
66
|
-
array << [
|
67
|
-
array << [
|
68
|
-
array << [
|
69
|
-
array << [
|
70
|
-
array << [
|
71
|
-
array << [
|
72
|
-
array << [
|
63
|
+
array << ['ID', list.id.to_s]
|
64
|
+
array << ['Description', list.description] unless list.description.nil?
|
65
|
+
array << ['Slug', list.slug]
|
66
|
+
array << ['Screen name', "@#{list.user.screen_name}"]
|
67
|
+
array << ['Created at', "#{ls_formatted_time(list)} (#{time_ago_in_words(list.created_at)} ago)"]
|
68
|
+
array << ['Members', number_with_delimiter(list.member_count)]
|
69
|
+
array << ['Subscribers', number_with_delimiter(list.subscriber_count)]
|
70
|
+
array << ['Status', list.following ? 'Following' : 'Not following']
|
71
|
+
array << ['Mode', list.mode]
|
72
|
+
array << ['URL', list.uri]
|
73
73
|
print_table(array)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
map %w(details) => :information
|
77
77
|
|
78
|
-
desc
|
79
|
-
method_option
|
80
|
-
method_option
|
81
|
-
method_option
|
82
|
-
method_option
|
83
|
-
method_option
|
84
|
-
method_option
|
78
|
+
desc 'members [USER/]LIST', 'Returns the members of a Twitter list.'
|
79
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :default => false, :desc => 'Output in CSV format.'
|
80
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify user via ID instead of screen name.'
|
81
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :default => false, :desc => 'Output in long format.'
|
82
|
+
method_option 'reverse', :aliases => '-r', :type => :boolean, :default => false, :desc => 'Reverse the order of the sort.'
|
83
|
+
method_option 'sort', :aliases => '-s', :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => 'screen_name', :desc => 'Specify the order of the results.', :banner => 'ORDER'
|
84
|
+
method_option 'unsorted', :aliases => '-u', :type => :boolean, :default => false, :desc => 'Output is not sorted.'
|
85
85
|
def members(list)
|
86
86
|
owner, list = extract_owner(list, options)
|
87
87
|
users = client.list_members(owner, list).to_a
|
88
88
|
print_users(users)
|
89
89
|
end
|
90
90
|
|
91
|
-
desc
|
92
|
-
method_option
|
91
|
+
desc 'remove LIST USER [USER...]', 'Remove members from a list.'
|
92
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify input as Twitter user IDs instead of screen names.'
|
93
93
|
def remove(list, user, *users)
|
94
|
-
|
95
|
-
client.
|
96
|
-
|
94
|
+
removed_users, number = fetch_users(users.unshift(user), options) do |users_to_remove|
|
95
|
+
client.remove_list_members(list, users_to_remove)
|
96
|
+
users_to_remove
|
97
97
|
end
|
98
98
|
say "@#{@rcfile.active_profile[0]} removed #{pluralize(number, 'member')} from the list \"#{list}\"."
|
99
99
|
say
|
100
100
|
if options['id']
|
101
|
-
say "Run `#{File.basename($
|
101
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list add --id #{list} #{removed_users.join(' ')}` to undo."
|
102
102
|
else
|
103
|
-
say "Run `#{File.basename($
|
103
|
+
say "Run `#{File.basename($PROGRAM_NAME)} list add #{list} #{removed_users.map { |removed_user| "@#{removed_user}" }.join(' ')}` to undo."
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
desc
|
108
|
-
method_option
|
109
|
-
method_option
|
110
|
-
method_option
|
111
|
-
method_option
|
112
|
-
method_option
|
107
|
+
desc 'timeline [USER/]LIST', 'Show tweet timeline for members of the specified list.'
|
108
|
+
method_option 'csv', :aliases => '-c', :type => :boolean, :default => false, :desc => 'Output in CSV format.'
|
109
|
+
method_option 'id', :aliases => '-i', :type => :boolean, :default => false, :desc => 'Specify user via ID instead of screen name.'
|
110
|
+
method_option 'long', :aliases => '-l', :type => :boolean, :default => false, :desc => 'Output in long format.'
|
111
|
+
method_option 'number', :aliases => '-n', :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => 'Limit the number of results.'
|
112
|
+
method_option 'reverse', :aliases => '-r', :type => :boolean, :default => false, :desc => 'Reverse the order of the sort.'
|
113
113
|
def timeline(list)
|
114
114
|
owner, list = extract_owner(list, options)
|
115
115
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
@@ -119,6 +119,5 @@ module T
|
|
119
119
|
print_tweets(tweets)
|
120
120
|
end
|
121
121
|
map %w(tl) => :timeline
|
122
|
-
|
123
122
|
end
|
124
123
|
end
|
data/lib/t/printable.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module T
|
2
2
|
module Printable
|
3
|
-
LIST_HEADINGS = [
|
4
|
-
TWEET_HEADINGS = [
|
5
|
-
USER_HEADINGS = [
|
6
|
-
MONTH_IN_SECONDS =
|
3
|
+
LIST_HEADINGS = ['ID', 'Created at', 'Screen name', 'Slug', 'Members', 'Subscribers', 'Mode', 'Description']
|
4
|
+
TWEET_HEADINGS = ['ID', 'Posted at', 'Screen name', 'Text']
|
5
|
+
USER_HEADINGS = ['ID', 'Since', 'Last tweeted at', 'Tweets', 'Favorites', 'Listed', 'Following', 'Followers', 'Screen name', 'Name', 'Verified', 'Protected', 'Bio', 'Status', 'Location', 'URL']
|
6
|
+
MONTH_IN_SECONDS = 2_592_000
|
7
7
|
|
8
8
|
private
|
9
9
|
|
@@ -16,22 +16,22 @@ module T
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def build_long_user(user)
|
19
|
-
[user.id, ls_formatted_time(user), ls_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, "@#{user.screen_name}", user.name, user.verified? ?
|
19
|
+
[user.id, ls_formatted_time(user), ls_formatted_time(user.status), user.statuses_count, user.favorites_count, user.listed_count, user.friends_count, user.followers_count, "@#{user.screen_name}", user.name, user.verified? ? 'Yes' : 'No', user.protected? ? 'Yes' : 'No', user.description.gsub(/\n+/, ' '), user.status ? decode_full_text(user.status, options['decode_uris']).gsub(/\n+/, ' ') : nil, user.location, user.website.to_s]
|
20
20
|
end
|
21
21
|
|
22
|
-
def csv_formatted_time(object, key
|
22
|
+
def csv_formatted_time(object, key = :created_at)
|
23
23
|
return nil if object.nil?
|
24
24
|
time = object.send(key.to_sym).dup
|
25
|
-
time.utc.strftime(
|
25
|
+
time.utc.strftime('%Y-%m-%d %H:%M:%S %z')
|
26
26
|
end
|
27
27
|
|
28
|
-
def ls_formatted_time(object, key
|
29
|
-
return
|
28
|
+
def ls_formatted_time(object, key = :created_at)
|
29
|
+
return '' if object.nil?
|
30
30
|
time = T.local_time(object.send(key.to_sym))
|
31
31
|
if time > Time.now - MONTH_IN_SECONDS * 6
|
32
|
-
time.strftime(
|
32
|
+
time.strftime('%b %e %H:%M')
|
33
33
|
else
|
34
|
-
time.strftime(
|
34
|
+
time.strftime('%b %e %Y')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -53,17 +53,17 @@ module T
|
|
53
53
|
|
54
54
|
def print_lists(lists)
|
55
55
|
lists = case options['sort']
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
when 'members'
|
57
|
+
lists.sort_by { |user| user.member_count }
|
58
|
+
when 'mode'
|
59
|
+
lists.sort_by { |user| user.mode }
|
60
|
+
when 'since'
|
61
|
+
lists.sort_by { |user| user.created_at }
|
62
|
+
when 'subscribers'
|
63
|
+
lists.sort_by { |user| user.subscriber_count }
|
64
|
+
else
|
65
|
+
lists.sort_by { |list| list.slug.downcase }
|
66
|
+
end unless options['unsorted']
|
67
67
|
lists.reverse! if options['reverse']
|
68
68
|
if options['csv']
|
69
69
|
require 'csv'
|
@@ -75,7 +75,7 @@ module T
|
|
75
75
|
array = lists.map do |list|
|
76
76
|
build_long_list(list)
|
77
77
|
end
|
78
|
-
format = options['format'] || LIST_HEADINGS.size.times.map{
|
78
|
+
format = options['format'] || LIST_HEADINGS.size.times.map { '%s' }
|
79
79
|
print_table_with_headings(array, LIST_HEADINGS, format)
|
80
80
|
else
|
81
81
|
print_attribute(lists, :full_name)
|
@@ -132,7 +132,7 @@ module T
|
|
132
132
|
array = tweets.map do |tweet|
|
133
133
|
build_long_tweet(tweet)
|
134
134
|
end
|
135
|
-
format = options['format'] || TWEET_HEADINGS.size.times.map{
|
135
|
+
format = options['format'] || TWEET_HEADINGS.size.times.map { '%s' }
|
136
136
|
print_table_with_headings(array, TWEET_HEADINGS, format)
|
137
137
|
else
|
138
138
|
tweets.each do |tweet|
|
@@ -141,25 +141,25 @@ module T
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
def print_users(users)
|
144
|
+
def print_users(users) # rubocop:disable CyclomaticComplexity
|
145
145
|
users = case options['sort']
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
146
|
+
when 'favorites'
|
147
|
+
users.sort_by { |user| user.favorites_count.to_i }
|
148
|
+
when 'followers'
|
149
|
+
users.sort_by { |user| user.followers_count.to_i }
|
150
|
+
when 'friends'
|
151
|
+
users.sort_by { |user| user.friends_count.to_i }
|
152
|
+
when 'listed'
|
153
|
+
users.sort_by { |user| user.listed_count.to_i }
|
154
|
+
when 'since'
|
155
|
+
users.sort_by { |user| user.created_at }
|
156
|
+
when 'tweets'
|
157
|
+
users.sort_by { |user| user.statuses_count.to_i }
|
158
|
+
when 'tweeted'
|
159
|
+
users.sort_by { |user| user.status? ? user.status.created_at : Time.at(0) }
|
160
|
+
else
|
161
|
+
users.sort_by { |user| user.screen_name.downcase }
|
162
|
+
end unless options['unsorted']
|
163
163
|
users.reverse! if options['reverse']
|
164
164
|
if options['csv']
|
165
165
|
require 'csv'
|
@@ -171,12 +171,11 @@ module T
|
|
171
171
|
array = users.map do |user|
|
172
172
|
build_long_user(user)
|
173
173
|
end
|
174
|
-
format = options['format'] || USER_HEADINGS.size.times.map{
|
174
|
+
format = options['format'] || USER_HEADINGS.size.times.map { '%s' }
|
175
175
|
print_table_with_headings(array, USER_HEADINGS, format)
|
176
176
|
else
|
177
177
|
print_attribute(users, :screen_name)
|
178
178
|
end
|
179
179
|
end
|
180
|
-
|
181
180
|
end
|
182
181
|
end
|