earthquake 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'awesome_print'
8
8
  gem 'launchy'
9
9
  gem 'oauth'
10
10
  gem 'twitter_oauth'
11
+ gem 'ruby-growl'
11
12
 
12
13
  group :development do
13
14
  gem "rspec", "~> 2.3.0"
data/Gemfile.lock CHANGED
@@ -29,6 +29,7 @@ GEM
29
29
  rspec-expectations (2.3.0)
30
30
  diff-lcs (~> 1.1.2)
31
31
  rspec-mocks (2.3.0)
32
+ ruby-growl (3.0)
32
33
  twitter-stream (0.1.12)
33
34
  eventmachine (>= 0.12.8)
34
35
  roauth (>= 0.0.2)
@@ -50,5 +51,6 @@ DEPENDENCIES
50
51
  notify
51
52
  oauth
52
53
  rspec (~> 2.3.0)
54
+ ruby-growl
53
55
  twitter-stream
54
56
  twitter_oauth
data/README.md CHANGED
@@ -119,7 +119,7 @@ The 'm' is a MatchData.
119
119
 
120
120
  Earthquake.init do
121
121
  output do |item|
122
- next unless item["stream"]
122
+ next unless item["_stream"]
123
123
  if item["text"] =~ /ruby/i
124
124
  notify "#{item["user"]["screen_name"]}: #{item["text"]}"
125
125
  end
@@ -143,7 +143,7 @@ The 'm' is a MatchData.
143
143
 
144
144
  Earthquake.init do
145
145
  filter do |item|
146
- if item["stream"] && item["text"]
146
+ if item["_stream"] && item["text"]
147
147
  item["text"] =~ /ruby/i
148
148
  else
149
149
  true
data/Rakefile CHANGED
@@ -37,6 +37,7 @@ Accordingly that, You should renew the access token if it is old.
37
37
  $ earthquake
38
38
 
39
39
  }
40
+ gem.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
40
41
  end
41
42
  Jeweler::RubygemsDotOrgTasks.new
42
43
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
data/bin/earthquake CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift(File.expand_path('../../lib', __FILE__))
2
+ $:.unshift(File.expand_path('../../lib', __FILE__)) if $0 == __FILE__
3
3
  require 'earthquake'
4
4
  Earthquake.start(ARGV)
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.4.6"
8
+ s.version = "0.4.7"
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-03-21}
12
+ s.date = %q{2011-03-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}
@@ -58,6 +58,7 @@ Accordingly that, You should renew the access token if it is old.
58
58
 
59
59
  }
60
60
  s.require_paths = ["lib"]
61
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
61
62
  s.rubygems_version = %q{1.6.0}
62
63
  s.summary = %q{Twitter Client on Terminal.}
63
64
  s.test_files = [
@@ -77,7 +78,7 @@ Accordingly that, You should renew the access token if it is old.
77
78
  s.add_runtime_dependency(%q<launchy>, [">= 0"])
78
79
  s.add_runtime_dependency(%q<oauth>, [">= 0"])
79
80
  s.add_runtime_dependency(%q<twitter_oauth>, [">= 0"])
80
- s.add_runtime_dependency(%q<termcolor>, [">= 0"])
81
+ s.add_runtime_dependency(%q<ruby-growl>, [">= 0"])
81
82
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
82
83
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
83
84
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
@@ -90,7 +91,7 @@ Accordingly that, You should renew the access token if it is old.
90
91
  s.add_dependency(%q<launchy>, [">= 0"])
91
92
  s.add_dependency(%q<oauth>, [">= 0"])
92
93
  s.add_dependency(%q<twitter_oauth>, [">= 0"])
93
- s.add_dependency(%q<termcolor>, [">= 0"])
94
+ s.add_dependency(%q<ruby-growl>, [">= 0"])
94
95
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
95
96
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
96
97
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
@@ -104,7 +105,7 @@ Accordingly that, You should renew the access token if it is old.
104
105
  s.add_dependency(%q<launchy>, [">= 0"])
105
106
  s.add_dependency(%q<oauth>, [">= 0"])
106
107
  s.add_dependency(%q<twitter_oauth>, [">= 0"])
107
- s.add_dependency(%q<termcolor>, [">= 0"])
108
+ s.add_dependency(%q<ruby-growl>, [">= 0"])
108
109
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
109
110
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
110
111
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
@@ -6,13 +6,13 @@ module Earthquake
6
6
  end
7
7
 
8
8
  command :help do
9
- puts "TODO..."
9
+ system 'less', File.expand_path('../../../README.md', __FILE__)
10
10
  end
11
11
 
12
12
  command :restart do
13
13
  puts 'restarting...'
14
14
  stop
15
- exec File.expand_path('../../..//bin/earthquake', __FILE__)
15
+ exec File.expand_path('../../../bin/earthquake', __FILE__)
16
16
  end
17
17
 
18
18
  command :eval do |m|
@@ -29,7 +29,7 @@ module Earthquake
29
29
  target = twitter.status(in_reply_to_status_id)
30
30
  screen_name = target["user"]["screen_name"]
31
31
  text = "@#{screen_name} #{m[2]}"
32
- if confirm(["'@#{screen_name}: #{target["text"].u}'".c(36), "reply '#{text}'"].join("\n"))
32
+ if confirm(["'@#{screen_name}: #{target["text"].u}'", "reply '#{text}'"].join("\n"))
33
33
  async { twitter.update(text, :in_reply_to_status_id => in_reply_to_status_id) }
34
34
  end
35
35
  end
@@ -79,7 +79,7 @@ module Earthquake
79
79
  x
80
80
  end
81
81
  }
82
- s["highlights"] = words
82
+ s["_highlights"] = words
83
83
  }.reverse
84
84
  end
85
85
 
@@ -3,7 +3,9 @@ require 'fileutils'
3
3
 
4
4
  module Earthquake
5
5
  module Core
6
- attr_accessor :config
6
+ def config
7
+ @config ||= {}
8
+ end
7
9
 
8
10
  def item_queue
9
11
  @item_queue ||= []
@@ -46,12 +48,12 @@ module Earthquake
46
48
 
47
49
  def load_config
48
50
  # TODO: parse argv
49
- self.config = {
51
+ config.merge!(
50
52
  :dir => File.expand_path('~/.earthquake'),
51
53
  :plugin_dir => File.expand_path('~/.earthquake/plugin'),
52
54
  :consumer_key => 'RmzuwQ5g0SYObMfebIKJag',
53
55
  :consumer_secret => 'V98dYYmWm9JoG7qfOF0jhJaVEVW3QhGYcDJ9JQSXU'
54
- }
56
+ )
55
57
 
56
58
  [config[:dir], config[:plugin_dir]].each do |dir|
57
59
  unless File.exists?(dir)
@@ -51,6 +51,7 @@ module Earthquake
51
51
  end
52
52
 
53
53
  def confirm(message, type = :y)
54
+ message = message.c(36)
54
55
  case type
55
56
  when :y
56
57
  print "#{message} [Yn] "
@@ -66,9 +67,10 @@ module Earthquake
66
67
 
67
68
  init do
68
69
  commands.clear
70
+ command_names.clear
69
71
  completions.clear
70
72
 
71
- Readline.basic_word_break_characters = " \t\n\"\\'`$><=;|&{("
73
+ Readline.basic_word_break_characters = " \t\n\"\\'`$><=;|&{(@"
72
74
 
73
75
  Readline.completion_proc = lambda do |text|
74
76
  completions.inject([]) do |results, completion|
@@ -20,7 +20,7 @@ module Earthquake
20
20
  return if item_queue.empty?
21
21
  insert do
22
22
  while item = item_queue.shift
23
- item["stream"] = true
23
+ item["_stream"] = true
24
24
  puts_items(item)
25
25
  end
26
26
  end
@@ -79,7 +79,7 @@ module Earthquake
79
79
  end
80
80
 
81
81
  statuses = ["[#{item["id"].to_s}]"]
82
- unless item["stream"]
82
+ unless item["_stream"]
83
83
  statuses.insert(0, "[#{Time.parse(item["created_at"]).strftime('%Y.%m.%d %X')}]")
84
84
  end
85
85
 
@@ -89,8 +89,8 @@ module Earthquake
89
89
  i.c(color_of($1))
90
90
  end
91
91
 
92
- if item["highlights"]
93
- item["highlights"].each do |h|
92
+ if item["_highlights"]
93
+ item["_highlights"].each do |h|
94
94
  c = color_of(h).to_i + 10
95
95
  text = text.gsub(/#{h}/i) do |i|
96
96
  i.c(c)
@@ -114,11 +114,11 @@ module Earthquake
114
114
 
115
115
  case item["event"]
116
116
  when "follow", "block", "unblock"
117
- puts "[#{item["event"]}] #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
117
+ puts "[#{item["event"]}]".c(42) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]}"
118
118
  when "favorite", "unfavorite"
119
- puts "[#{item["event"]}] #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]} : #{item["target_object"]["text"]}"
119
+ puts "[#{item["event"]}]".c(42) + " #{item["source"]["screen_name"]} => #{item["target"]["screen_name"]} : #{item["target_object"]["text"].u}"
120
120
  when "delete"
121
- puts "[deleted] #{item["delete"]["status"]["id"]}"
121
+ puts "[deleted]".c(42) + " #{item["delete"]["status"]["id"]}"
122
122
  else
123
123
  if config[:debug]
124
124
  ap item
@@ -9,7 +9,9 @@ module Earthquake
9
9
 
10
10
  filter do |item|
11
11
  next if item["text"].nil? || item["disable_cache"]
12
- Earthquake.cache.write("status:#{item["id"]}", item.dup, :expires_in => 1.hour.ago)
12
+ item = item.dup
13
+ item.keys.select { |key| key =~ /^_/ }.each { |key| item.delete(key) } # remote optional data like "_stream", "_highlights"
14
+ Earthquake.cache.write("status:#{item["id"]}", item)
13
15
  end
14
16
  end
15
17
 
@@ -22,7 +24,7 @@ module Earthquake
22
24
  result.dup
23
25
  else
24
26
  result = __send__(:"#{m}_without_cache", *args)
25
- Earthquake.cache.write(key, result.dup, :expires_in => 1.hour.ago)
27
+ Earthquake.cache.write(key, result.dup)
26
28
  result
27
29
  end
28
30
  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.6
5
+ version: 0.4.7
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-03-21 00:00:00 +09:00
13
+ date: 2011-03-26 00:00:00 +09:00
14
14
  default_executable: earthquake
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -102,7 +102,7 @@ dependencies:
102
102
  prerelease: false
103
103
  version_requirements: *id008
104
104
  - !ruby/object:Gem::Dependency
105
- name: termcolor
105
+ name: ruby-growl
106
106
  requirement: &id009 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
@@ -194,10 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - ">="
196
196
  - !ruby/object:Gem::Version
197
- hash: -4509587911112698358
198
- segments:
199
- - 0
200
- version: "0"
197
+ version: 1.9.1
201
198
  required_rubygems_version: !ruby/object:Gem::Requirement
202
199
  none: false
203
200
  requirements: