jugyo-termtter 0.5.6 → 0.5.7
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 -1
- data/bin/termtter +2 -2
- data/lib/plugin/{standard_commands.rb → standard_plugins.rb} +49 -0
- data/lib/plugin/uri-open.rb +29 -7
- data/lib/termtter.rb +19 -1
- data/run_termtter.rb +1 -1
- metadata +2 -2
data/Manifest.txt
CHANGED
data/bin/termtter
CHANGED
|
@@ -5,7 +5,7 @@ $KCODE = 'u'
|
|
|
5
5
|
require 'rubygems'
|
|
6
6
|
require 'termtter'
|
|
7
7
|
require 'configatron'
|
|
8
|
-
plugin '
|
|
8
|
+
plugin 'standard_plugins'
|
|
9
9
|
plugin 'stdout'
|
|
10
10
|
|
|
11
11
|
conf_file = File.expand_path('~/.termtter')
|
|
@@ -20,7 +20,7 @@ else
|
|
|
20
20
|
plugins = Dir.glob(File.dirname(__FILE__) + "/../lib/plugin/*.rb").map {|f|
|
|
21
21
|
f.match(%r|lib/plugin/(.*?).rb$|)[1]
|
|
22
22
|
}
|
|
23
|
-
plugins -= %w[stdout
|
|
23
|
+
plugins -= %w[stdout standard_plugins]
|
|
24
24
|
plugins.each do |p|
|
|
25
25
|
io.puts "#plugin '#{p}'"
|
|
26
26
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module Termtter::Client
|
|
2
2
|
|
|
3
|
+
# standard commands
|
|
4
|
+
|
|
3
5
|
add_command /^(update|u)\s+(.*)/ do |m, t|
|
|
4
6
|
text = m[2]
|
|
5
7
|
unless text.empty?
|
|
@@ -66,4 +68,51 @@ show ID Show a single status
|
|
|
66
68
|
end
|
|
67
69
|
end
|
|
68
70
|
|
|
71
|
+
# completion for standard commands
|
|
72
|
+
|
|
73
|
+
require 'set'
|
|
74
|
+
public_storage[:users] ||= Set.new
|
|
75
|
+
public_storage[:status_ids] ||= Set.new
|
|
76
|
+
|
|
77
|
+
add_hook do |statuses, event, t|
|
|
78
|
+
statuses.each do |s|
|
|
79
|
+
public_storage[:users].add(s.user_screen_name)
|
|
80
|
+
public_storage[:users] += s.text.scan(/@([a-zA-Z_0-9]*)/).flatten
|
|
81
|
+
public_storage[:status_ids].add(s.id.to_s)
|
|
82
|
+
public_storage[:status_ids].add(s.in_reply_to_status_id.to_s) if s.in_reply_to_status_id
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def self.find_status_id_candidates(a, b)
|
|
87
|
+
if a.empty?
|
|
88
|
+
public_storage[:status_ids].to_a
|
|
89
|
+
else
|
|
90
|
+
public_storage[:status_ids].grep(/#{Regexp.quote a}/)
|
|
91
|
+
end.
|
|
92
|
+
map {|u| b % u }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def self.find_user_candidates(a, b)
|
|
96
|
+
if a.empty?
|
|
97
|
+
public_storage[:users].to_a
|
|
98
|
+
else
|
|
99
|
+
public_storage[:users].grep(/^#{Regexp.quote a}/i)
|
|
100
|
+
end.
|
|
101
|
+
map {|u| b % u }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
add_completion do |input|
|
|
105
|
+
standard_commands = %w[exit help list pause update resume replies search show]
|
|
106
|
+
case input
|
|
107
|
+
when /^(list|l)?\s+(.*)/
|
|
108
|
+
find_user_candidates $2, "#{$1} %s"
|
|
109
|
+
when /^(update|u)\s+(.*)@([^\s]*)$/
|
|
110
|
+
find_user_candidates $3, "#{$1} #{$2}@%s"
|
|
111
|
+
when /^show\s+(.*)/
|
|
112
|
+
find_status_id_candidates $1, "show %s"
|
|
113
|
+
else
|
|
114
|
+
standard_commands.grep(/^#{Regexp.quote input}/)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
69
118
|
end
|
data/lib/plugin/uri-open.rb
CHANGED
|
@@ -9,26 +9,48 @@ module Termtter::Client
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def self.open_uri(uri)
|
|
13
|
+
# FIXME: works only in OSX and other *NIXs
|
|
14
|
+
if /linux/ =~ RUBY_PLATFORM
|
|
15
|
+
system 'firefox', uri
|
|
16
|
+
else
|
|
17
|
+
system 'open', uri
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
12
21
|
add_command /^uri-open\s*$/ do |m, t|
|
|
13
22
|
public_storage[:uris].each do |uri|
|
|
14
|
-
|
|
15
|
-
if /linux/ =~ RUBY_PLATFORM
|
|
16
|
-
system 'firefox', uri
|
|
17
|
-
else
|
|
18
|
-
system 'open', uri
|
|
19
|
-
end
|
|
23
|
+
open_uri(uri)
|
|
20
24
|
end
|
|
21
25
|
public_storage[:uris].clear
|
|
22
26
|
end
|
|
23
27
|
|
|
28
|
+
add_command /^uri-open\s+(\d+)$/ do |m, t|
|
|
29
|
+
if m[1]
|
|
30
|
+
index = m[1].to_i
|
|
31
|
+
open_uri(public_storage[:uris][index])
|
|
32
|
+
public_storage[:uris].delete_at(index)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
24
36
|
add_command /^uri-open\s+list\s*$/ do |m, t|
|
|
25
|
-
|
|
37
|
+
public_storage[:uris].each_with_index do |uri, index|
|
|
38
|
+
puts "#{index}: #{uri}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
add_command /^uri-open\s+delete\s+(\d+)$/ do |m, t|
|
|
43
|
+
public_storage[:uris].delete_at(m[1].to_i) if m[1]
|
|
26
44
|
end
|
|
27
45
|
|
|
28
46
|
add_command /^uri-open\s+clear\s*$/ do |m, t|
|
|
29
47
|
public_storage[:uris].clear
|
|
30
48
|
puts "clear uris"
|
|
31
49
|
end
|
|
50
|
+
|
|
51
|
+
add_completion do |input|
|
|
52
|
+
['uri-open ', 'uri-open list', 'uri-open delete', 'uri-open clear'].grep(/^#{Regexp.quote input}/)
|
|
53
|
+
end
|
|
32
54
|
end
|
|
33
55
|
# ~/.termtter
|
|
34
56
|
# plugin 'uri-open'
|
data/lib/termtter.rb
CHANGED
|
@@ -28,7 +28,7 @@ def require(s)
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
module Termtter
|
|
31
|
-
VERSION = '0.5.
|
|
31
|
+
VERSION = '0.5.7'
|
|
32
32
|
|
|
33
33
|
class Twitter
|
|
34
34
|
|
|
@@ -99,6 +99,7 @@ module Termtter
|
|
|
99
99
|
|
|
100
100
|
@@hooks = []
|
|
101
101
|
@@commands = {}
|
|
102
|
+
@@completions = []
|
|
102
103
|
|
|
103
104
|
class << self
|
|
104
105
|
def add_hook(&hook)
|
|
@@ -117,6 +118,21 @@ module Termtter
|
|
|
117
118
|
@@commands.clear
|
|
118
119
|
end
|
|
119
120
|
|
|
121
|
+
def add_completion(&completion)
|
|
122
|
+
@@completions << completion
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def clear_completions
|
|
126
|
+
@@completions.clear
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
Readline.basic_word_break_characters= "\t\n\"\\'`><=;|&{("
|
|
130
|
+
Readline.completion_proc = proc {|input|
|
|
131
|
+
@@completions.map {|completion|
|
|
132
|
+
completion.call(input)
|
|
133
|
+
}.flatten.compact
|
|
134
|
+
}
|
|
135
|
+
|
|
120
136
|
def public_storage
|
|
121
137
|
@@public_storage ||= {}
|
|
122
138
|
return @@public_storage
|
|
@@ -210,7 +226,9 @@ module Termtter
|
|
|
210
226
|
|
|
211
227
|
@@input_thread.join
|
|
212
228
|
end
|
|
229
|
+
|
|
213
230
|
end
|
|
231
|
+
|
|
214
232
|
end
|
|
215
233
|
|
|
216
234
|
class CommandNotFound < StandardError; end
|
data/run_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.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jugyo
|
|
@@ -64,7 +64,7 @@ files:
|
|
|
64
64
|
- lib/termtter.rb
|
|
65
65
|
- lib/plugin/stdout.rb
|
|
66
66
|
- lib/plugin/notify-send.rb
|
|
67
|
-
- lib/plugin/
|
|
67
|
+
- lib/plugin/standard_plugins.rb
|
|
68
68
|
- lib/plugin/uri-open.rb
|
|
69
69
|
- lib/plugin/growl.rb
|
|
70
70
|
- lib/plugin/say.rb
|