earthquake 0.4.7 → 0.4.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 CHANGED
@@ -5,6 +5,8 @@ Twitter Client on Terminal with Streaming API.
5
5
 
6
6
  It supports ruby 1.9 only.
7
7
 
8
+ **We need patches that fix the document to better english!**
9
+
8
10
  ![http://images.instagram.com/media/2011/03/21/862f3b8d119b4eeb9c52e690a0087f5e_7.jpg](http://images.instagram.com/media/2011/03/21/862f3b8d119b4eeb9c52e690a0087f5e_7.jpg)
9
11
 
10
12
  Features
@@ -71,18 +73,12 @@ The config file is '~/.earthquake/config'.
71
73
 
72
74
  The blue is excluded.
73
75
 
74
- ### Running on debug mode
75
-
76
- Earthquake.config[:debug] = true
77
-
78
- デバッグモードで動作しているとき、コードの修正は即座に反映される(正確にはコマンドの実行の直前にリロードされる)。
79
-
80
76
  Plugin
81
77
  ----
82
78
 
83
79
  "~/.earthquake/plugin" is the directory for plugins.
84
80
  At launch, Earthquake try to load files under the directory.
85
- プラグインの初期化処理は Earthquake.init のブロックの中で行うべきである。
81
+ The block that is specified for Earthquake.init will be reloaded at any command line input.
86
82
 
87
83
  ### Defining your commands
88
84
 
@@ -155,7 +151,7 @@ The 'm' is a MatchData.
155
151
 
156
152
  Earthquake.init do
157
153
  completion do |text|
158
- ['@jugyo', 'earthquake', '#eqrb'].grep(/^#{Regexp.quote(text)}/)
154
+ ['jugyo', 'earthquake', '#eqrb'].grep(/^#{Regexp.quote(text)}/)
159
155
  end
160
156
  end
161
157
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.7
1
+ 0.4.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.4.7"
8
+ s.version = "0.4.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"]
@@ -44,7 +44,7 @@ module Earthquake
44
44
  end
45
45
 
46
46
  command :mentions do
47
- puts_items twitter.mentions.reverse
47
+ puts_items twitter.mentions
48
48
  end
49
49
 
50
50
  command :follow do |m|
@@ -56,11 +56,11 @@ module Earthquake
56
56
  end
57
57
 
58
58
  command :recent do
59
- puts_items twitter.home_timeline.reverse
59
+ puts_items twitter.home_timeline
60
60
  end
61
61
 
62
62
  command :recent do |m|
63
- puts_items twitter.user_timeline(:screen_name => m[1]).reverse
63
+ puts_items twitter.user_timeline(:screen_name => m[1])
64
64
  end
65
65
 
66
66
  command :user do |m|
@@ -70,7 +70,7 @@ module Earthquake
70
70
  command :search do |m|
71
71
  puts_items twitter.search(m[1])["results"].each { |s|
72
72
  s["user"] = {"screen_name" => s["from_user"]}
73
- s["disable_cache"] = true
73
+ s["_disable_cache"] = true
74
74
  words = m[1].split(/\s+/).reject{|x| x[0] =~ /^-|^(OR|AND)$/ }.map{|x|
75
75
  case x
76
76
  when /^from:(.+)/, /^to:(.+)/
@@ -80,7 +80,7 @@ module Earthquake
80
80
  end
81
81
  }
82
82
  s["_highlights"] = words
83
- }.reverse
83
+ }
84
84
  end
85
85
 
86
86
  command %r|^:retweet\s+(\d+)$|, :as => :retweet do |m|
@@ -107,15 +107,15 @@ module Earthquake
107
107
  end
108
108
 
109
109
  command :retweeted_by_me do
110
- puts_items twitter.retweeted_by_me.reverse
110
+ puts_items twitter.retweeted_by_me
111
111
  end
112
112
 
113
113
  command :retweeted_to_me do
114
- puts_items twitter.retweeted_to_me.reverse
114
+ puts_items twitter.retweeted_to_me
115
115
  end
116
116
 
117
117
  command :retweets_of_me do
118
- puts_items twitter.retweets_of_me.reverse
118
+ puts_items twitter.retweets_of_me
119
119
  end
120
120
 
121
121
  command :block do |m|
@@ -130,6 +130,24 @@ module Earthquake
130
130
  async { twitter.report_spam(m[1]) }
131
131
  end
132
132
 
133
+ command :messages do
134
+ puts_items twitter.messages.each { |s|
135
+ s["user"] = {"screen_name" => s["sender_screen_name"]}
136
+ s["_disable_cache"] = true
137
+ }
138
+ end
139
+
140
+ command :sent_messages do
141
+ puts_items twitter.sent_messages.each { |s|
142
+ s["user"] = {"screen_name" => s["sender_screen_name"]}
143
+ s["_disable_cache"] = true
144
+ }
145
+ end
146
+
147
+ command %r|^:message (\w+)\s+(.*)|, :as => :message do |m|
148
+ async { twitter.message(*m[1, 2]) } if confirm("message '#{m[2]}' to @#{m[1]}")
149
+ end
150
+
133
151
  command :reconnect do
134
152
  reconnect
135
153
  end
@@ -90,7 +90,7 @@ module Earthquake
90
90
  EventMachine::run do
91
91
  Thread.start do
92
92
  while buf = Readline.readline("⚡ ", true)
93
- Readline::HISTORY.pop if buf.empty?
93
+ Readline::HISTORY.pop if buf.empty? || Readline::HISTORY[-1] == Readline::HISTORY[-2]
94
94
  sync { input(buf.strip) }
95
95
  end
96
96
  end
@@ -21,7 +21,12 @@ module Earthquake
21
21
 
22
22
  def input(text)
23
23
  begin
24
- reload if config[:debug]
24
+ reload
25
+ rescue Exception => e
26
+ error e
27
+ end
28
+
29
+ begin
25
30
  if command = command(text)
26
31
  command[:block].call(command[:pattern].match(text))
27
32
  elsif !text.empty?
@@ -28,7 +28,7 @@ module Earthquake
28
28
  end
29
29
 
30
30
  def puts_items(items)
31
- [items].flatten.each do |item|
31
+ [items].flatten.reverse_each do |item|
32
32
  next if filters.any? { |f| f.call(item) == false }
33
33
  outputs.each do |o|
34
34
  begin
@@ -83,11 +83,15 @@ module Earthquake
83
83
  statuses.insert(0, "[#{Time.parse(item["created_at"]).strftime('%Y.%m.%d %X')}]")
84
84
  end
85
85
 
86
- source = item["source"].u =~ />(.*)</ ? $1 : 'web'
87
- user_color = color_of(item["user"]["screen_name"])
88
- text = item["text"].u.gsub(/[@#]([0-9A-Za-z_]+)/) do |i|
86
+ source = item["source"].u =~ />(.*)</ ? $1 : 'web' rescue ''
87
+
88
+ text = item["text"].u
89
+ text.gsub!(/@([0-9A-Za-z_]+)/) do |i|
89
90
  i.c(color_of($1))
90
91
  end
92
+ text.gsub!(/(?:^#([^\s]+))|(?:\s+#([^\s]+))/) do |i|
93
+ i.c(color_of($1 || $2))
94
+ end
91
95
 
92
96
  if item["_highlights"]
93
97
  item["_highlights"].each do |h|
@@ -102,7 +106,7 @@ module Earthquake
102
106
 
103
107
  status = [
104
108
  "#{mark}" + "#{statuses.join(" ")}".c(90),
105
- "#{item["user"]["screen_name"].c(user_color)}:",
109
+ "#{item["user"]["screen_name"].c(color_of(item["user"]["screen_name"]))}:",
106
110
  "#{text}",
107
111
  "#{misc} #{source}".c(90)
108
112
  ].join(" ")
@@ -7,8 +7,8 @@ module Earthquake
7
7
  init do
8
8
  @twitter = TwitterOAuth::Client.new(config.slice(:consumer_key, :consumer_secret, :token, :secret))
9
9
 
10
- filter do |item|
11
- next if item["text"].nil? || item["disable_cache"]
10
+ output do |item|
11
+ next if item["text"].nil? || item["_disable_cache"]
12
12
  item = item.dup
13
13
  item.keys.select { |key| key =~ /^_/ }.each { |key| item.delete(key) } # remote optional data like "_stream", "_highlights"
14
14
  Earthquake.cache.write("status:#{item["id"]}", item)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.7
5
+ version: 0.4.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo