earthquake 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -98,6 +98,10 @@ Commands
98
98
 
99
99
  ⚡ :plugin_install https://gist.github.com/899506
100
100
 
101
+ ### Alias
102
+
103
+ ⚡ :alias rt retweet
104
+
101
105
  And there are more commands!
102
106
 
103
107
  Configuration
@@ -130,6 +134,11 @@ Blue is excluded.
130
134
  :url => [4, 34]
131
135
  }
132
136
 
137
+ ### Defining aliases
138
+
139
+ # ~/.earthquake/config
140
+ Earthquake.alias_command :rt, :retweet
141
+
133
142
  ### HTTP proxy support
134
143
 
135
144
  Please set environment variable *http_proxy* if you want earthquake to use http proxy.
@@ -249,7 +258,6 @@ The 'm' is a MatchData.
249
258
  TODO
250
259
  ----
251
260
 
252
- * alias
253
261
  * mark my tweet
254
262
  * Earthquake should parse ARGV
255
263
  * ruby1.9nize
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -5,26 +5,37 @@ argv = ARGV.dup
5
5
  opts = Slop.parse! argv, :help => true do
6
6
  banner "Usage: earthquake [options] [directory]"
7
7
  on :d, :debug, 'Enable debug mode'
8
+ on :n, :'no-logo', 'No Logo'
9
+ on :c, :command, "Invoke an command and exit", true
8
10
  end
9
11
  options = opts.to_hash(true)
10
12
  options.delete(:help)
11
13
  options[:dir] = argv.shift unless argv.empty?
12
14
 
13
15
  require 'pathname'
14
- eq_dir = Pathname.new(File.expand_path('../..', __FILE__)).realpath
16
+ eq_dir = Pathname.new(__FILE__).realpath.parent.parent
15
17
 
16
18
  $:.unshift eq_dir.join('lib') if $0 == __FILE__
17
19
 
18
- print "\e[31m"
19
- puts %q{
20
+ command = options.delete(:command)
21
+ no_logo = options.delete(:'no-logo')
22
+
23
+ if !no_logo && !command
24
+ print "\e[31m"
25
+ puts %q{
20
26
  _ _ _
21
27
  ___ __ _ _ __| |_| |__ __ _ _ _ __ _| | _____
22
28
  / _ \/ _` | '__| __| '_ \ / _` | | | |/ _` | |/ / _ \
23
29
  | __/ (_| | | | |_| | | | (_| | |_| | (_| | < __/
24
30
  \___|\__,_|_| \__|_| |_|\__, |\__,_|\__,_|_|\_\___|
25
31
  |_| }.
26
- gsub(/^\n/, '') + "v#{eq_dir.join('VERSION').read}".rjust(10) + "\n\n"
27
- print "\e[0m"
32
+ gsub(/^\n/, '') + "v#{eq_dir.join('VERSION').read}".rjust(10) + "\n\n"
33
+ print "\e[0m"
34
+ end
28
35
 
29
36
  require 'earthquake'
30
- Earthquake.start(options)
37
+ if command
38
+ Earthquake.invoke(command, options)
39
+ else
40
+ Earthquake.start(options)
41
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{earthquake}
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
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-26}
12
+ s.date = %q{2011-06-15}
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}
@@ -13,7 +13,8 @@ Earthquake.init do
13
13
  command :restart do
14
14
  puts 'restarting...'
15
15
  stop
16
- exec File.expand_path('../../../bin/earthquake', __FILE__), *ARGV
16
+ args = ARGV.push '-n' unless ARGV.include?('-n')
17
+ exec File.expand_path('../../../bin/earthquake', __FILE__), *args
17
18
  end
18
19
 
19
20
  command :eval do |m|
@@ -88,7 +89,8 @@ Earthquake.init do
88
89
  end
89
90
 
90
91
  command :search do |m|
91
- puts_items twitter.search(m[1], config[:search_options] || {})["results"].each { |s|
92
+ search_options = config[:search_options] ? config[:search_options].dup : {}
93
+ puts_items twitter.search(m[1], search_options)["results"].each { |s|
92
94
  s["user"] = {"screen_name" => s["from_user"]}
93
95
  s["_disable_cache"] = true
94
96
  words = m[1].split(/\s+/).reject{|x| x[0] =~ /^-|^(OR|AND)$/ }.map{|x|
@@ -84,10 +84,19 @@ module Earthquake
84
84
  end
85
85
  end
86
86
 
87
- def start(options = {})
87
+ def __init(options)
88
88
  config.merge!(options)
89
89
  _init
90
90
  _once
91
+ end
92
+
93
+ def invoke(command, options = {})
94
+ __init(options)
95
+ input(command)
96
+ end
97
+
98
+ def start(options = {})
99
+ __init(options)
91
100
  restore_history
92
101
 
93
102
  EventMachine::run do
@@ -33,7 +33,6 @@ module Earthquake
33
33
 
34
34
  def alias_command(name, target)
35
35
  command_aliases[name.to_s] = target.to_s
36
- command_names << ":#{name}"
37
36
  end
38
37
 
39
38
  def input(text)
@@ -116,7 +115,7 @@ module Earthquake
116
115
 
117
116
  completion do |text|
118
117
  regexp = /^#{Regexp.quote(text)}/
119
- results = command_names.grep(regexp)
118
+ results = (command_names + command_aliases.keys.map {|i| ":#{i}"}).grep(regexp)
120
119
  history = Readline::HISTORY.reverse_each.take(config[:history_size]) | @tweets_for_completion
121
120
  history.inject(results){|r, line|
122
121
  r | line.split.grep(regexp)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earthquake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.1
5
+ version: 0.7.2
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-26 00:00:00 +09:00
13
+ date: 2011-06-15 00:00:00 +09:00
14
14
  default_executable: earthquake
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency