earthquake 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
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.7
1
+ 0.5.8
data/earthquake.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{earthquake}
8
- s.version = "0.5.7"
8
+ s.version = "0.5.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jugyo"]
@@ -1,6 +1,14 @@
1
1
  class String
2
2
  def c(*codes)
3
- "\e[#{codes.join;}m#{self}\e[0m"
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
@@ -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(4).c(36)
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(90),
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(31) : nil),
113
- info.join(' - ').c(90)
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(42) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
127
+ puts "[#{item["event"]}]".c(:event) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
125
128
  when "favorite", "unfavorite"
126
- puts "[#{item["event"]}]".c(42) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]} : #{item["target_object"]["text"].u}"
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(42) + " #{item["delete"]["status"]["id"]}"
131
+ puts "[deleted]".c(:event) + " #{item["delete"]["status"]["id"]}"
129
132
  else
130
133
  if config[:debug]
131
134
  ap item
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.7
5
+ version: 0.5.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo