earthquake 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,8 @@ It supports only Ruby 1.9.
6
6
 
7
7
  Homepage: [https://github.com/jugyo/earthquake](https://github.com/jugyo/earthquake)
8
8
  Twitter: [http://twitter.com/earthquakegem](http://twitter.com/earthquakegem)
9
- Demo: [http://www.youtube.com/watch?v=S2KtBGrIe5c](http://www.youtube.com/watch?v=S2KtBGrIe5c)
9
+ Demo: [http://www.youtube.com/watch?v=S2KtBGrIe5c](http://www.youtube.com/watch?v=S2KtBGrIe5c)
10
+ Slide: [http://www.slideshare.net/jugyo/earthquakegem](http://www.slideshare.net/jugyo/earthquakegem)
10
11
 
11
12
  **We need patches that fix the english of the documentation!**
12
13
 
@@ -24,6 +25,10 @@ Install
24
25
 
25
26
  $ gem install earthquake
26
27
 
28
+ **Ubuntu:** The EventMachine needs the package libssl-dev.
29
+
30
+ $ sudo apt-get install libssl-dev
31
+
27
32
  Usage
28
33
  ----
29
34
 
@@ -143,7 +148,7 @@ You can try it by using the :eval command:
143
148
  Plugins
144
149
  ----
145
150
 
146
- => [https://github.com/jugyo/earthquake/wiki/Plugins](https://github.com/jugyo/earthquake/wiki/Plugins)
151
+ see [https://github.com/jugyo/earthquake/wiki](https://github.com/jugyo/earthquake/wiki)
147
152
 
148
153
  Making Plugin
149
154
  ----
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.11
1
+ 0.6.12
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.6.11"
8
+ s.version = "0.6.12"
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-04-25}
12
+ s.date = %q{2011-05-09}
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}
@@ -60,7 +60,7 @@ Accordingly, you should renew the access token if it is old.
60
60
  }
61
61
  s.require_paths = ["lib"]
62
62
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
63
- s.rubygems_version = %q{1.6.0}
63
+ s.rubygems_version = %q{1.6.2}
64
64
  s.summary = %q{Twitter Client on Terminal.}
65
65
  s.test_files = [
66
66
  "spec/earthquake_spec.rb",
@@ -112,7 +112,7 @@ Earthquake.init do
112
112
 
113
113
  command %r|^:retweet\s+(\d+)\s+(.*)$|, :as => :retweet do |m|
114
114
  target = twitter.status(m[1])
115
- text = "#{m[2]} RT @#{target["user"]["screen_name"]}: #{target["text"]} (#{target["id"]})"
115
+ text = "#{m[2]} #{config[:quotetweet] ? "QT" : "RT"} @#{target["user"]["screen_name"]}: #{target["text"]} (#{target["id"]})"
116
116
  if confirm("unofficial retweet '#{text}'")
117
117
  async_e { twitter.update(text) }
118
118
  end
@@ -188,16 +188,24 @@ module Earthquake
188
188
  end
189
189
 
190
190
  def async(&block)
191
- Thread.start(&block)
191
+ Thread.start do
192
+ begin
193
+ block.call
194
+ rescue Exception => e
195
+ error e
196
+ end
197
+ end
192
198
  end
193
199
 
194
200
  def error(e)
195
201
  notify "[ERROR] #{e.message}\n#{e.backtrace.join("\n")}"
196
202
  end
197
203
 
198
- def notify(message, options = {:title => 'earthquake'})
204
+ def notify(message, options = {})
205
+ args = {:title => 'earthquake'}.update(options)
206
+ title = args.delete(:title)
199
207
  message = message.is_a?(String) ? message : message.inspect
200
- Notify.notify options[:title], message
208
+ Notify.notify title, message.e, args
201
209
  end
202
210
  alias_method :n, :notify
203
211
 
@@ -51,27 +51,19 @@ class String
51
51
  end
52
52
  end
53
53
 
54
- def u
55
- gsub(/&(lt|gt|amp|quot|apos);/) do |s|
56
- case s
57
- when '&' then '&'
58
- when '&lt;' then '<'
59
- when '&gt;' then '>'
60
- when '&apos;' then "'"
61
- when '&quot;' then '"'
62
- end
63
- end
54
+ t = {
55
+ ?& => "&amp;",
56
+ ?< => "&lt;",
57
+ ?> => "&gt;",
58
+ ?' => "&apos;",
59
+ ?" => "&quot;",
60
+ }
61
+
62
+ define_method(:u) do
63
+ gsub(/(#{Regexp.union(t.values)})/o, t.invert)
64
64
  end
65
65
 
66
- def e
67
- gsub(/[&<>'"]/) do |s|
68
- case s
69
- when '&' then '&amp;'
70
- when '<' then '&lt;'
71
- when '>' then '&gt;'
72
- when "'" then '&apos;'
73
- when '"' then '&quot;'
74
- end
75
- end
66
+ define_method(:e) do
67
+ gsub(/[#{t.keys.join}]/o, t)
76
68
  end
77
- end
69
+ end
@@ -11,33 +11,33 @@ module Earthquake
11
11
  end
12
12
 
13
13
  class Gen
14
- def initialize(vars = ('aa'..'zz').to_a, prefix = '$')
15
- if not vars.kind_of?(Array)
16
- raise ArgumentError, 'vars should be an Array'
17
- elsif vars.empty?
18
- raise ArgumentError, 'vars should not be empty'
14
+ def initialize(vars = "aa".."zz", prefix = "$")
15
+ unless Range === vars and String === vars.first
16
+ raise ArgumentError, "vars should be a Range of String"
19
17
  end
20
- @vars = vars.map { |var| prefix + var }
21
- @table = {}
22
- @rtable = {}
18
+ @vars = vars
19
+ @var = @vars.last.dup
20
+ @table = ActiveSupport::Cache::MemoryStore.new
23
21
  @prefix = prefix
24
22
  end
25
23
 
26
24
  def var2id(var)
27
- @table[var]
25
+ @table.read(var)
28
26
  end
29
27
 
30
28
  def id2var(id)
31
- @rtable[id] || self.next(id)
29
+ @table.read(id) || succ(id)
32
30
  end
33
31
 
34
- def next(id)
35
- var = @vars.shift
36
- @vars.push var
37
- @rtable.delete(@table[var])
38
- @table[var] = id
39
- @rtable[id] = var
40
- var
32
+ private
33
+
34
+ def succ(id)
35
+ @var.replace(@vars.first.dup) unless @vars.include?(@var.next!)
36
+ var = @prefix + @var
37
+ @table.delete(@table.read(var))
38
+ @table.write(var, id)
39
+ @table.write(id, var)
40
+ var.dup
41
41
  end
42
42
  end
43
43
  end
@@ -47,4 +47,4 @@ module Earthquake
47
47
  init do
48
48
  self.id_var ||= IdVar::Gen.new
49
49
  end
50
- end
50
+ end
@@ -97,7 +97,7 @@ module Earthquake
97
97
  Readline.completion_proc = lambda do |text|
98
98
  completions.inject([]) do |results, completion|
99
99
  begin
100
- results + (completion.call(text) || [])
100
+ results | (completion.call(text) || [])
101
101
  rescue Exception => e
102
102
  error e
103
103
  results
@@ -106,15 +106,13 @@ module Earthquake
106
106
  end
107
107
 
108
108
  completion do |text|
109
- results = []
110
109
  regexp = /^#{Regexp.quote(text)}/
111
110
 
112
- results += command_names.grep(regexp)
111
+ results = command_names.grep(regexp)
113
112
 
114
- range = Readline::HISTORY.count >= config[:history_size] ? -config[:history_size]..-1 : 0..-1
115
- results += Readline::HISTORY.to_a[range].map { |line| line.split(/\s+/) }.flatten.grep(regexp)
116
-
117
- results
113
+ Readline::HISTORY.reverse_each.take(config[:history_size]).inject(results){|r, line|
114
+ r | line.split.grep(regexp)
115
+ }
118
116
  end
119
117
 
120
118
  input_filter do |text|
@@ -93,7 +93,7 @@ module Earthquake
93
93
 
94
94
  id = id2var(item["id"])
95
95
 
96
- text = item["text"].u
96
+ text = (item["retweeted_status"] && item["truncated"] ? "RT: @#{item["retweeted_status"]["user"]["screen_name"]} #{item["retweeted_status"]["text"]}" : item["text"]).u
97
97
  text.gsub!(/\s+/, ' ') unless config[:raw_text]
98
98
  text = text.coloring(/@[0-9A-Za-z_]+/) { |i| color_of(i) }
99
99
  text = text.coloring(/(^#[^\s]+)|(\s+#[^\s]+)/) { |i| color_of(i) }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.11
5
+ version: 0.6.12
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-04-25 00:00:00 +09:00
13
+ date: 2011-05-09 00:00:00 +09:00
14
14
  default_executable: earthquake
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements: []
206
206
 
207
207
  rubyforge_project:
208
- rubygems_version: 1.6.0
208
+ rubygems_version: 1.6.2
209
209
  signing_key:
210
210
  specification_version: 3
211
211
  summary: Twitter Client on Terminal.