dvyjones-slartibartfast 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -0
- data/Rakefile +17 -0
- data/bin/slartibartfast +10 -0
- data/lib/slartibartfast.rb +61 -0
- data/slartibartfast.gemspec +36 -0
- metadata +73 -0
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('slartibartfast', '0.0.1') do |p|
|
6
|
+
p.description = "A pluggable IRC bot."
|
7
|
+
p.url = "http://github.com/dvyjones/slartibartfast"
|
8
|
+
p.author = "Henrik Hodne"
|
9
|
+
p.email = "henrik.hodne@gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
p.runtime_dependencies = ["eventmanager"]
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
16
|
+
|
17
|
+
|
data/bin/slartibartfast
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'slartibartfast'
|
4
|
+
|
5
|
+
pm = Slartibartfast::PluginManager.new
|
6
|
+
# Load most plugins, such as Config, Commands, but NOT the IRC plugin.
|
7
|
+
pm.load :autoload
|
8
|
+
# Load and connect to the Irc plugin AFTER the other plugins are loaded.
|
9
|
+
pm.load :irc
|
10
|
+
pm[:irc].connect
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Slartibartfast
|
2
|
+
class PluginManager
|
3
|
+
attr_reader :plugins, :callbacks
|
4
|
+
attr_writer :callbacks
|
5
|
+
def initialize()
|
6
|
+
@plugins = {}
|
7
|
+
@callbacks = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def load(plugin, options)
|
11
|
+
options.merge!( :reload => false ) {|k,v1,v2| v1} # Specifying default options
|
12
|
+
if options[:reload] or !@plugins.has_key? plugin
|
13
|
+
self.doLoad plugin
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def unload(plugin)
|
18
|
+
if @plugins[plugin].respond_to? 'stop'
|
19
|
+
@plugins[plugin].stop
|
20
|
+
end
|
21
|
+
@plugins.delete plugin
|
22
|
+
@callbacks.delete plugin
|
23
|
+
end
|
24
|
+
|
25
|
+
def register(plugin, handle, callback)
|
26
|
+
if !@callbacks.has_key? plugin
|
27
|
+
@callbacks[plugin] = {}
|
28
|
+
@callbacks[plugin][handle] = []
|
29
|
+
else
|
30
|
+
if !@callbacks[plugin].has_key? handle
|
31
|
+
@callbacks[plugin][handle] = []
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@callbacks[plugin][handle] << callback
|
35
|
+
end
|
36
|
+
|
37
|
+
def e(handle, *args)
|
38
|
+
@callbacks.each do |p, h|
|
39
|
+
h.each do |h, c|
|
40
|
+
if h == handle
|
41
|
+
c.each do |c|
|
42
|
+
c.call *args
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def doLoad(plugin)
|
52
|
+
load 'plugins/#{plugin.to_s.downcase}.rb', wrap=false
|
53
|
+
@plugins[plugin] = Object.const_get("#{plugin.to_s.capitalize}Plugin").new :pm => self
|
54
|
+
if @plugins[plugin].respond_to? 'dependencies'
|
55
|
+
@plugins[plugin].dependencies.each do |dependency|
|
56
|
+
self.load(dependency)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{slartibartfast}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Henrik Hodne"]
|
9
|
+
s.date = %q{2008-12-09}
|
10
|
+
s.default_executable = %q{slartibartfast}
|
11
|
+
s.description = %q{A pluggable IRC bot.}
|
12
|
+
s.email = %q{henrik.hodne@gmail.com}
|
13
|
+
s.executables = ["slartibartfast"]
|
14
|
+
s.extra_rdoc_files = ["bin/slartibartfast", "README.rdoc", "lib/slartibartfast.rb"]
|
15
|
+
s.files = ["bin/slartibartfast", "Manifest", "slartibartfast.gemspec", "README.rdoc", "Rakefile", "lib/slartibartfast.rb"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/dvyjones/slartibartfast}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Slartibartfast", "--main", "README.rdoc"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{slartibartfast}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{A pluggable IRC bot.}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_runtime_dependency(%q<eventmanager>, [">= 0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<eventmanager>, [">= 0"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<eventmanager>, [">= 0"])
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dvyjones-slartibartfast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Henrik Hodne
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-09 00:00:00 -08:00
|
13
|
+
default_executable: slartibartfast
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: eventmanager
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: A pluggable IRC bot.
|
25
|
+
email: henrik.hodne@gmail.com
|
26
|
+
executables:
|
27
|
+
- slartibartfast
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- bin/slartibartfast
|
32
|
+
- README.rdoc
|
33
|
+
- lib/slartibartfast.rb
|
34
|
+
files:
|
35
|
+
- bin/slartibartfast
|
36
|
+
- Manifest
|
37
|
+
- slartibartfast.gemspec
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- lib/slartibartfast.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/dvyjones/slartibartfast
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --line-numbers
|
46
|
+
- --inline-source
|
47
|
+
- --title
|
48
|
+
- Slartibartfast
|
49
|
+
- --main
|
50
|
+
- README.rdoc
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "1.2"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: slartibartfast
|
68
|
+
rubygems_version: 1.2.0
|
69
|
+
signing_key:
|
70
|
+
specification_version: 2
|
71
|
+
summary: A pluggable IRC bot.
|
72
|
+
test_files: []
|
73
|
+
|