sup 0.9.1 → 0.10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sup might be problematic. Click here for more details.
- data/CONTRIBUTORS +10 -6
- data/History.txt +11 -0
- data/ReleaseNotes +10 -0
- data/bin/sup +55 -19
- data/bin/sup-add +18 -8
- data/bin/sup-config +2 -2
- data/bin/sup-convert-ferret-index +84 -0
- data/bin/sup-dump +4 -3
- data/bin/sup-sync +4 -3
- data/bin/sup-sync-back +3 -2
- data/bin/sup-tweak-labels +3 -3
- data/lib/sup.rb +35 -4
- data/lib/sup/buffer.rb +12 -6
- data/lib/sup/colormap.rb +1 -0
- data/lib/sup/crypto.rb +76 -55
- data/lib/sup/ferret_index.rb +6 -1
- data/lib/sup/index.rb +62 -8
- data/lib/sup/logger.rb +2 -1
- data/lib/sup/maildir.rb +4 -2
- data/lib/sup/mbox/loader.rb +4 -3
- data/lib/sup/message-chunks.rb +9 -7
- data/lib/sup/message.rb +29 -27
- data/lib/sup/mode.rb +11 -4
- data/lib/sup/modes/buffer-list-mode.rb +5 -0
- data/lib/sup/modes/console-mode.rb +4 -0
- data/lib/sup/modes/edit-message-mode.rb +4 -2
- data/lib/sup/modes/file-browser-mode.rb +1 -1
- data/lib/sup/modes/inbox-mode.rb +18 -1
- data/lib/sup/modes/label-list-mode.rb +44 -3
- data/lib/sup/modes/text-mode.rb +1 -1
- data/lib/sup/modes/thread-index-mode.rb +63 -52
- data/lib/sup/modes/thread-view-mode.rb +68 -7
- data/lib/sup/poll.rb +20 -5
- data/lib/sup/source.rb +1 -0
- data/lib/sup/thread.rb +1 -1
- data/lib/sup/util.rb +49 -11
- data/lib/sup/xapian_index.rb +151 -112
- metadata +4 -10
- data/lib/sup/hook.rb.BACKUP.8625.rb +0 -158
- data/lib/sup/hook.rb.BACKUP.8681.rb +0 -158
- data/lib/sup/hook.rb.BASE.8625.rb +0 -155
- data/lib/sup/hook.rb.BASE.8681.rb +0 -155
- data/lib/sup/hook.rb.LOCAL.8625.rb +0 -142
- data/lib/sup/hook.rb.LOCAL.8681.rb +0 -142
- data/lib/sup/hook.rb.REMOTE.8625.rb +0 -145
- data/lib/sup/hook.rb.REMOTE.8681.rb +0 -145
@@ -1,145 +0,0 @@
|
|
1
|
-
module Redwood
|
2
|
-
|
3
|
-
class HookManager
|
4
|
-
class HookContext
|
5
|
-
def initialize name
|
6
|
-
@__say_id = nil
|
7
|
-
@__name = name
|
8
|
-
@__locals = {}
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_writer :__locals
|
12
|
-
def method_missing m, *a
|
13
|
-
case @__locals[m]
|
14
|
-
when Proc
|
15
|
-
@__locals[m] = @__locals[m].call(*a) # only call the proc once
|
16
|
-
when nil
|
17
|
-
super
|
18
|
-
else
|
19
|
-
@__locals[m]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def say s
|
24
|
-
if BufferManager.instantiated?
|
25
|
-
@__say_id = BufferManager.say s, @__say_id
|
26
|
-
BufferManager.draw_screen
|
27
|
-
else
|
28
|
-
log s
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def log s
|
33
|
-
Redwood::log "hook[#@__name]: #{s}"
|
34
|
-
end
|
35
|
-
|
36
|
-
def ask_yes_or_no q
|
37
|
-
if BufferManager.instantiated?
|
38
|
-
BufferManager.ask_yes_or_no q
|
39
|
-
else
|
40
|
-
print q
|
41
|
-
gets.chomp.downcase == 'y'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def get tag
|
46
|
-
HookManager.tags[tag]
|
47
|
-
end
|
48
|
-
|
49
|
-
def set tag, value
|
50
|
-
HookManager.tags[tag] = value
|
51
|
-
end
|
52
|
-
|
53
|
-
def __binding
|
54
|
-
binding
|
55
|
-
end
|
56
|
-
|
57
|
-
def __cleanup
|
58
|
-
BufferManager.clear @__say_id if @__say_id
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
include Singleton
|
63
|
-
|
64
|
-
def initialize dir
|
65
|
-
@dir = dir
|
66
|
-
@hooks = {}
|
67
|
-
@descs = {}
|
68
|
-
@contexts = {}
|
69
|
-
@tags = {}
|
70
|
-
|
71
|
-
Dir.mkdir dir unless File.exists? dir
|
72
|
-
|
73
|
-
self.class.i_am_the_instance self
|
74
|
-
end
|
75
|
-
|
76
|
-
attr_reader :tags
|
77
|
-
|
78
|
-
def run name, locals={}
|
79
|
-
hook = hook_for(name) or return
|
80
|
-
context = @contexts[hook] ||= HookContext.new(name)
|
81
|
-
context.__locals = locals
|
82
|
-
|
83
|
-
result = nil
|
84
|
-
begin
|
85
|
-
result = context.instance_eval @hooks[name], fn_for(name)
|
86
|
-
rescue Exception => e
|
87
|
-
log "error running hook: #{e.message}"
|
88
|
-
log e.backtrace.join("\n")
|
89
|
-
@hooks[name] = nil # disable it
|
90
|
-
BufferManager.flash "Error running hook: #{e.message}" if BufferManager.instantiated?
|
91
|
-
end
|
92
|
-
context.__cleanup
|
93
|
-
result
|
94
|
-
end
|
95
|
-
|
96
|
-
def register name, desc
|
97
|
-
@descs[name] = desc
|
98
|
-
end
|
99
|
-
|
100
|
-
def print_hooks f=$stdout
|
101
|
-
puts <<EOS
|
102
|
-
Have #{@descs.size} registered hooks:
|
103
|
-
|
104
|
-
EOS
|
105
|
-
|
106
|
-
@descs.sort.each do |name, desc|
|
107
|
-
f.puts <<EOS
|
108
|
-
#{name}
|
109
|
-
#{"-" * name.length}
|
110
|
-
File: #{fn_for name}
|
111
|
-
#{desc}
|
112
|
-
EOS
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def enabled? name; !hook_for(name).nil? end
|
117
|
-
|
118
|
-
private
|
119
|
-
|
120
|
-
def hook_for name
|
121
|
-
unless @hooks.member? name
|
122
|
-
@hooks[name] =
|
123
|
-
begin
|
124
|
-
returning IO.read(fn_for(name)) do
|
125
|
-
log "read '#{name}' from #{fn_for(name)}"
|
126
|
-
end
|
127
|
-
rescue SystemCallError => e
|
128
|
-
#log "disabled hook for '#{name}': #{e.message}"
|
129
|
-
nil
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
@hooks[name]
|
134
|
-
end
|
135
|
-
|
136
|
-
def fn_for name
|
137
|
-
File.join @dir, "#{name}.rb"
|
138
|
-
end
|
139
|
-
|
140
|
-
def log m
|
141
|
-
Redwood::log("hook: " + m)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|