earthquake 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/bin/earthquake +5 -2
- data/earthquake.gemspec +2 -2
- data/lib/earthquake/commands.rb +6 -2
- data/lib/earthquake/core.rb +2 -1
- data/lib/earthquake/get_access_token.rb +3 -2
- data/lib/earthquake/input.rb +25 -7
- data/lib/earthquake/twitter.rb +19 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -130,6 +130,10 @@ Blue is excluded.
|
|
130
130
|
:url => [4, 34]
|
131
131
|
}
|
132
132
|
|
133
|
+
### HTTP proxy support
|
134
|
+
|
135
|
+
Please set environment variable *http_proxy* if you want earthquake to use http proxy.
|
136
|
+
|
133
137
|
Desktop Notifications
|
134
138
|
----
|
135
139
|
|
@@ -245,7 +249,7 @@ The 'm' is a MatchData.
|
|
245
249
|
TODO
|
246
250
|
----
|
247
251
|
|
248
|
-
*
|
252
|
+
* alias
|
249
253
|
* mark my tweet
|
250
254
|
* Earthquake should parse ARGV
|
251
255
|
* ruby1.9nize
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/bin/earthquake
CHANGED
@@ -10,7 +10,10 @@ options = opts.to_hash(true)
|
|
10
10
|
options.delete(:help)
|
11
11
|
options[:dir] = argv.shift unless argv.empty?
|
12
12
|
|
13
|
-
|
13
|
+
require 'pathname'
|
14
|
+
eq_dir = Pathname.new(File.expand_path('../..', __FILE__)).realpath
|
15
|
+
|
16
|
+
$:.unshift eq_dir.join('lib') if $0 == __FILE__
|
14
17
|
|
15
18
|
print "\e[31m"
|
16
19
|
puts %q{
|
@@ -20,7 +23,7 @@ puts %q{
|
|
20
23
|
| __/ (_| | | | |_| | | | (_| | |_| | (_| | < __/
|
21
24
|
\___|\__,_|_| \__|_| |_|\__, |\__,_|\__,_|_|\_\___|
|
22
25
|
|_| }.
|
23
|
-
gsub(/^\n/, '') + "v#{
|
26
|
+
gsub(/^\n/, '') + "v#{eq_dir.join('VERSION').read}".rjust(10) + "\n\n"
|
24
27
|
print "\e[0m"
|
25
28
|
|
26
29
|
require 'earthquake'
|
data/earthquake.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{earthquake}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jugyo"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-26}
|
13
13
|
s.default_executable = %q{earthquake}
|
14
14
|
s.description = %q{Twitter Client on Terminal with Twitter Streaming API.}
|
15
15
|
s.email = %q{jugyo.org@gmail.com}
|
data/lib/earthquake/commands.rb
CHANGED
@@ -28,7 +28,7 @@ Earthquake.init do
|
|
28
28
|
input(":update #{m[0]}")
|
29
29
|
end
|
30
30
|
|
31
|
-
command %r|^:reply
|
31
|
+
command %r|^:reply\s+(\d+)\s+(.*)|, :as => :reply do |m|
|
32
32
|
in_reply_to_status_id = m[1]
|
33
33
|
target = twitter.status(in_reply_to_status_id)
|
34
34
|
screen_name = target["user"]["screen_name"]
|
@@ -88,7 +88,7 @@ Earthquake.init do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
command :search do |m|
|
91
|
-
puts_items twitter.search(m[1])["results"].each { |s|
|
91
|
+
puts_items twitter.search(m[1], config[:search_options] || {})["results"].each { |s|
|
92
92
|
s["user"] = {"screen_name" => s["from_user"]}
|
93
93
|
s["_disable_cache"] = true
|
94
94
|
words = m[1].split(/\s+/).reject{|x| x[0] =~ /^-|^(OR|AND)$/ }.map{|x|
|
@@ -247,4 +247,8 @@ Earthquake.init do
|
|
247
247
|
command :edit_config do
|
248
248
|
system ENV["EDITOR"] + " #{config[:file]}"
|
249
249
|
end
|
250
|
+
|
251
|
+
command %r|^:alias\s+:?(\w+)\s+:?(\w+)|, :as => :alias do |m|
|
252
|
+
alias_command m[1], m[2]
|
253
|
+
end
|
250
254
|
end
|
data/lib/earthquake/core.rb
CHANGED
@@ -130,7 +130,8 @@ module Earthquake
|
|
130
130
|
|
131
131
|
options = {
|
132
132
|
:oauth => config.slice(:consumer_key, :consumer_secret).merge(
|
133
|
-
:access_key => config[:token], :access_secret => config[:secret]
|
133
|
+
:access_key => config[:token], :access_secret => config[:secret],
|
134
|
+
:proxy => ENV['http_proxy']
|
134
135
|
)
|
135
136
|
}.merge(options)
|
136
137
|
|
@@ -4,7 +4,8 @@ module Earthquake
|
|
4
4
|
consumer = OAuth::Consumer.new(
|
5
5
|
self.config[:consumer_key],
|
6
6
|
self.config[:consumer_secret],
|
7
|
-
:site => 'https://api.twitter.com'
|
7
|
+
:site => 'https://api.twitter.com',
|
8
|
+
:proxy => ENV['http_proxy']
|
8
9
|
)
|
9
10
|
request_token = consumer.get_request_token
|
10
11
|
|
@@ -28,4 +29,4 @@ module Earthquake
|
|
28
29
|
end
|
29
30
|
|
30
31
|
extend GetAccessToken
|
31
|
-
end
|
32
|
+
end
|
data/lib/earthquake/input.rb
CHANGED
@@ -27,6 +27,15 @@ module Earthquake
|
|
27
27
|
completions << block
|
28
28
|
end
|
29
29
|
|
30
|
+
def command_aliases
|
31
|
+
@command_aliases ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def alias_command(name, target)
|
35
|
+
command_aliases[name.to_s] = target.to_s
|
36
|
+
command_names << ":#{name}"
|
37
|
+
end
|
38
|
+
|
30
39
|
def input(text)
|
31
40
|
return if text.empty?
|
32
41
|
|
@@ -107,20 +116,29 @@ module Earthquake
|
|
107
116
|
|
108
117
|
completion do |text|
|
109
118
|
regexp = /^#{Regexp.quote(text)}/
|
110
|
-
|
111
119
|
results = command_names.grep(regexp)
|
112
|
-
|
113
|
-
|
120
|
+
history = Readline::HISTORY.reverse_each.take(config[:history_size]) | @tweets_for_completion
|
121
|
+
history.inject(results){|r, line|
|
114
122
|
r | line.split.grep(regexp)
|
115
123
|
}
|
116
124
|
end
|
117
125
|
|
126
|
+
@tweets_for_completion ||= []
|
127
|
+
|
128
|
+
output do |item|
|
129
|
+
next unless item["text"]
|
130
|
+
@tweets_for_completion << [item["user"]["screen_name"], item["text"]].join(" ")
|
131
|
+
@tweets_for_completion.shift if @tweets_for_completion.size > config[:history_size]
|
132
|
+
end
|
133
|
+
|
118
134
|
input_filter do |text|
|
119
|
-
if text =~ %r
|
120
|
-
|
121
|
-
|
122
|
-
|
135
|
+
if text =~ %r|^:(\w+)|
|
136
|
+
if target = command_aliases[$1]
|
137
|
+
text = text.sub(%r|^:\w+|, ":#{target}")
|
138
|
+
end
|
139
|
+
text = text.gsub(/\$\w+/) { |var| var2id(var) || var }
|
123
140
|
end
|
141
|
+
text
|
124
142
|
end
|
125
143
|
end
|
126
144
|
|
data/lib/earthquake/twitter.rb
CHANGED
@@ -31,8 +31,26 @@ module Earthquake
|
|
31
31
|
end
|
32
32
|
alias_method_chain m, :cache
|
33
33
|
end
|
34
|
+
|
35
|
+
def initialize(options = {})
|
36
|
+
@consumer_key = options[:consumer_key]
|
37
|
+
@consumer_secret = options[:consumer_secret]
|
38
|
+
@token = options[:token]
|
39
|
+
@secret = options[:secret]
|
40
|
+
@proxy = ENV['http_proxy']
|
41
|
+
end
|
42
|
+
|
43
|
+
def consumer
|
44
|
+
options = { :site => 'http://api.twitter.com' }
|
45
|
+
options.update( :proxy => @proxy ) if @proxy
|
46
|
+
@consumer ||= OAuth::Consumer.new(
|
47
|
+
@consumer_key,
|
48
|
+
@consumer_secret,
|
49
|
+
options
|
50
|
+
)
|
51
|
+
end
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
37
55
|
extend Twitter
|
38
|
-
end
|
56
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: earthquake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- jugyo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-26 00:00:00 +09:00
|
14
14
|
default_executable: earthquake
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|