ratchet 0.3.0
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/gem_bin/ratchet +23 -0
- data/lib/ratchet.rb +613 -0
- data/lib/ratchet/aliases.rb +106 -0
- data/lib/ratchet/bufferparser.rb +409 -0
- data/lib/ratchet/commandbuffer.rb +66 -0
- data/lib/ratchet/commandparser.rb +668 -0
- data/lib/ratchet/configuration.rb +278 -0
- data/lib/ratchet/connections.rb +403 -0
- data/lib/ratchet/constants.rb +111 -0
- data/lib/ratchet/contrib/instance_exec.rb +21 -0
- data/lib/ratchet/eventparser.rb +486 -0
- data/lib/ratchet/gtk/bufferlistview.rb +514 -0
- data/lib/ratchet/gtk/bufferview.rb +167 -0
- data/lib/ratchet/gtk/configwindow.rb +229 -0
- data/lib/ratchet/gtk/connectionwindow.rb +218 -0
- data/lib/ratchet/gtk/keybinding.rb +356 -0
- data/lib/ratchet/gtk/linkwindow.rb +137 -0
- data/lib/ratchet/gtk/mainwindow.rb +504 -0
- data/lib/ratchet/gtk/networkpresenceconf.rb +567 -0
- data/lib/ratchet/gtk/pluginconfig.rb +94 -0
- data/lib/ratchet/gtk/pluginwindow.rb +146 -0
- data/lib/ratchet/gtk/userlistview.rb +161 -0
- data/lib/ratchet/help.rb +64 -0
- data/lib/ratchet/items.rb +271 -0
- data/lib/ratchet/lines.rb +63 -0
- data/lib/ratchet/networks.rb +652 -0
- data/lib/ratchet/plugins.rb +616 -0
- data/lib/ratchet/queue.rb +47 -0
- data/lib/ratchet/ratchet-version.rb +21 -0
- data/lib/ratchet/replies.rb +134 -0
- data/lib/ratchet/replyparser.rb +441 -0
- data/lib/ratchet/tabcomplete.rb +98 -0
- data/lib/ratchet/users.rb +237 -0
- data/lib/ratchet/utils.rb +178 -0
- data/share/defaults.yaml +169 -0
- data/share/glade/config.glade +2634 -0
- data/share/glade/connect.glade +950 -0
- data/share/glade/keybindings.glade +109 -0
- data/share/glade/linkwindow.glade +188 -0
- data/share/glade/mainwindow.glade +335 -0
- data/share/glade/network-presences.glade +1373 -0
- data/share/glade/pluginconf.glade +97 -0
- data/share/glade/plugins.glade +360 -0
- data/share/plugins/colorewrite.rb +193 -0
- data/share/plugins/highlighter.rb +115 -0
- data/share/plugins/mpdplay.rb +123 -0
- data/share/plugins/numberswitcher.rb +30 -0
- data/share/plugins/sysinfo.rb +82 -0
- metadata +96 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### pluginconfig.rb ####
|
|
21
|
+
# The GTK specific part of the plugin config
|
|
22
|
+
####
|
|
23
|
+
|
|
24
|
+
module Ratchet
|
|
25
|
+
class PluginConfig
|
|
26
|
+
#the GTK specific chunk
|
|
27
|
+
def initialize(main, options)
|
|
28
|
+
@main = main
|
|
29
|
+
@config = @main.config
|
|
30
|
+
return if options.length == 0
|
|
31
|
+
@glade = GladeXML.new("#{DATADIR}/glade/pluginconf.glade") {|handler| method(handler)}
|
|
32
|
+
|
|
33
|
+
@tooltips = Gtk::Tooltips.new
|
|
34
|
+
|
|
35
|
+
@table = @glade['optiontable']
|
|
36
|
+
@table.resize(options.length, 2)
|
|
37
|
+
@table.border_width = 10
|
|
38
|
+
@table.column_spacings = 10
|
|
39
|
+
@table.row_spacings = 5
|
|
40
|
+
@configarray = {}
|
|
41
|
+
|
|
42
|
+
handle_options(options)
|
|
43
|
+
@window = @glade['confwindow']
|
|
44
|
+
@window.show_all
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def handle_options(options)
|
|
48
|
+
i = 0
|
|
49
|
+
options.each do |option|
|
|
50
|
+
if option['type'] and option['name'] and option['description']
|
|
51
|
+
#fill in defaults for unset values
|
|
52
|
+
option['tooltip'] ||= nil
|
|
53
|
+
option['value'] ||= nil
|
|
54
|
+
option['xopt'] ||= Gtk::SHRINK
|
|
55
|
+
option['yopt'] ||= Gtk::FILL
|
|
56
|
+
|
|
57
|
+
if option['type'] == Color
|
|
58
|
+
widget = Gtk::ColorButton.new
|
|
59
|
+
widget.color = Gdk::Color.new(*option['value']) if option['value']
|
|
60
|
+
widget.signal_connect('color_set') {|widget| color_changed(widget)}
|
|
61
|
+
elsif option['type'] == String
|
|
62
|
+
#I guess we need some trick to allow combo boxes too...
|
|
63
|
+
widget = Gtk::Entry.new
|
|
64
|
+
widget.text = option['value'] if option['value']
|
|
65
|
+
widget.signal_connect('changed') {|widget| text_changed(widget)}
|
|
66
|
+
elsif option['type'] == Integer
|
|
67
|
+
widget = Gtk::Entry.new
|
|
68
|
+
widget.text = option['value'].to_s if option['value']
|
|
69
|
+
widget.signal_connect('changed') {|widget| integer_changed(widget)}
|
|
70
|
+
elsif option['type'] == TrueClass
|
|
71
|
+
widget = Gtk::CheckButton.new#(option['description'])
|
|
72
|
+
widget.active = false
|
|
73
|
+
widget.active = true if option['value'] == true
|
|
74
|
+
widget.signal_connect('toggled') {|widget| bool_changed(widget)}
|
|
75
|
+
elsif option['type'] == Array
|
|
76
|
+
widget = Gtk::Entry.new
|
|
77
|
+
widget.text = option['value'].join(',') if option['value']
|
|
78
|
+
widget.signal_connect('changed') {|widget| array_changed(widget)}
|
|
79
|
+
else
|
|
80
|
+
puts 'unknown type '+option['type'].to_s
|
|
81
|
+
next
|
|
82
|
+
end
|
|
83
|
+
@tooltips.set_tip(widget, option['tooltip'], '') if option['tooltip']
|
|
84
|
+
@configarray[widget] = {'name' => option['name'], 'value' => option['value']}
|
|
85
|
+
@table.attach(Gtk::Label.new(option['description']), 0, 1, i, i+1, Gtk::SHRINK, Gtk::FILL)# unless option['type'] == TrueClass
|
|
86
|
+
@table.attach(widget, 1, 2, i, i+1, Gtk::SHRINK, Gtk::FILL)
|
|
87
|
+
i += 1
|
|
88
|
+
else
|
|
89
|
+
puts 'missing required options'
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### pluginwindow.rb
|
|
21
|
+
# The plugin manager window
|
|
22
|
+
####
|
|
23
|
+
|
|
24
|
+
module Ratchet
|
|
25
|
+
class PluginWindow < SingleWindow
|
|
26
|
+
def initialize(main)
|
|
27
|
+
@main = main
|
|
28
|
+
@config = @main.config
|
|
29
|
+
@glade = GladeXML.new("#{DATADIR}/glade/plugins.glade") {|handler| method(handler)}
|
|
30
|
+
@window = @glade['pluginwindow']
|
|
31
|
+
@pluginstore = Gtk::ListStore.new(String, String)
|
|
32
|
+
@pluginlist = @glade['pluginlist']
|
|
33
|
+
@pluginlist.model = @pluginstore
|
|
34
|
+
|
|
35
|
+
renderer = Gtk::CellRendererText.new
|
|
36
|
+
|
|
37
|
+
col = Gtk::TreeViewColumn.new("Plugin", renderer, :text => 0)
|
|
38
|
+
|
|
39
|
+
col.set_cell_data_func(renderer) do |col, renderer, model, iter|
|
|
40
|
+
if iter[1] == ''
|
|
41
|
+
renderer.background = "#FFC8CA"
|
|
42
|
+
else
|
|
43
|
+
renderer.background = "#C8FFCC"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@pluginlist.append_column(col)
|
|
48
|
+
col = Gtk::TreeViewColumn.new("Plugin", renderer, :text => 1)
|
|
49
|
+
@pluginlist.append_column(col)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#puts Dir.entries('plugins')
|
|
53
|
+
|
|
54
|
+
plugins = []
|
|
55
|
+
|
|
56
|
+
if File.directory?(File.join(DATADIR, 'plugins'))
|
|
57
|
+
plugins += Dir.entries(File.join(DATADIR, 'plugins'))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if File.directory?(File.join($ratchetfolder, 'plugins'))
|
|
61
|
+
plugins += Dir.entries(File.join($ratchetfolder, 'plugins'))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
plugins = plugins.uniq.select do |i|
|
|
65
|
+
name, ext = i.split('.')
|
|
66
|
+
if ext
|
|
67
|
+
ext.downcase == 'rb'
|
|
68
|
+
else
|
|
69
|
+
false
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
plugins.each do |plugin|
|
|
74
|
+
name, extension = plugin.split('.')
|
|
75
|
+
iter = @pluginstore.append
|
|
76
|
+
iter[0] = name
|
|
77
|
+
if Plugin[name]
|
|
78
|
+
puts name
|
|
79
|
+
iter[1] = '*'
|
|
80
|
+
else
|
|
81
|
+
iter[1] = ''
|
|
82
|
+
end
|
|
83
|
+
#puts iter[0], iter[1]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
@pluginlist.selection.signal_connect('changed') {|widget| update_buttons(widget)}
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def update_buttons(widget)
|
|
90
|
+
selection = widget.selected
|
|
91
|
+
if selection
|
|
92
|
+
if selection[1] == '*'
|
|
93
|
+
@glade['plugin_unload'].sensitive = true
|
|
94
|
+
@glade['plugin_load'].sensitive = false
|
|
95
|
+
@glade['plugin_options'].sensitive = Plugin[selection[0]].respond_to? :configure
|
|
96
|
+
else
|
|
97
|
+
@glade['plugin_load'].sensitive = true
|
|
98
|
+
@glade['plugin_unload'].sensitive = false
|
|
99
|
+
@glade['plugin_options'].sensitive = false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def get_selection
|
|
105
|
+
selection = @pluginlist.selection.selected
|
|
106
|
+
if selection
|
|
107
|
+
return selection
|
|
108
|
+
else
|
|
109
|
+
return nil
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def load_plugin
|
|
114
|
+
if selection = get_selection and selection[1] == ''
|
|
115
|
+
if @main.plugin_load(selection[0])
|
|
116
|
+
selection[1] = '*'
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
update_buttons(@pluginlist.selection)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def unload_plugin
|
|
123
|
+
if selection = get_selection and selection[1] == '*'
|
|
124
|
+
if plugin = Plugin[selection[0]]
|
|
125
|
+
if Plugin.unregister(plugin)
|
|
126
|
+
selection[1] = ''
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
update_buttons(@pluginlist.selection)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def config_plugin
|
|
134
|
+
if selection = get_selection and selection[1] == '*'
|
|
135
|
+
if plugin = Plugin[selection[0]]
|
|
136
|
+
PluginConfig.new(@main, plugin.configure)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def destroy
|
|
142
|
+
@glade['pluginwindow'].destroy
|
|
143
|
+
self.class.destroy
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### userlistview.rb ####
|
|
21
|
+
# The userlist, a view for a UserList object (see users.rb)
|
|
22
|
+
####
|
|
23
|
+
|
|
24
|
+
module Ratchet
|
|
25
|
+
class UserListView
|
|
26
|
+
attr_accessor :widget
|
|
27
|
+
def initialize(buffer)
|
|
28
|
+
@buffer = buffer
|
|
29
|
+
@widget = Gtk::VPaned.new
|
|
30
|
+
@box = Gtk::VBox.new
|
|
31
|
+
@title = Gtk::Label.new('')
|
|
32
|
+
@userview = Gtk::TreeView.new
|
|
33
|
+
@userview.set_headers_visible(false)
|
|
34
|
+
@userlist = Gtk::ListStore.new(String, String)
|
|
35
|
+
@renderer = Gtk::CellRendererText.new
|
|
36
|
+
@modecolumn = Gtk::TreeViewColumn.new("Mode", @renderer, :text=>0)
|
|
37
|
+
@usercolumn = Gtk::TreeViewColumn.new("Users", @renderer, :text=>1)
|
|
38
|
+
@userlist.clear
|
|
39
|
+
@box.pack_start(@title, false, false)
|
|
40
|
+
scrolledwindow = Gtk::ScrolledWindow.new
|
|
41
|
+
#frame = Gtk::Frame.new
|
|
42
|
+
scrolledwindow.shadow_type=Gtk::SHADOW_ETCHED_IN
|
|
43
|
+
scrolledwindow.add(@userview)
|
|
44
|
+
scrolledwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
|
45
|
+
@box.pack_start(scrolledwindow)
|
|
46
|
+
@widget.add1(@box)
|
|
47
|
+
@useriters = []
|
|
48
|
+
|
|
49
|
+
@userview.model = @userlist
|
|
50
|
+
@userview.append_column(@modecolumn)
|
|
51
|
+
@userview.append_column(@usercolumn)
|
|
52
|
+
@userview.set_search_column(1)
|
|
53
|
+
|
|
54
|
+
@userview.signal_connect('button_press_event'){|widget, event| userlist_on_click(widget, event)}
|
|
55
|
+
@userview.signal_connect('row_activated'){|widget, path, column| userlist_on_doubleclick(widget, path, column)}
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def userlist_on_click(widget, event)
|
|
60
|
+
if event.button == 3
|
|
61
|
+
path, column, x, y = widget.get_path_at_pos(event.x, event.y)
|
|
62
|
+
return unless path
|
|
63
|
+
widget.set_cursor(path, nil, false)
|
|
64
|
+
userlist_popup_menu(widget, event)
|
|
65
|
+
true
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def userlist_popup_menu(widget, event)
|
|
71
|
+
selection = widget.selection.selected
|
|
72
|
+
if selection
|
|
73
|
+
menu = create_user_popup(selection[1])
|
|
74
|
+
return unless menu
|
|
75
|
+
menu.show_all
|
|
76
|
+
menu.popup(nil, nil, event.button, event.time)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def userlist_on_doubleclick(treeview, path, column)
|
|
81
|
+
iter = treeview.model.get_iter(path)
|
|
82
|
+
return if iter[1] == @buffer.username
|
|
83
|
+
if !chat = @buffer.main.find_buffer(@buffer.network.name, @buffer.presence, nil, iter[1])
|
|
84
|
+
@buffer.main.add_buffer(@buffer.network.name, @buffer.presence, nil, iter[1])
|
|
85
|
+
end
|
|
86
|
+
# chat.connect unless chat.connected
|
|
87
|
+
# switchchannel(chat)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def create_user_popup(user)
|
|
91
|
+
user = @buffer.users[user] if @buffer.users
|
|
92
|
+
if user
|
|
93
|
+
menu = Gtk::Menu.new
|
|
94
|
+
menu.append(Gtk::MenuItem.new(user.name))
|
|
95
|
+
menu.append(Gtk::MenuItem.new('hostname: '+user.hostname)) if user.hostname
|
|
96
|
+
menu.append(Gtk::MenuItem.new('Last message: '+user.lastspoke.strftime('%H:%M')))
|
|
97
|
+
whois = Gtk::MenuItem.new("Whois "+ user.name)
|
|
98
|
+
whois.signal_connect('activate') do |w|
|
|
99
|
+
@buffer.controller.window.whois(user.name)
|
|
100
|
+
end
|
|
101
|
+
menu.append(whois)
|
|
102
|
+
else
|
|
103
|
+
menu = nil
|
|
104
|
+
end
|
|
105
|
+
menu
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def get_iter(name)
|
|
110
|
+
iter = @useriters.detect{|x| x.valid? and @userlist.get_iter(x.path)[1] == name}
|
|
111
|
+
return nil unless iter
|
|
112
|
+
@userlist.get_iter(iter.path)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def summary=(summary)
|
|
116
|
+
@title.text = summary
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def add_user(user, position)
|
|
120
|
+
iter = @userlist.insert(position)
|
|
121
|
+
iter[0] = user.mode_symbol
|
|
122
|
+
iter[1] = user.name
|
|
123
|
+
@useriters << Gtk::TreeRowReference.new(@userlist, iter.path)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
#~ def move(olduser, user, position)
|
|
127
|
+
#~ remove_user(olduser)
|
|
128
|
+
#~ add_user(user, position)
|
|
129
|
+
#~ end
|
|
130
|
+
|
|
131
|
+
def reorder(oldposition, newposition, user)
|
|
132
|
+
iter = @userlist.get_iter(oldposition.to_s)
|
|
133
|
+
# puts iter
|
|
134
|
+
@userlist.remove(iter) if iter
|
|
135
|
+
add_user(user, newposition)
|
|
136
|
+
#iter[0] = user.mode_symbol
|
|
137
|
+
#iter[1] = user.name
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#~ def reorder(order)
|
|
141
|
+
#~ first = @userlist.iter_first
|
|
142
|
+
#~ #@userlist.rows_reordered(first.path, first, order)
|
|
143
|
+
#~ end
|
|
144
|
+
|
|
145
|
+
def remove_user(user)
|
|
146
|
+
iter = get_iter(user)
|
|
147
|
+
@userlist.remove(iter) if iter
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def clear
|
|
151
|
+
@userlist.clear
|
|
152
|
+
@useriters.clear
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def fill(model)
|
|
156
|
+
@userlist.clear
|
|
157
|
+
@useriters.clear
|
|
158
|
+
model.users.each{|user| add_user(user, model.users.index(user))}
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
data/lib/ratchet/help.rb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
This file is part of the Ratchet project, a client for Icecap.
|
|
3
|
+
Copyright (C) 2005-6 Andrew Thompson
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the Free Software
|
|
17
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18
|
+
=end
|
|
19
|
+
|
|
20
|
+
#### help.rb ####
|
|
21
|
+
# Some metaprogramming to allow the use of the help class method to document
|
|
22
|
+
# builtin commands and plugin added commands
|
|
23
|
+
####
|
|
24
|
+
|
|
25
|
+
module Ratchet
|
|
26
|
+
module Help
|
|
27
|
+
attr_reader :helpstrings
|
|
28
|
+
def help(a, b)
|
|
29
|
+
#puts a, b
|
|
30
|
+
@helpstrings ||= {}
|
|
31
|
+
@helpstrings[a] = b
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# class Class
|
|
37
|
+
# include Help
|
|
38
|
+
# end
|
|
39
|
+
|
|
40
|
+
class Module
|
|
41
|
+
include Ratchet::Help
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class Object
|
|
45
|
+
def help(sym)
|
|
46
|
+
sym = sym.to_sym
|
|
47
|
+
# puts "#{sym} => #{self.class.helpstrings[sym].inspect}"
|
|
48
|
+
if self.class.helpstrings and self.class.helpstrings[sym]
|
|
49
|
+
# puts "#{sym} => #{self.class.helpstrings[sym]}"
|
|
50
|
+
return self.class.helpstrings[sym]
|
|
51
|
+
else
|
|
52
|
+
#hit up the plugins for some info
|
|
53
|
+
ObjectSpace.each_object(Plugin) do |klass|
|
|
54
|
+
if klass.class.helpstrings and klass.class.helpstrings[sym]
|
|
55
|
+
# puts klass.class.helpstrings[sym]
|
|
56
|
+
return klass.class.helpstrings[sym]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
# puts "#{sym} was unmatched"
|
|
61
|
+
false
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|