confparser 0.0.1.2 → 0.0.1.3

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.
Files changed (2) hide show
  1. data/lib/confparser.rb +8 -9
  2. metadata +2 -2
data/lib/confparser.rb CHANGED
@@ -22,9 +22,9 @@ class ConfParser < Hash
22
22
 
23
23
  def [] (name)
24
24
  __get__(name).tap {|x|
25
- x.gsub!(/\$\((.+?)\)/) {|n|
25
+ break x.gsub(/\$\((.+?)\)/) {|n|
26
26
  (self[$1] || parent[$1]).to_s
27
- } if x.is_a?(String)
27
+ }.strip if x.is_a?(String)
28
28
  }
29
29
  end
30
30
  }
@@ -69,28 +69,27 @@ class ConfParser < Hash
69
69
 
70
70
  case line
71
71
  when /^\s*[;#]/ then next
72
- when /^\s*$/ then next
73
72
  when /^\s*(.+?)\s*[=:]\s*(.*)$/
74
73
  if section
75
74
  self[section] = Section.new(self) unless self[section]
76
- key = $1
77
- self[section][key] = $2
75
+ key, self[section][key] = $1, $2
78
76
  else
79
- key = $1
80
- self[key] = $2
77
+ key, self[key] = $1, $2
81
78
  end
82
79
  when /^\s*\[(.+?)\]\s*$/
83
- section = $1
80
+ section, key = $1, nil
84
81
  else
85
82
  if key
86
83
  if section
87
84
  self[section] = Section.new(self) unless self[section]
85
+ self[section][key] = '' unless self[section][key]
88
86
  self[section][key] += "\n" + line
89
87
  else
88
+ self[key] = '' unless self[key]
90
89
  self[key] += "\n" + line
91
90
  end
92
91
  else
93
- raise "Syntax error at line #{lineno}"
92
+ raise "Syntax error at line #{lineno}" unless line =~ /^\s*$/
94
93
  end
95
94
  end
96
95
  }
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.0.1.2
9
+ - 3
10
+ version: 0.0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - shura