earthquake 0.5.7 → 0.5.8
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 +12 -1
- data/VERSION +1 -1
- data/earthquake.gemspec +1 -1
- data/lib/earthquake/ext.rb +9 -1
- data/lib/earthquake/output.rb +15 -12
- metadata +1 -1
data/README.md
CHANGED
@@ -101,13 +101,23 @@ You can change the directory at launch as below:
|
|
101
101
|
|
102
102
|
$ earthquake ~/.earthquake_foo
|
103
103
|
|
104
|
-
### Changing the colors
|
104
|
+
### Changing the colors for user name
|
105
105
|
|
106
106
|
# ~/.earthquake/config
|
107
107
|
Earthquake.config[:colors] = (31..36).to_a - [34]
|
108
108
|
|
109
109
|
Blue is excluded.
|
110
110
|
|
111
|
+
### Changing the color scheme
|
112
|
+
|
113
|
+
# ~/.earthquake/config
|
114
|
+
Earthquake.config[:color] = {
|
115
|
+
:info => 34,
|
116
|
+
:notice => 41,
|
117
|
+
:event => 46,
|
118
|
+
:url => [4, 34]
|
119
|
+
}
|
120
|
+
|
111
121
|
Desktop Notifications
|
112
122
|
----
|
113
123
|
|
@@ -208,6 +218,7 @@ The 'm' is a MatchData.
|
|
208
218
|
TODO
|
209
219
|
----
|
210
220
|
|
221
|
+
* guideline for plugin
|
211
222
|
* ssl for twitter_oauth
|
212
223
|
* deal proxy
|
213
224
|
* spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.8
|
data/earthquake.gemspec
CHANGED
data/lib/earthquake/ext.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
class String
|
2
2
|
def c(*codes)
|
3
|
-
|
3
|
+
codes = codes.map { |code|
|
4
|
+
case code
|
5
|
+
when String, Symbol
|
6
|
+
Earthquake.config[:color][code.to_sym] rescue nil
|
7
|
+
else
|
8
|
+
code
|
9
|
+
end
|
10
|
+
}.compact.unshift(0)
|
11
|
+
"\e[#{codes.join(';')}m#{self}\e[0m"
|
4
12
|
end
|
5
13
|
|
6
14
|
def u
|
data/lib/earthquake/output.rb
CHANGED
@@ -53,11 +53,7 @@ module Earthquake
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def color_of(screen_name)
|
56
|
-
colors[screen_name.to_i(36) % colors.size]
|
57
|
-
end
|
58
|
-
|
59
|
-
def colors
|
60
|
-
config[:colors]
|
56
|
+
config[:colors][screen_name.to_i(36) % config[:colors].size]
|
61
57
|
end
|
62
58
|
end
|
63
59
|
|
@@ -66,6 +62,13 @@ module Earthquake
|
|
66
62
|
output_filters.clear
|
67
63
|
|
68
64
|
config[:colors] ||= (31..36).to_a + (91..96).to_a
|
65
|
+
config[:color] ||= {}
|
66
|
+
config[:color].reverse_merge!(
|
67
|
+
:info => 90,
|
68
|
+
:notice => 31,
|
69
|
+
:event => 42,
|
70
|
+
:url => [4, 36]
|
71
|
+
)
|
69
72
|
|
70
73
|
output do |item|
|
71
74
|
next unless item["text"]
|
@@ -91,7 +94,7 @@ module Earthquake
|
|
91
94
|
i.c(color_of($1 || $2))
|
92
95
|
end
|
93
96
|
text.gsub!(URI.regexp(["http", "https"])) do |i|
|
94
|
-
i.c(
|
97
|
+
i.c(:url)
|
95
98
|
end
|
96
99
|
|
97
100
|
if item["_highlights"]
|
@@ -106,11 +109,11 @@ module Earthquake
|
|
106
109
|
mark = item["_mark"] || ""
|
107
110
|
|
108
111
|
status = [
|
109
|
-
"#{mark}" + "[#{id}]".c(
|
112
|
+
"#{mark}" + "[#{id}]".c(:info),
|
110
113
|
"#{item["user"]["screen_name"].c(color_of(item["user"]["screen_name"]))}:",
|
111
114
|
"#{text}",
|
112
|
-
(item["user"]["protected"] ? "[P]".c(
|
113
|
-
info.join(' - ').c(
|
115
|
+
(item["user"]["protected"] ? "[P]".c(:notice) : nil),
|
116
|
+
info.join(' - ').c(:info)
|
114
117
|
].compact.join(" ")
|
115
118
|
puts status
|
116
119
|
end
|
@@ -121,11 +124,11 @@ module Earthquake
|
|
121
124
|
# TODO: handle 'list_member_added' and 'list_member_removed'
|
122
125
|
case item["event"]
|
123
126
|
when "follow", "block", "unblock"
|
124
|
-
puts "[#{item["event"]}]".c(
|
127
|
+
puts "[#{item["event"]}]".c(:event) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
|
125
128
|
when "favorite", "unfavorite"
|
126
|
-
puts "[#{item["event"]}]".c(
|
129
|
+
puts "[#{item["event"]}]".c(:event) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]} : #{item["target_object"]["text"].u}"
|
127
130
|
when "delete"
|
128
|
-
puts "[deleted]".c(
|
131
|
+
puts "[deleted]".c(:event) + " #{item["delete"]["status"]["id"]}"
|
129
132
|
else
|
130
133
|
if config[:debug]
|
131
134
|
ap item
|