PerfectlyNormal-Flexo 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/flexo.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Flexo"
3
- s.version = "0.3.9"
4
- s.date = "2008-10-14"
3
+ s.version = "0.4.0"
4
+ s.date = "2008-10-15"
5
5
  s.author = "Per Christian B. Viken"
6
6
  s.email = "perchr@northblue.org"
7
7
  s.homepage = "http://eastblue.org/dev/flexo/"
@@ -9,7 +9,7 @@ module Flexo
9
9
 
10
10
  CHANPREFIX = ['#', '&', '+', '!']
11
11
 
12
- FLEXO_VERSION = '0.3.9'
12
+ FLEXO_VERSION = '0.4.0'
13
13
  FLEXO_RELEASE = 'Bendless Love'
14
14
  end
15
15
  end
data/lib/flexo/event.rb CHANGED
@@ -15,7 +15,7 @@ module Flexo
15
15
  def initialize(manager, data)
16
16
  @manager = manager
17
17
  @data = data
18
- @manager.logger.debug("Creating instance of #{self.class}")
18
+ @manager.logger.debug2("Creating instance of #{self.class}")
19
19
  end
20
20
 
21
21
  # Checks the nickname in the hostmask
data/lib/flexo/manager.rb CHANGED
@@ -66,7 +66,7 @@ module Flexo
66
66
  @server.setup
67
67
 
68
68
  @logger.debug "Created all Flexo-classes. Going to create threads"
69
- manager = Thread.new do
69
+ manager = Thread.new do
70
70
  loop do
71
71
  if @threadqueue.size < @threadmax
72
72
  @threadgroup.add(@threadqueue.shift.wakeup)
@@ -145,6 +145,10 @@ module Flexo
145
145
  def server
146
146
  return @server
147
147
  end
148
+
149
+ def load_plugin(plugin)
150
+ return @pluginmanager.load_plugin(plugin)
151
+ end
148
152
 
149
153
  def nickname; return @nickname; end
150
154
  def nickname=(nick); @nickname = nick; nick; end
@@ -83,10 +83,10 @@ module Flexo
83
83
 
84
84
  plugin = klass.new(@plugins_loaded)
85
85
  rescue Flexo::PluginError => e
86
- puts "Plugin encountered an error (#{e.class}): #{e.message}"
87
- puts e.backtrace
86
+ @manager.logger.error "Plugin encountered an error (#{e.class}): #{e.message}"
87
+ @manager.logger.error e.backtrace
88
88
  rescue Flexo::PluginDependencyError => e
89
- @manager.logger.warn e.message
89
+ @manager.logger.error e.message
90
90
  return nil
91
91
  rescue Flexo::PluginNotFoundError => e
92
92
  @manager.logger.warn e.message
data/plugins/auth.rb CHANGED
@@ -163,7 +163,7 @@ module Flexo
163
163
  p = privmsg
164
164
  return notify_cannot_register_in_public(p) if privmsg.to_channel?
165
165
  return notify_username_taken(p) if username_exists?(username)
166
- return notify_hostmask_taken(p) if hostmask_exists?(privmsg.from, privmsg.data.mask.host)
166
+ return notify_hostmask_taken(p) if hostmask_exists?(privmsg.from, privmsg.data.hostmask.hostname)
167
167
 
168
168
  master = (usercount == 0 ? true : false)
169
169
  register(username, password, privmsg.sender, privmsg.data.hostmask.hostname, (master ? 256 : @default_level.to_i))
data/plugins/control.rb CHANGED
@@ -6,7 +6,7 @@ module Flexo
6
6
  # as well as for adding the restricted commands
7
7
  class ControlPlugin < Flexo::Plugin
8
8
  NAME = 'Control'
9
- VERSION = '0.1.0'
9
+ VERSION = '0.1.2'
10
10
  SUMMARY = 'Control a Flexo instance through IRC'
11
11
  DEPENDS = ['auth']
12
12
 
@@ -14,22 +14,39 @@ module Flexo
14
14
  super
15
15
 
16
16
  @manager.logger.debug("ControlPlugin started")
