jugyo-termtter 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -0
- data/example_dot_termtter +1 -0
- data/lib/termtter/completion.rb +59 -0
- data/lib/termtter.rb +1 -1
- metadata +2 -1
data/Manifest.txt
CHANGED
data/example_dot_termtter
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
class Termtter::Client
|
|
4
|
+
|
|
5
|
+
public_storage[:users] ||= Set.new
|
|
6
|
+
|
|
7
|
+
add_hook do |statuses, event, t|
|
|
8
|
+
if !statuses.empty?
|
|
9
|
+
case event
|
|
10
|
+
when :update_friends_timeline, :replies, :list_user_timeline
|
|
11
|
+
statuses.each do |s|
|
|
12
|
+
public_storage[:users].add(s.user_screen_name)
|
|
13
|
+
s.text.scan(/@[a-zA-Z_0-9]*/).each do |u| # reply
|
|
14
|
+
public_storage[:users].add(u.gsub("@","")) unless u == "@"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module Termtter
|
|
24
|
+
module InputCompletor
|
|
25
|
+
|
|
26
|
+
Commands = %w[exit help list pause update resume replies search show uri-open]
|
|
27
|
+
|
|
28
|
+
CompletionProc = proc {|input|
|
|
29
|
+
case input
|
|
30
|
+
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
|
|
38
|
+
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
|
|
46
|
+
else
|
|
47
|
+
Commands.grep(/^#{Regexp.quote input}/)
|
|
48
|
+
end
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Readline.basic_word_break_characters= "\t\n\"\\'`><=;|&{("
|
|
55
|
+
Readline.completion_proc = Termtter::InputCompletor::CompletionProc
|
|
56
|
+
|
|
57
|
+
# author: bubbles
|
|
58
|
+
#
|
|
59
|
+
# see also: http://d.hatena.ne.jp/bubbles/20090105/1231145823
|
data/lib/termtter.rb
CHANGED
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.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jugyo
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- lib/termtter/growl.rb
|
|
69
69
|
- lib/termtter/say.rb
|
|
70
70
|
- lib/termtter/english.rb
|
|
71
|
+
- lib/termtter/completion.rb
|
|
71
72
|
- test/test_termtter.rb
|
|
72
73
|
- test/friends_timeline.json
|
|
73
74
|
- test/search.json
|