earthquake 0.4.2 → 0.4.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/Gemfile +0 -1
- data/README.md +4 -1
- data/VERSION +1 -1
- data/earthquake.gemspec +2 -1
- data/lib/earthquake.rb +2 -1
- data/lib/earthquake/cache.rb +11 -0
- data/lib/earthquake/commands.rb +14 -11
- data/lib/earthquake/core.rb +17 -0
- data/lib/earthquake/ext.rb +2 -4
- data/lib/earthquake/input.rb +1 -1
- data/lib/earthquake/output.rb +12 -8
- data/lib/earthquake/twitter.rb +14 -0
- metadata +2 -1
data/Gemfile
CHANGED
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
|
+

|
9
|
+
|
8
10
|
Install
|
9
11
|
----
|
10
12
|
|
@@ -149,8 +151,9 @@ TODO
|
|
149
151
|
----
|
150
152
|
|
151
153
|
* more intelligent completion
|
154
|
+
* caching statuses
|
152
155
|
* typable id
|
153
|
-
*
|
156
|
+
* request asynchronously
|
154
157
|
* spec
|
155
158
|
|
156
159
|
Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
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.
|
8
|
+
s.version = "0.4.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jugyo"]
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"bin/earthquake",
|
31
31
|
"earthquake.gemspec",
|
32
32
|
"lib/earthquake.rb",
|
33
|
+
"lib/earthquake/cache.rb",
|
33
34
|
"lib/earthquake/commands.rb",
|
34
35
|
"lib/earthquake/core.rb",
|
35
36
|
"lib/earthquake/ext.rb",
|
data/lib/earthquake.rb
CHANGED
@@ -4,18 +4,19 @@
|
|
4
4
|
readline
|
5
5
|
active_support/core_ext
|
6
6
|
active_support/dependencies
|
7
|
+
active_support/cache
|
7
8
|
twitter/json_stream
|
8
9
|
notify
|
9
10
|
ap
|
10
11
|
launchy
|
11
12
|
oauth
|
12
13
|
twitter_oauth
|
13
|
-
termcolor
|
14
14
|
).each { |lib| require lib }
|
15
15
|
|
16
16
|
%w(
|
17
17
|
ext
|
18
18
|
core
|
19
|
+
cache
|
19
20
|
output
|
20
21
|
input
|
21
22
|
get_access_token
|
data/lib/earthquake/commands.rb
CHANGED
@@ -21,12 +21,14 @@ module Earthquake
|
|
21
21
|
|
22
22
|
# update
|
23
23
|
command %r|^[^:].*| do |m|
|
24
|
-
twitter.update(m[0]) if confirm("update '#{m[0]}'")
|
24
|
+
async { twitter.update(m[0]) } if confirm("update '#{m[0]}'")
|
25
25
|
end
|
26
26
|
|
27
27
|
command %r|^:reply (\d+)\s+(.*)|, :as => :reply do |m|
|
28
28
|
# TODO: fill the user name to reply
|
29
|
-
|
29
|
+
async do
|
30
|
+
twitter.update(m[2], :in_reply_to_status_id => m[1]) if confirm("reply '#{m[2]}' to #{m[1]}")
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
command :status do |m|
|
@@ -34,7 +36,8 @@ module Earthquake
|
|
34
36
|
end
|
35
37
|
|
36
38
|
command :delete do |m|
|
37
|
-
|
39
|
+
# TODO: confirm
|
40
|
+
async { twitter.status_destroy(m[1]) }
|
38
41
|
end
|
39
42
|
|
40
43
|
command :mentions do
|
@@ -42,11 +45,11 @@ module Earthquake
|
|
42
45
|
end
|
43
46
|
|
44
47
|
command :follow do |m|
|
45
|
-
twitter.friend(m[1])
|
48
|
+
async { twitter.friend(m[1]) }
|
46
49
|
end
|
47
50
|
|
48
51
|
command :unfollow do |m|
|
49
|
-
twitter.unfriend(m[1])
|
52
|
+
async { twitter.unfriend(m[1]) }
|
50
53
|
end
|
51
54
|
|
52
55
|
command :list do |m|
|
@@ -66,15 +69,15 @@ module Earthquake
|
|
66
69
|
end
|
67
70
|
|
68
71
|
command :retweet do |m|
|
69
|
-
twitter.retweet(m[1])
|
72
|
+
async { twitter.retweet(m[1]) }
|
70
73
|
end
|
71
74
|
|
72
75
|
command :favorite do |m|
|
73
|
-
twitter.favorite(m[1])
|
76
|
+
async { twitter.favorite(m[1]) }
|
74
77
|
end
|
75
78
|
|
76
79
|
command :unfavorite do |m|
|
77
|
-
twitter.unfavorite(m[1])
|
80
|
+
async { twitter.unfavorite(m[1]) }
|
78
81
|
end
|
79
82
|
|
80
83
|
command :retweeted_by_me do
|
@@ -90,15 +93,15 @@ module Earthquake
|
|
90
93
|
end
|
91
94
|
|
92
95
|
command :block do |m|
|
93
|
-
twitter.block(m[1])
|
96
|
+
async { twitter.block(m[1]) }
|
94
97
|
end
|
95
98
|
|
96
99
|
command :unblock do |m|
|
97
|
-
twitter.unblock(m[1])
|
100
|
+
async { twitter.unblock(m[1]) }
|
98
101
|
end
|
99
102
|
|
100
103
|
command :report_spam do |m|
|
101
|
-
twitter.report_spam(m[1])
|
104
|
+
async { twitter.report_spam(m[1]) }
|
102
105
|
end
|
103
106
|
|
104
107
|
command :reconnect do
|
data/lib/earthquake/core.rb
CHANGED
@@ -17,6 +17,18 @@ module Earthquake
|
|
17
17
|
inits << block
|
18
18
|
end
|
19
19
|
|
20
|
+
def onces
|
21
|
+
@once ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
def once(&block)
|
25
|
+
onces << block
|
26
|
+
end
|
27
|
+
|
28
|
+
def _once
|
29
|
+
onces.each { |block| class_eval(&block) }
|
30
|
+
end
|
31
|
+
|
20
32
|
def _init
|
21
33
|
load_config
|
22
34
|
load_plugins
|
@@ -68,6 +80,7 @@ module Earthquake
|
|
68
80
|
end
|
69
81
|
|
70
82
|
def start(*argv)
|
83
|
+
_once
|
71
84
|
_init
|
72
85
|
restore_history
|
73
86
|
|
@@ -154,6 +167,10 @@ module Earthquake
|
|
154
167
|
end
|
155
168
|
end
|
156
169
|
|
170
|
+
def async(&block)
|
171
|
+
Thread.start(&block)
|
172
|
+
end
|
173
|
+
|
157
174
|
def error(e)
|
158
175
|
notify "[ERROR] #{e.message}\n#{e.backtrace.join("\n")}"
|
159
176
|
end
|
data/lib/earthquake/ext.rb
CHANGED
data/lib/earthquake/input.rb
CHANGED
data/lib/earthquake/output.rb
CHANGED
@@ -83,24 +83,28 @@ module Earthquake
|
|
83
83
|
|
84
84
|
source = item["source"] =~ />(.*)</ ? $1 : 'web'
|
85
85
|
user_color = color_of(item["user"]["screen_name"])
|
86
|
-
text = item["text"].
|
87
|
-
c
|
88
|
-
"<#{c}>#{i}</#{c}>"
|
86
|
+
text = item["text"].gsub(/[@#]([0-9A-Za-z_]+)/) do |i|
|
87
|
+
i.c(color_of($1))
|
89
88
|
end
|
90
89
|
|
91
90
|
if item["highlights"]
|
92
91
|
item["highlights"].each do |h|
|
93
92
|
c = color_of(h).to_i + 10
|
94
93
|
text = text.gsub(/#{h}/i) do |i|
|
95
|
-
|
94
|
+
i.c(c)
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
99
98
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
mark = item["mark"] || ""
|
100
|
+
|
101
|
+
status = [
|
102
|
+
"#{mark}#{statuses.join(" ")}".c(90),
|
103
|
+
item["user"]["screen_name"].c(user_color),
|
104
|
+
"#{text}",
|
105
|
+
"#{misc} #{source}".c(90)
|
106
|
+
].join(" ")
|
107
|
+
puts status
|
104
108
|
end
|
105
109
|
|
106
110
|
output do |item|
|
data/lib/earthquake/twitter.rb
CHANGED
@@ -7,5 +7,19 @@ module Earthquake
|
|
7
7
|
@twitter = TwitterOAuth::Client.new(config.slice(:consumer_key, :consumer_secret, :token, :secret))
|
8
8
|
end
|
9
9
|
|
10
|
+
once do
|
11
|
+
class ::TwitterOAuth::Client
|
12
|
+
def status_with_cache(id)
|
13
|
+
key = "status:#{id}"
|
14
|
+
unless s = Earthquake.cache.read(key)
|
15
|
+
s = status_without_cache(id)
|
16
|
+
Earthquake.cache.write(key, s, :expires_in => 1.hour.ago)
|
17
|
+
end
|
18
|
+
s
|
19
|
+
end
|
20
|
+
alias_method_chain :status, :cache
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
10
24
|
extend Twitter
|
11
25
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: earthquake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- jugyo
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- bin/earthquake
|
167
167
|
- earthquake.gemspec
|
168
168
|
- lib/earthquake.rb
|
169
|
+
- lib/earthquake/cache.rb
|
169
170
|
- lib/earthquake/commands.rb
|
170
171
|
- lib/earthquake/core.rb
|
171
172
|
- lib/earthquake/ext.rb
|