configparser 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/configparser.gemspec +1 -0
- data/lib/configparser.rb +6 -2
- data/lib/configparser/version.rb +1 -1
- data/test/test_configparser.rb +31 -0
- metadata +61 -67
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb8abd63de5675ecb447293414f42920df48f4f8
|
4
|
+
data.tar.gz: cdfd1a378fbf2bda1df9934ddae8d22299908443
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9ea08520489ce5de29f8c718f059527dae061d5be7abe300b6a9785b88dbba9d55576e5f1b9c2ef40a60497d605ebd3468feeb97b22c90bedd26fd59d222092
|
7
|
+
data.tar.gz: e5045a31bb7913efe020dc089cfbd6b6c5b3f068060f5240523c07f2c7d6d01fe8b74413584767c586c499bac6e69f8281ecce68061fbe4ab157361b2458088e
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/configparser.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
23
24
|
|
24
25
|
spec.signing_key = "#{File.dirname(__FILE__)}/../gem-private_key.pem"
|
25
26
|
spec.cert_chain = ["#{File.dirname(__FILE__)}/../gem-public_cert.pem"]
|
data/lib/configparser.rb
CHANGED
@@ -3,10 +3,14 @@ require "configparser/version"
|
|
3
3
|
# DESCRIPTION: parses configuration files compatible with Python's ConfigParser
|
4
4
|
|
5
5
|
class ConfigParser < Hash
|
6
|
-
def initialize(fname)
|
6
|
+
def initialize(fname = nil)
|
7
|
+
self.parse(File.open(fname, "r").each_line) if fname
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse(input_source)
|
7
11
|
section = nil
|
8
12
|
key = nil
|
9
|
-
|
13
|
+
input_source.each do |line|
|
10
14
|
next if (line =~ /^(#|;)/)
|
11
15
|
|
12
16
|
# parse out the lines of the config
|
data/lib/configparser/version.rb
CHANGED
data/test/test_configparser.rb
CHANGED
@@ -42,4 +42,35 @@ myway: or the highway
|
|
42
42
|
assert_equal('recent hotel',cp['section2']['local2'])
|
43
43
|
assert_equal('un$(resolvable)',cp['section2']['local3'])
|
44
44
|
end
|
45
|
+
|
46
|
+
def test_parse_from_non_file
|
47
|
+
simple_content = <<end_of_simple
|
48
|
+
test1=hi
|
49
|
+
test2 = hello
|
50
|
+
|
51
|
+
[first_section]
|
52
|
+
mytest=55
|
53
|
+
yourtest = 99
|
54
|
+
#nothere=notthere
|
55
|
+
myboolean
|
56
|
+
|
57
|
+
[second section]
|
58
|
+
myway=or the
|
59
|
+
highway
|
60
|
+
end_of_simple
|
61
|
+
|
62
|
+
cp = ConfigParser.new()
|
63
|
+
cp.parse(simple_content.each_line)
|
64
|
+
assert_equal(cp, {
|
65
|
+
"test1" => "hi",
|
66
|
+
"test2" => "hello",
|
67
|
+
"first_section" => {
|
68
|
+
"mytest" => "55",
|
69
|
+
"yourtest" => "99",
|
70
|
+
"myboolean" => true
|
71
|
+
},
|
72
|
+
"second section" => {
|
73
|
+
"myway" => "or the highway"
|
74
|
+
}})
|
75
|
+
end
|
45
76
|
end
|
metadata
CHANGED
@@ -1,19 +1,13 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: configparser
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- chrislee35
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
|
-
cert_chain:
|
10
|
+
cert_chain:
|
17
11
|
- |
|
18
12
|
-----BEGIN CERTIFICATE-----
|
19
13
|
MIIDYjCCAkqgAwIBAgIBADANBgkqhkiG9w0BAQUFADBXMREwDwYDVQQDDAhydWJ5
|
@@ -36,48 +30,57 @@ cert_chain:
|
|
36
30
|
jLXMQu2ZgISYwXNjNbGVHehut82U7U9oiHoWcrOGazaRUmGO9TXP+aJLH0gw2dcK
|
37
31
|
AfMglXPi
|
38
32
|
-----END CERTIFICATE-----
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
43
36
|
name: bundler
|
44
|
-
|
45
|
-
|
46
|
-
requirements:
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
47
39
|
- - ~>
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
|
50
|
-
segments:
|
51
|
-
- 1
|
52
|
-
- 3
|
53
|
-
version: "1.3"
|
54
|
-
prerelease: false
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
55
42
|
type: :development
|
56
|
-
|
57
|
-
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.3'
|
49
|
+
- !ruby/object:Gem::Dependency
|
58
50
|
name: rake
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
version: "0"
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
68
57
|
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: minitest
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
69
70
|
type: :development
|
70
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
71
77
|
description: parses configuration files compatable with Python's ConfigParser
|
72
|
-
email:
|
78
|
+
email:
|
73
79
|
- rubygems@chrislee.dhs.org
|
74
80
|
executables: []
|
75
|
-
|
76
81
|
extensions: []
|
77
|
-
|
78
82
|
extra_rdoc_files: []
|
79
|
-
|
80
|
-
files:
|
83
|
+
files:
|
81
84
|
- .gitignore
|
82
85
|
- Gemfile
|
83
86
|
- LICENSE.txt
|
@@ -91,39 +94,30 @@ files:
|
|
91
94
|
- test/simple.cfg
|
92
95
|
- test/test_configparser.rb
|
93
96
|
homepage: https://github.com/chrislee35/configparser
|
94
|
-
licenses:
|
97
|
+
licenses:
|
95
98
|
- MIT
|
99
|
+
metadata: {}
|
96
100
|
post_install_message:
|
97
101
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
102
|
+
require_paths:
|
100
103
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
hash: 3
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
119
114
|
requirements: []
|
120
|
-
|
121
115
|
rubyforge_project:
|
122
|
-
rubygems_version: 1.
|
116
|
+
rubygems_version: 2.1.11
|
123
117
|
signing_key:
|
124
|
-
specification_version:
|
118
|
+
specification_version: 4
|
125
119
|
summary: parses configuration files compatable with Python's ConfigParser
|
126
|
-
test_files:
|
120
|
+
test_files:
|
127
121
|
- test/complex.cfg
|
128
122
|
- test/helper.rb
|
129
123
|
- test/simple.cfg
|
metadata.gz.sig
CHANGED
Binary file
|