parseconfig 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/Changelog +4 -0
  3. data/LICENSE +1 -1
  4. data/README.md +45 -39
  5. data/lib/parseconfig.rb +4 -4
  6. metadata +8 -10
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d1e9b35305ee60ce0732906eee17091e8c3564e
4
+ data.tar.gz: 20c5c7343345170d04a5f9009f55f9a31bf61cc2
5
+ SHA512:
6
+ metadata.gz: 7db0455728e0e7a4cbb058db4766e28bf5029258b10f808c11bf5eca06a5d53dafb9499dac1339bbcf847306ac3f39c6f55cd9ed77dfbdb57134170dcd3ff413
7
+ data.tar.gz: 31d19e90674de0732c023e644b90e9860c5845b8d0cabed89022786b45d8c43a4d16c81cd8b2f9f196da6548ada8a95741ee941fbe43bf1b250a5e822373a9c3
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ Mon Oct 06, 2014 - v1.0.6
2
+ - Fix where extraneous double quotes were getting wrapped around parameters
3
+ that have non-word characters (issue #19)
4
+
1
5
  Thu Dec 19, 2013 - v1.0.4
2
6
  - Add fix for config files with Byte Order Marker (BOM)
3
7
  - Add support for .eql? function.
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  The MIT License:
3
3
 
4
- Copyright (c) 2006-2013 Data Folk Labs, LLC
4
+ Copyright (c) 2006-2014 Data Folk Labs, LLC
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -11,6 +11,10 @@ Installation
11
11
 
12
12
  $ sudo gem install parseconfig
13
13
 
14
+ Gemfile
15
+
16
+ gem 'parseconfig'
17
+
14
18
  Usage
15
19
  -----
16
20
 
@@ -31,49 +35,51 @@ An example configuration file might look like:
31
35
 
32
36
  Access it with ParseConfig:
33
37
 
34
- >> require('parseconfig.rb')
35
- => true
38
+ ```ruby
39
+
40
+ >> require 'parseconfig'
41
+ => true
36
42
 
37
- >> config = ParseConfig.new('/path/to/config/file')
38
- => #<ParseConfig:0x102410908
39
- @config_file="example.conf",
40
- @groups=["group1", "group2"],
41
- @params={
43
+ >> config = ParseConfig.new('/path/to/config/example.conf')
44
+ => #<ParseConfig:0x102410908
45
+ @config_file="example.conf",
46
+ @groups=["group1", "group2"],
47
+ @params={
48
+ "param1"=>"value1"
49
+ "param2"=>"value2",
50
+ "group1"=>{
42
51
  "param1"=>"value1"
43
52
  "param2"=>"value2",
44
- "group1"=>{
45
- "param1"=>"value1"
46
- "param2"=>"value2",
47
- },
48
- "group2"=>{
49
- "param1"=>"value1"
50
- "param2"=>"value2",
51
- },
52
- }
53
- >
54
-
55
- >> config.get_params()
56
- => ["param1", "param2", "group1", "group2"]
57
-
58
- >> config['param1']
59
- => "value1"
60
-
61
- >> config.get_groups()
62
- => ["group1", "group2"]
63
-
64
- >> config['group1']
65
- => {"group1_param1"=>"group1_value1", "group1_param2"=>"group1_value2"}
66
-
67
- >> config['group1']['group1_param1']
68
- => "group1_value1"
69
-
70
- >> file = File.open('/path/to/config/file', 'w')
71
- => #<File:file>
72
- >> config.write(file)
73
- => []
74
- >> file.close
75
- => nil
53
+ },
54
+ "group2"=>{
55
+ "param1"=>"value1"
56
+ "param2"=>"value2",
57
+ },
58
+ }>
59
+
60
+ >> config.get_params
61
+ => ["param1", "param2", "group1", "group2"]
62
+
63
+ >> config['param1']
64
+ => "value1"
65
+
66
+ >> config.get_groups
67
+ => ["group1", "group2"]
68
+
69
+ >> config['group1']
70
+ => {"group1_param1"=>"group1_value1", "group1_param2"=>"group1_value2"}
71
+
72
+ >> config['group1']['group1_param1']
73
+ => "group1_value1"
74
+
75
+ >> file = File.open('/path/to/config/file', 'w')
76
+ => #<File:file>
77
+ >> config.write(file)
78
+ => []
79
+ >> file.close
80
+ => nil
76
81
 
82
+ ```
77
83
 
78
84
  License
79
85
  -------
@@ -18,7 +18,7 @@
18
18
 
19
19
  class ParseConfig
20
20
 
21
- Version = '1.0.4'
21
+ Version = '1.0.6'
22
22
 
23
23
  attr_accessor :config_file, :params, :groups
24
24
 
@@ -155,10 +155,10 @@ class ParseConfig
155
155
  end
156
156
 
157
157
  # Writes out the config file to output_stream
158
- def write(output_stream=STDOUT)
158
+ def write(output_stream=STDOUT, quoted=true)
159
159
  self.params.each do |name,value|
160
160
  if value.class.to_s != 'Hash'
161
- if value.scan(/\w+/).length > 1
161
+ if quoted == true
162
162
  output_stream.puts "#{name} = \"#{value}\""
163
163
  else
164
164
  output_stream.puts "#{name} = #{value}"
@@ -170,7 +170,7 @@ class ParseConfig
170
170
  self.groups.each do |group|
171
171
  output_stream.puts "[#{group}]"
172
172
  self.params[group].each do |param, value|
173
- if value.scan(/\w+/).length > 1
173
+ if quoted == true
174
174
  output_stream.puts "#{param} = \"#{value}\""
175
175
  else
176
176
  output_stream.puts "#{param} = #{value}"
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parseconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
5
- prerelease:
4
+ version: 1.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - BJ Dierkes
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2014-10-06 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: ParseConfig provides simple parsing of standard configuration files in
15
14
  the form of 'param = value'. It also supports nested [group] sections.
@@ -18,32 +17,31 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - README.md
22
20
  - Changelog
23
21
  - LICENSE
22
+ - README.md
24
23
  - lib/parseconfig.rb
25
24
  homepage: http://github.com/datafolklabs/ruby-parseconfig/
26
25
  licenses: []
26
+ metadata: {}
27
27
  post_install_message:
28
28
  rdoc_options: []
29
29
  require_paths:
30
30
  - lib
31
31
  required_ruby_version: !ruby/object:Gem::Requirement
32
- none: false
33
32
  requirements:
34
- - - ! '>='
33
+ - - ">="
35
34
  - !ruby/object:Gem::Version
36
35
  version: '0'
37
36
  required_rubygems_version: !ruby/object:Gem::Requirement
38
- none: false
39
37
  requirements:
40
- - - ! '>='
38
+ - - ">="
41
39
  - !ruby/object:Gem::Version
42
40
  version: '0'
43
41
  requirements: []
44
42
  rubyforge_project:
45
- rubygems_version: 1.8.23
43
+ rubygems_version: 2.2.2
46
44
  signing_key:
47
- specification_version: 3
45
+ specification_version: 4
48
46
  summary: Config File Parser for Standard Unix/Linux Type Config Files
49
47
  test_files: []