Permalink
Browse files

server/base: move the support stuff to its own module

  • Loading branch information...
1 parent 649d96f commit af44c0ae5679dd9f0763accf486aa42ec25ea9f3 @meh committed Jul 14, 2011
Showing with 53 additions and 22 deletions.
  1. +4 −22 lib/failirc/server/modules/base.rb
  2. +49 −0 lib/failirc/server/modules/base/support.rb
View
26 lib/failirc/server/modules/base.rb
@@ -17,6 +17,7 @@
# along with failirc. If not, see <http://www.gnu.org/licenses/>.
#++
+require 'failirc/server/modules/base/support'
require 'failirc/server/modules/base/errors'
require 'failirc/server/modules/base/responses'
@@ -35,25 +36,6 @@
identifier 'RFC 1460, 2810, 2811, 2812, 2813;'
on :start do |server|
- @supported_modes = {
- :client => 'Nzo',
- :channel => 'abcCehiIkKlLmnNoQsStuvVxyz'
- }
-
- @support = {
- CASEMAPPING: 'ascii',
- SAFELIST: true,
- EXCEPTS: 'e',
- INVEX: 'I',
- CHANTYPES: '&#+!',
- CHANMODES: 'beI,kfL,lj,acCiKmnNQsStuVz',
- PREFIX: '(!xyohv)!~&@%+',
- STATUSMSG: '~&@%+',
- FNC: true,
-
- CMDS: 'KNOCK'
- }
-
@mutex = Mutex.new
@joining = {}
@pinged_out = []
@@ -309,10 +291,10 @@ def register (thing)
client.send RPL_HOSTEDBY, client
client.send RPL_SERVCREATEDON
client.send RPL_SERVINFO,
- client: @supported_modes[:client],
- channel: @supported_modes[:channel]
+ client: Support::Modes::Client,
+ channel: Support::Modes::Channel
- @support.map {|(key, value)|
+ Support.to_hash.map {|(key, value)|
value != true ? "#{key}=#{value}" : key
}.join(' ')
View
49 lib/failirc/server/modules/base/support.rb
@@ -0,0 +1,49 @@
+#--
+# Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
+#
+# This file is part of failirc.
+#
+# failirc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# failirc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with failirc. If not, see <http://www.gnu.org/licenses/>.
+#++
+
+module IRC; class Server; module Base
+
+module Support
+ module Modes
+ Client = 'NZo'
+ Channel = 'abcCehiIkKlLmnNoQsStuvVxyz'
+ end
+
+ CASEMAPPING = 'ascii'
+ SAFELIST = true
+ EXCEPTS = 'e'
+ INVEX = 'I'
+ CHANTYPES = '&#+!'
+ CHANMODES = 'beI,kfL,lj,acCiKmnNQsStuVz'
+ PREFIX = '(!xyohv)!~&@%+'
+ STATUSMSG = '~&@%+'
+ FNC = true
+ CMDS = 'KNOCK'
+
+ def self.to_hash
+ Hash[self.constants.reject {|const|
+ true if const == :Modes
+ }.map {|const|
+ [const, const_get(const)]
+ }]
+ end
+end
+
+
+end; end; end

0 comments on commit af44c0a

Please sign in to comment.