jugyo-termtter 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require 'set'
2
2
 
3
- class Termtter::Client
3
+ module Termtter::Client
4
4
 
5
5
  public_storage[:users] ||= Set.new
6
6
 
@@ -25,24 +25,23 @@ module Termtter
25
25
 
26
26
  Commands = %w[exit help list pause update resume replies search show uri-open]
27
27
 
28
+ def self.find_candidates(a, b)
29
+ if a.empty?
30
+ Termtter::Client.public_storage[:users].to_a
31
+ else
32
+ Termtter::Client.public_storage[:users].
33
+ grep(/^#{Regexp.quote a}/i).map {|u| b % u }
34
+ end
35
+ end
36
+
28
37
  CompletionProc = proc {|input|
29
38
  case input
30
39
  when /^l(ist)? +(.*)/
31
- username = $2
32
- if username.empty?
33
- Termtter::Client.public_storage[:users].to_a
34
- else
35
- Termtter::Client.public_storage[:users].to_a.
36
- grep(/^#{Regexp.quote username}/).map{|u| "list #{u}"}
37
- end
40
+ find_candidates $2, "list %s"
41
+ when /^(update|u)\s+(.*)@([^\s]*)$/
42
+ find_candidates $3, "#{$1} #{$2}@%s"
38
43
  when /^uri-open +(.*)/
39
- uri_open_com = $1
40
- if uri_open_com.empty?
41
- %w[clear list]
42
- else
43
- %w[clear list].
44
- grep(/^#{Regexp.quote uri_open_com}/).map{|c| "uri-open #{c}"}
45
- end
44
+ find_candidates $1, "uri-open %s"
46
45
  else
47
46
  Commands.grep(/^#{Regexp.quote input}/)
48
47
  end
data/lib/termtter/say.rb CHANGED
@@ -7,7 +7,7 @@ def say(who, what)
7
7
  system 'say', '-v', voice, what
8
8
  end
9
9
 
10
- class Termtter::Client
10
+ module Termtter::Client
11
11
  add_hook do |statuses, event, t|
12
12
  if !statuses.empty? && event == :update_friends_timeline
13
13
  statuses.reverse.each do |s|
@@ -1,4 +1,4 @@
1
- class Termtter::Client
1
+ module Termtter::Client
2
2
 
3
3
  add_command /^(update|u)\s+(.*)/ do |m, t|
4
4
  text = m[2]
@@ -1,4 +1,4 @@
1
- class Termtter::Client
1
+ module Termtter::Client
2
2
  public_storage[:uris] = []
3
3
 
4
4
  add_hook do |statuses, event, t|
data/lib/termtter.rb CHANGED
@@ -5,12 +5,15 @@ require 'cgi'
5
5
  require 'readline'
6
6
  require 'enumerator'
7
7
  require 'parsedate'
8
+ require 'configatron'
8
9
 
9
10
  $:.unshift(File.dirname(__FILE__)) unless
10
11
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
11
12
 
13
+ configatron.set_default(:update_interval, 300)
14
+
12
15
  module Termtter
13
- VERSION = '0.5.2'
16
+ VERSION = '0.5.3'
14
17
 
15
18
  class Twitter
16
19
 
@@ -82,7 +85,7 @@ module Termtter
82
85
  end
83
86
  end
84
87
 
85
- class Client
88
+ module Client
86
89
 
87
90
  @@hooks = []
88
91
  @@commands = {}
@@ -144,19 +147,19 @@ module Termtter
144
147
 
145
148
  def self.resume
146
149
  @@pause = false
147
- @@update.run
150
+ @@update_thread.run
148
151
  end
149
152
 
150
153
  def self.exit
151
- @@update.kill
152
- @@input.kill
154
+ @@update_thread.kill
155
+ @@input_thread.kill
153
156
  end
154
157
 
155
158
  def self.run
156
159
  @@pause = false
157
160
  tw = Termtter::Twitter.new(configatron.user_name, configatron.password)
158
161
 
159
- @@update = Thread.new do
162
+ @@update_thread = Thread.new do
160
163
  since_id = nil
161
164
  loop do
162
165
  begin
@@ -177,7 +180,7 @@ module Termtter
177
180
  end
178
181
  end
179
182
 
180
- @@input = Thread.new do
183
+ @@input_thread = Thread.new do
181
184
  while buf = Readline.readline("", true)
182
185
  begin
183
186
  call_commands(buf, tw)
@@ -194,7 +197,7 @@ module Termtter
194
197
  stty_save = `stty -g`.chomp
195
198
  trap("INT") { system "stty", stty_save; exit }
196
199
 
197
- @@input.join
200
+ @@input_thread.join
198
201
  end
199
202
 
200
203
  end
data/run_termtter.rb CHANGED
@@ -13,7 +13,8 @@ $:.unshift(File.dirname(self_file) + "/lib")
13
13
  require 'termtter'
14
14
  require 'termtter/standard_commands'
15
15
  require 'termtter/stdout'
16
- require 'configatron'
16
+
17
+ configatron.update_interval
17
18
 
18
19
  conf_file = File.expand_path('~/.termtter')
19
20
  if File.exist? conf_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-termtter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-05 00:00:00 -08:00
12
+ date: 2009-01-06 00:00:00 -08:00
13
13
  default_executable: termtter
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency