public
Description: Direct Connect bot written in Ruby
Clone URL: git://github.com/kballard/dcbot.git
Search Repo:
Create new class IniReader in config.rb
kballard (author)
Fri Feb 15 05:33:38 -0800 2008
commit  e89b66216bff218fc0924bcc5afd1f9d9d24e402
tree    4231e8b3a6bed7d12fe08a178651304075634406
parent  e0503ebf0f02caaabef537a00060cf628bb6ed16
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1 +1,30 @@
0
+module IniReader
0
+ def self.read(filename)
0
+ File.open(filename, "r") do |f|
0
+ read_stream(f)
0
+ end
0
+ end
0
+
0
+ def self.read_stream(io)
0
+ config = []
0
+ name = ""
0
+ section = {}
0
+ until (line = io.gets).nil?
0
+ if line =~ /^\s*#/ then
0
+ # do nothing
0
+ elsif line =~ /^\[(.*)\]\s*$/ then
0
+ config << [name, section]
0
+ name = $1
0
+ section = {}
0
+ elsif line =~ /^\s*(.*?)\s*=\s*(.*?)\s*$/ then
0
+ section[$1] = $2
0
+ end
0
+ end
0
+ config << [name, section]
0
+ if config.size > 0 and config[0][0] == "" and config[0][1].empty? then
0
+ config.delete_at 0
0
+ end
0
+ config
0
+ end
0
+end
...
2
3
4
 
5
6
7
...
2
3
4
5
6
7
8
0
@@ -2,6 +2,7 @@
0
 
0
 require 'rubygems'
0
 require './runloop'
0
+require './config'
0
 require './dcppsocket'
0
 require './plugin'
0
 require 'pp'

Comments

    No one has commented yet.