configparser 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42a4613bc96b535efac8c96b423eb3990946876c
4
- data.tar.gz: ca2ee55f792fcde58014508cbc5ed23bedb9476e
3
+ metadata.gz: 963a2aeb71783101be9ff9da4eae8ab8f237471e
4
+ data.tar.gz: 6280b7525c83c1d1d3a1723c0af4be3c7ee88ae3
5
5
  SHA512:
6
- metadata.gz: 9d3d5f30257627c7e91e1ec1df2a522ce90c5a450afcb4bb62fba1549d16f7737c6de202de1b3d0e08d416585ecbe775214def93a5fce1bdf52138249a101c56
7
- data.tar.gz: ced3899217c2d2252824145acb1be8b7ad153fc9135465f1c39b4a3e20d40314b9f55a26fd72d8f6e4b71f007ee96bb3c44e0b52a685e86104d555bd43c28df4
6
+ metadata.gz: 56a5b36b5ba0bf411945af98586dc0d9a0cc33f3d7157e3277191cfbd5222689c0e41c14c27fb983db78822c3e673bb642283d501c94ec4b05080c6493f14ba0
7
+ data.tar.gz: ac46e308fdd5e3387b325f91982c7b637559374bb4036d00d32dc6b444dab15a271bd50633e0316042f0fa8b1c33524afd042b2e1672fef0e80ba5d6758f79d1
@@ -25,6 +25,7 @@ class ConfigParser < Hash
25
25
  end
26
26
  elsif line =~ /^\s*\[(.+?)\]/ # handle new sections
27
27
  section = $1
28
+ self[section] = {}
28
29
  elsif line =~ /^\s+(.+?)$/ # handle continued lines
29
30
  if section
30
31
  self[section][key] += " #{$1}";
@@ -1,3 +1,3 @@
1
1
  class Configparser
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -107,6 +107,7 @@ spaces around the delimiter: obviously
107
107
  spaces in keys: allowed
108
108
  spaces in values: allowed as well
109
109
  you can also use: to delimit keys from values
110
+ [You can use comments]
110
111
  "
111
112
 
112
113
  assert_equal(doc, cp.to_s)
@@ -125,4 +126,48 @@ end_of_simple
125
126
  }}, cp)
126
127
  assert_equal(nil_content, cp.to_s("="))
127
128
  end
129
+
130
+ def test_from_python_cfgparser
131
+ content = <<end_of_python_example
132
+ [Foo Bar]
133
+ foo=bar
134
+ [Spacey Bar]
135
+ foo = bar
136
+ [Commented Bar]
137
+ foo: bar ; comment
138
+ [Long Line]
139
+ foo: this line is much, much longer than my editor
140
+ likes it.
141
+ [Section\\with$weird%characters[\t]
142
+ [Internationalized Stuff]
143
+ foo[bg]: Bulgarian
144
+ foo=Default
145
+ foo[en]=English
146
+ foo[de]=Deutsch
147
+ [Spaces]
148
+ key with spaces : value
149
+ another with spaces = splat!
150
+ end_of_python_example
151
+ cp = ConfigParser.new()
152
+ cp.parse(content.each_line)
153
+ doc = "[Commented Bar]
154
+ foo: bar ; comment
155
+ [Foo Bar]
156
+ foo: bar
157
+ [Internationalized Stuff]
158
+ foo: Default
159
+ foo[bg]: Bulgarian
160
+ foo[de]: Deutsch
161
+ foo[en]: English
162
+ [Long Line]
163
+ foo: this line is much, much longer than my editor likes it.
164
+ [Section\\with$weird%characters[\t]
165
+ [Spaces]
166
+ another with spaces: splat!
167
+ key with spaces: value
168
+ [Spacey Bar]
169
+ foo: bar
170
+ "
171
+ assert_equal(doc, cp.to_s)
172
+ end
128
173
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest