t 0.9.2 → 0.9.3
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/lib/t/printable.rb +19 -6
- data/lib/t/version.rb +1 -1
- metadata +1 -1
data/lib/t/printable.rb
CHANGED
@@ -5,6 +5,7 @@ require 'fastercsv' unless Array.new.respond_to?(:to_csv)
|
|
5
5
|
require 'highline'
|
6
6
|
require 'htmlentities'
|
7
7
|
require 'thor/shell/color'
|
8
|
+
require 'time'
|
8
9
|
|
9
10
|
module T
|
10
11
|
module Printable
|
@@ -16,32 +17,44 @@ module T
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def build_long_list(list)
|
19
|
-
created_at = list.created_at > 6.months.ago
|
20
|
+
created_at = if Time.parse(list.created_at.to_s) > 6.months.ago
|
21
|
+
list.created_at.strftime("%b %e %H:%M")
|
22
|
+
else
|
23
|
+
list.created_at.strftime("%b %e %Y")
|
24
|
+
end
|
20
25
|
[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
26
|
end
|
22
27
|
|
23
28
|
def build_long_status(status)
|
24
|
-
created_at = status.created_at > 6.months.ago
|
29
|
+
created_at = if Time.parse(status.created_at.to_s) > 6.months.ago
|
30
|
+
Time.parse(status.created_at.to_s).strftime("%b %e %H:%M")
|
31
|
+
else
|
32
|
+
Time.parse(status.created_at.to_s).strftime("%b %e %Y")
|
33
|
+
end
|
25
34
|
[status.id, created_at, "@#{status.user.screen_name}", HTMLEntities.new.decode(status.text).gsub(/\n+/, ' ')]
|
26
35
|
end
|
27
36
|
|
28
37
|
def build_long_user(user)
|
29
|
-
created_at = user.created_at > 6.months.ago
|
38
|
+
created_at = if user.created_at > 6.months.ago
|
39
|
+
Time.parse(user.created_at.to_s).strftime("%b %e %H:%M")
|
40
|
+
else
|
41
|
+
user.created_at.strftime("%b %e %Y")
|
42
|
+
end
|
30
43
|
[user.id, created_at, number_with_delimiter(user.statuses_count), number_with_delimiter(user.favourites_count), number_with_delimiter(user.listed_count), number_with_delimiter(user.friends_count), number_with_delimiter(user.followers_count), "@#{user.screen_name}", user.name]
|
31
44
|
end
|
32
45
|
|
33
46
|
def print_csv_list(list)
|
34
|
-
created_at = list.created_at.utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
47
|
+
created_at = Time.parse(list.created_at.to_s).utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
35
48
|
say [list.id, created_at, list.user.screen_name, list.slug, list.member_count, list.subscriber_count, list.mode, list.description].to_csv
|
36
49
|
end
|
37
50
|
|
38
51
|
def print_csv_status(status)
|
39
|
-
created_at = status.created_at.utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
52
|
+
created_at = Time.parse(status.created_at.to_s).utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
40
53
|
say [status.id, created_at, status.user.screen_name, HTMLEntities.new.decode(status.text)].to_csv
|
41
54
|
end
|
42
55
|
|
43
56
|
def print_csv_user(user)
|
44
|
-
created_at = user.created_at.utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
57
|
+
created_at = Time.parse(user.created_at.to_s).utc.strftime("%Y-%m-%d %H:%M:%S %z")
|
45
58
|
say [user.id, created_at, user.statuses_count, user.favourites_count, user.listed_count, user.friends_count, user.followers_count, user.screen_name, user.name].to_csv
|
46
59
|
end
|
47
60
|
|
data/lib/t/version.rb
CHANGED