17
- add_trigger(/^ctrl quit$/, &method(:cmd_quit))
18
- add_trigger(/^ctrl realquit$/, &method(:cmd_realquit))
19
- add_trigger(/^ctrl join (#\S+)$/, &method(:cmd_join))
17
+ add_restricted_trigger(/^ctrl quit ?(.+)*$/, :level => 256, &method(:cmd_quit))
18
+ add_restricted_trigger(/^ctrl join (#\S+)$/, :level => 192, &method(:cmd_join))
19
+ add_restricted_trigger(/^ctrl part (#\S+)$/, :level => 192, &method(:cmd_part))
20
+ add_restricted_trigger(/^ctrl plugin load (\S+)$/, :level => 256, &method(:cmd_loadplugin))
21
+ add_restricted_trigger(/^ctrl plugin unload (\S+)$/, :level => 256, &method(:cmd_unloadplugin))
20
22
  end
21
23
 
24
+ private
25
+
22
26
  def cmd_join(privmsg, channel)
23
27
  @manager.sender.join(channel)
24
28
  end
25
29
 
26
- def cmd_quit(privmsg)
27
- @manager.logger.debug("Trying to quit")
28
- privmsg.reply("No!")
30
+ def cmd_part(privmsg, channel)
31
+ @manager.sender.part(channel)
32
+ end
33
+
34
+ def cmd_quit(privmsg, message = "Leaving!")
35
+ @manager.logger.info("Requested to quit...")
36
+ @manager.sender.quit(message)
37
+ end
38
+
39
+ def cmd_loadplugin(privmsg, plugin)
40
+ @manager.logger.debug("ControlPlugin: Trying to load #{plugin}")
41
+ begin
42
+ plugin = @manager.load_plugin(plugin)
43
+ privmsg.reply "Successfully loaded #{plugin}"
44
+ rescue
45
+ end
29
46
  end
30
47
 
31
- def cmd_realquit(privmsg)
32
- @manager.sender.quit("Leaving!")
48
+ def cmd_unloadplugin(privmsg, plugin)
49
+ privmsg.reply "Not implemented yet"
33
50
  end
34
51
  end
35
52
  end
data/plugins/svnlookup.rb CHANGED
@@ -1,9 +1,3 @@
1
- begin
2
- require 'svn/info'
3
- rescue LoadError
4
- raise PluginDependencyError, "Ruby-bindings for Subversion not found"
5
- end
6
-
7
1
  module Flexo
8
2
  module Plugins
9
3
  # SVN Lookup -- Registers a command to view commit
@@ -13,28 +7,27 @@ module Flexo
13
7
  # this plugin requires read-access to the filesystem.
14
8
  class SvnLookupPlugin < Flexo::Plugin
15
9
  NAME = 'SvnLookup'
16
- VERSION = '0.1.0'
10
+ VERSION = '0.1.5'
17
11
  SUMMARY = 'Replies to !svn <project> [<revision>] with information about the commit'
18
- DEPENDS = []
12
+ DEPENDS = ['ruby-svn/info']
19
13
 
20
14
  def initialize(*args)
21
15
  super
22
16
  @manager.config['plugins.svn.repositories'] ||= '/var/svn/repositories'
23
17
  @path = @manager.config['plugins.svn.repositories']
24
18
 
25
- add_trigger(/^svn (\S+) (\d+)?/, &method(:cmd_lookup))
19
+ add_trigger(/^svn (\S+) ?(\d+)?$/, &method(:cmd_lookup))
26
20
  end
27
21
 
28
22
  private
29
23
 
30
- def lookup(privmsg, project, revision = 'latest')
31
- @manager.logger.debug "Requested information for #{project} (#{revision})"
24
+ def cmd_lookup(privmsg, project, revision = nil)
32
25
  begin
33
- if revision == 'latest'
26
+ if revision == nil
34
27
  revision = Svn::Repos.open("#{@path}/#{project}").fs.youngest_rev
35
28
  end
36
29
 
37
- @info = Svn::Info.new("#{@path}/#{project}", revision)
30
+ @info = Svn::Info.new("#{@path}/#{project}", revision.to_i)
38
31
  rescue => e
39
32
  raise PluginError, "#{e.message}\n#{e.backtrace}"
40
33
  end
@@ -45,18 +38,21 @@ module Flexo
45
38
  files_deleted = @info.deleted_files.length
46
39
  dirs_changed = @info.changed_dirs.length
47
40
 
48
- str_changedirs = (dirs_changed < 5 ? "in #{@info.changed_dirs.join(', ')}" : 'in the repository')
41
+ str_changedirs = (dirs_changed < 3 ?
42
+ "in #{@info.changed_dirs.join(', ')}" : '')
49
43
  str_changed = []
50
44
  str_changed << "#{files_added.to_s} added" if files_added > 0
51
45
  str_changed << "#{files_updated.to_s} updated" if files_updated > 0
52
46
  str_changed << "#{files_deleted.to_s} deleted" if files_deleted > 0
53
- str_changed = (str_changed.length > 0 ? changes.join(', ') : '')
47
+ str_changed = (str_changed.length > 0 ? str_changed.join(', ') : '')
54
48
  str_changelog = @info.log
49
+ str_date = @info.date
55
50
 
56
51
  str_full = "[#{project}] #{str_changed} #{str_changedirs}."
57
- str_full += " r#{revision} commited by #{author}: #{str_changelog}"
52
+ str_full += " r#{revision} commited by #{author} (#{str_date})"
58
53
 
59
54
  privmsg.reply str_full
55
+ privmsg.reply str_changelog
60
56
  end
61
57
  end
62
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PerfectlyNormal-Flexo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Per Christian B. Viken
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-14 00:00:00 -07:00
12
+ date: 2008-10-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15