configparser 0.1.3 → 0.1.4

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: 4d3c3eacddf5d2024c066d1538085850467ba989
4
- data.tar.gz: b121f9f948a254895fe7051802dcba8f7f72d612
3
+ metadata.gz: 26c531c67c5b36be5e065f5724dbbe79912fcd17
4
+ data.tar.gz: 0a0dbe4809dd15cb05a0fb2a57f725eb34ad3991
5
5
  SHA512:
6
- metadata.gz: b6fe602bdc834e0f4da93cd2db56ba3f38c9d85aab61fb73f5a4388d479fcb56e18c68d7447d658417f02606fb3712562063f1dd26494b6a17a5d16eaa84b126
7
- data.tar.gz: 257e52754a0e7f41ff98d70aeeab23943a60c78e39e2f6ab28cd1fea3776de8db1417131f8a0a0730deddcb576d4b1107869fde5100f6e1029379b8c2df2a92e
6
+ metadata.gz: dcac507b266312e93519fadf779cc1d7954929bbb74fcc0af83438230bf8f1a3067f604f27684382d6c77dc38d5aa6ebfa5ba885047f2d7aa03f33e9d56432d8
7
+ data.tar.gz: c754988f122b18ecd8dfacaea82951865d4e383d9d8a72d4c0e9cbfccfac8abe32aae47ab74e44981fa4f1cefed07111ac1619abf89ef240f13256dc51c7b634
data/README.md CHANGED
@@ -32,6 +32,7 @@ Or install it yourself as:
32
32
  myway=or the
33
33
  highway
34
34
 
35
+ require 'configparser'
35
36
  cp = ConfigParser.new('test/simple.cfg')
36
37
  puts cp.to_s
37
38
 
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_development_dependency "minitest", "~> 5.5"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "minitest"
24
24
 
25
- spec.signing_key = "#{File.dirname(__FILE__)}/../gem-private_key.pem"
26
- spec.cert_chain = ["#{File.dirname(__FILE__)}/../gem-public_cert.pem"]
25
+ #spec.signing_key = "#{File.dirname(__FILE__)}/../gem-private_key.pem"
26
+ #spec.cert_chain = ["#{File.dirname(__FILE__)}/../gem-public_cert.pem"]
27
27
 
28
28
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
29
  end
@@ -11,7 +11,7 @@ class ConfigParser < Hash
11
11
  section = nil
12
12
  key = nil
13
13
  input_source.each do |line|
14
- next if (line =~ /^(#|;)/)
14
+ next if (line =~ /^\s*(#|;)/)
15
15
 
16
16
  # parse out the lines of the config
17
17
  if line =~ /^\s*(.+?)\s*[=:]\s*(.+)$/ # handle key=value lines
@@ -23,7 +23,7 @@ class ConfigParser < Hash
23
23
  key = $1
24
24
  self[key] = $2
25
25
  end
26
- elsif line =~ /^\[(.+?)\]/ # handle new sections
26
+ elsif line =~ /^\s*\[(.+?)\]/ # handle new sections
27
27
  section = $1
28
28
  elsif line =~ /^\s+(.+?)$/ # handle continued lines
29
29
  if section
@@ -1,3 +1,3 @@
1
1
  class Configparser
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,41 @@
1
+ [Simple Values]
2
+ key=value
3
+ spaces in keys=allowed
4
+ spaces in values=allowed as well
5
+ spaces around the delimiter = obviously
6
+ you can also use : to delimit keys from values
7
+
8
+ [All Values Are Strings]
9
+ values like this: 1000000
10
+ or this: 3.14159265359
11
+ are they treated as numbers? : no
12
+ integers, floats and booleans are held as: strings
13
+ can use the API to get converted values directly: true
14
+
15
+ [Multiline Values]
16
+ chorus: I'm a lumberjack, and I'm okay
17
+ I sleep all night and I work all day
18
+
19
+ [No Values]
20
+ key_without_value
21
+ empty string value here =
22
+
23
+ [You can use comments]
24
+ # like this
25
+ ; or this
26
+
27
+ # By default only in an empty line.
28
+ # Inline comments can be harmful because they prevent users
29
+ # from using the delimiting characters as parts of values.
30
+ # That being said, this can be customized.
31
+
32
+ [Sections Can Be Indented]
33
+ can_values_be_as_well = True
34
+ does_that_mean_anything_special = False
35
+ purpose = formatting for readability
36
+ multiline_values = are
37
+ handled just fine as
38
+ long as they are indented
39
+ deeper than the first line
40
+ of a value
41
+ # Did I mention we can indent comments, too?
@@ -1,2 +1,6 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
+ require 'minitest/test'
3
+ require 'minitest/unit'
4
+ require 'minitest/pride'
5
+ include MiniTest::Assertions
2
6
  require File.expand_path('../../lib/configparser.rb', __FILE__)
@@ -8,10 +8,10 @@ end
8
8
 
9
9
  require_relative 'helper'
10
10
 
11
- class TestConfigparser < Test::Unit::TestCase
11
+ class TestConfigparser < Minitest::Test
12
12
  def test_parse_a_simple_config
13
13
  cp = ConfigParser.new('test/simple.cfg')
14
- assert_not_nil(cp)
14
+ refute_nil(cp)
15
15
  assert_equal('hi',cp['test1'])
16
16
  assert_equal('hello',cp['test2'])
17
17
  assert_equal('55',cp['first_section']['mytest'])
@@ -36,7 +36,7 @@ myway: or the highway
36
36
 
37
37
  def test_parse_a_config_with_substitutions
38
38
  cp = ConfigParser.new('test/complex.cfg')
39
- assert_not_nil(cp)
39
+ refute_nil(cp)
40
40
  assert_equal('strange-default-whatever',cp['global2'])
41
41
  assert_equal('strange-default-whatever-yodel-local',cp['section1']['local1'])
42
42
  assert_equal('recent hotel',cp['section2']['local2'])
@@ -45,7 +45,7 @@ myway: or the highway
45
45
 
46
46
  def test_parse_a_config_with_indents
47
47
  cp = ConfigParser.new('test/smb.cfg')
48
- assert_not_nil(cp)
48
+ refute_nil(cp)
49
49
  assert_equal("WORKGROUP", cp['global']["workgroup"])
50
50
  assert_equal("%h server (Samba, Ubuntu)", cp['global']["server string"])
51
51
  assert_equal("no", cp['global']["dns proxy"])
@@ -81,4 +81,34 @@ end_of_simple
81
81
  "myway" => "or the highway"
82
82
  }})
83
83
  end
84
+
85
+ def test_parse_configparser_example_from_python
86
+ cp = ConfigParser.new('test/configparser_example.cfg')
87
+ refute_nil(cp)
88
+ doc = "[All Values Are Strings]
89
+ are they treated as numbers?: no
90
+ can use the API to get converted values directly: true
91
+ integers, floats and booleans are held as: strings
92
+ or this: 3.14159265359
93
+ values like this: 1000000
94
+ [Multiline Values]
95
+ chorus: I'm a lumberjack, and I'm okay I sleep all night and I work all day
96
+ [No Values]
97
+ key_without_value
98
+ [Sections Can Be Indented]
99
+ can_values_be_as_well: True
100
+ does_that_mean_anything_special: False
101
+ multiline_values: are handled just fine as long as they are indented deeper than the first line of a value
102
+ purpose: formatting for readability
103
+ [Simple Values]
104
+ key: value
105
+ spaces around the delimiter: obviously
106
+ spaces in keys: allowed
107
+ spaces in values: allowed as well
108
+ you can also use: to delimit keys from values
109
+ "
110
+
111
+ assert_equal(doc, cp.to_s)
112
+ end
113
+
84
114
  end
metadata CHANGED
@@ -1,67 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDYjCCAkqgAwIBAgIBADANBgkqhkiG9w0BAQUFADBXMREwDwYDVQQDDAhydWJ5
14
- Z2VtczEYMBYGCgmSJomT8ixkARkWCGNocmlzbGVlMRMwEQYKCZImiZPyLGQBGRYD
15
- ZGhzMRMwEQYKCZImiZPyLGQBGRYDb3JnMB4XDTEzMDUyMjEyNTk0N1oXDTE0MDUy
16
- MjEyNTk0N1owVzERMA8GA1UEAwwIcnVieWdlbXMxGDAWBgoJkiaJk/IsZAEZFghj
17
- aHJpc2xlZTETMBEGCgmSJomT8ixkARkWA2RoczETMBEGCgmSJomT8ixkARkWA29y
18
- ZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANcPrx8BZiWIR9xWWG8I
19
- tqR538tS1t+UJ4FZFl+1vrtU9TiuWX3Vj37TwUpa2fFkziK0n5KupVThyEhcem5m
20
- OGRjvgrRFbWQJSSscIKOpwqURHVKRpV9gVz/Hnzk8S+xotUR1Buo3Ugr+I1jHewD
21
- Cgr+y+zgZbtjtHsJtsuujkOcPhEjjUinj68L9Fz9BdeJQt+IacjwAzULix6jWCht
22
- Uc+g+0z8Esryca2G6I1GsrgX6WHw8dykyQDT9dCtS2flCOwSC1R0K5T/xHW54f+5
23
- wcw8mm53KLNe+tmgVC6ZHyME+qJsBnP6uxF0aTEnGA/jDBQDhQNTF0ZP/abzyTsL
24
- zjUCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFO8w
25
- +aeP7T6kVJblCg6eusOII9DfMA0GCSqGSIb3DQEBBQUAA4IBAQBCQyRJLXsBo2Fy
26
- 8W6e/W4RemQRrlAw9DK5O6U71JtedVob2oq+Ob+zmS+PifE2+L+3RiJ2H6VTlOzi
27
- x+A061MUXhGraqVq4J2FC8kt4EQywAD0P0Ta5GU24CGSF08Y3GkJy1Sa4XqTC2YC
28
- o51s7JP+tkCCtpVYSdzJhTllieRAWBpGV1dtaoeUKE6tYPMBkosxSRcVGczk/Sc3
29
- 7eQCpexYy9JlUBI9u3BqIY9E+l+MSn8ihXSPmyK0DgrhaCu+voaSFVOX6Y+B5qbo
30
- jLXMQu2ZgISYwXNjNbGVHehut82U7U9oiHoWcrOGazaRUmGO9TXP+aJLH0gw2dcK
31
- AfMglXPi
32
- -----END CERTIFICATE-----
33
- date: 2014-05-20 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2015-06-17 00:00:00.000000000 Z
34
12
  dependencies:
35
13
  - !ruby/object:Gem::Dependency
36
- name: bundler
14
+ name: minitest
37
15
  requirement: !ruby/object:Gem::Requirement
38
16
  requirements:
39
17
  - - "~>"
40
18
  - !ruby/object:Gem::Version
41
- version: '1.3'
19
+ version: '5.5'
42
20
  type: :development
43
21
  prerelease: false
44
22
  version_requirements: !ruby/object:Gem::Requirement
45
23
  requirements:
46
24
  - - "~>"
47
25
  - !ruby/object:Gem::Version
48
- version: '1.3'
26
+ version: '5.5'
49
27
  - !ruby/object:Gem::Dependency
50
- name: rake
28
+ name: bundler
51
29
  requirement: !ruby/object:Gem::Requirement
52
30
  requirements:
53
- - - ">="
31
+ - - "~>"
54
32
  - !ruby/object:Gem::Version
55
- version: '0'
33
+ version: '1.3'
56
34
  type: :development
57
35
  prerelease: false
58
36
  version_requirements: !ruby/object:Gem::Requirement
59
37
  requirements:
60
- - - ">="
38
+ - - "~>"
61
39
  - !ruby/object:Gem::Version
62
- version: '0'
40
+ version: '1.3'
63
41
  - !ruby/object:Gem::Dependency
64
- name: minitest
42
+ name: rake
65
43
  requirement: !ruby/object:Gem::Requirement
66
44
  requirements:
67
45
  - - ">="
@@ -90,6 +68,7 @@ files:
90
68
  - lib/configparser.rb
91
69
  - lib/configparser/version.rb
92
70
  - test/complex.cfg
71
+ - test/configparser_example.cfg
93
72
  - test/helper.rb
94
73
  - test/simple.cfg
95
74
  - test/smb.cfg
@@ -120,6 +99,7 @@ specification_version: 4
120
99
  summary: parses configuration files compatable with Python's ConfigParser
121
100
  test_files:
122
101
  - test/complex.cfg
102
+ - test/configparser_example.cfg
123
103
  - test/helper.rb
124
104
  - test/simple.cfg
125
105
  - test/smb.cfg
Binary file
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- x��n�ˉ���qut7���5%�l}�O�>�iGi��{oz ��<�兾FM� �ގ`�2Hb�x�C�*�_|&� jp���l�?�X�Wg��8e�o�vU�]{�~��2����g&n�����|���gJP�6tb������