iniparse 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/iniparse.gemspec +3 -3
- data/lib/iniparse.rb +1 -1
- data/lib/iniparse/line_collection.rb +1 -1
- data/lib/iniparse/lines.rb +11 -7
- data/lib/iniparse/parser.rb +1 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef588e81126741da025ef4c347f46c02b6a63037
|
4
|
+
data.tar.gz: 3ecdabf11a24fc32e1241a6371e8e721cc49770a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74eeab1bc5dbf530b3f8655794dcdc602efbe82e5950feae867d1d3a9e775ce9c82859ec53bb1d8ea0ac64d2a707b7d6691f1767874f36e4182fa07696744648
|
7
|
+
data.tar.gz: 1158894ac7fe9d37a44a00b01b90325dbfec459e887cc343772af308407b015a482ff0c4e193dff53ee1d5caeef589d2cae6726e67001ed60c1dd9aeb4977454
|
data/iniparse.gemspec
CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
## If your rubyforge_project name is different, then edit it and comment out
|
13
13
|
## the sub! line in the Rakefile
|
14
14
|
s.name = 'iniparse'
|
15
|
-
s.version = '1.4.
|
16
|
-
s.date = '
|
15
|
+
s.version = '1.4.3'
|
16
|
+
s.date = '2017-06-01'
|
17
17
|
s.rubyforge_project = 'iniparse'
|
18
18
|
|
19
19
|
s.summary = 'A pure Ruby library for parsing INI documents.'
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.extra_rdoc_files = %w(LICENSE README.rdoc)
|
33
33
|
|
34
34
|
# Dependencies.
|
35
|
-
s.add_development_dependency('rspec', '~>
|
35
|
+
s.add_development_dependency('rspec', '~> 3.4')
|
36
36
|
|
37
37
|
# = MANIFEST =
|
38
38
|
s.files = %w[
|
data/lib/iniparse.rb
CHANGED
@@ -111,7 +111,7 @@ module IniParse
|
|
111
111
|
include LineCollection
|
112
112
|
|
113
113
|
def <<(line)
|
114
|
-
if line.kind_of?(IniParse::Lines::Option)
|
114
|
+
if line.kind_of?(IniParse::Lines::Option) || (has_key?('__anonymous__') && (line.blank? || line.kind_of?(IniParse::Lines::Comment)))
|
115
115
|
option = line
|
116
116
|
line = IniParse::Lines::AnonymousSection.new
|
117
117
|
|
data/lib/iniparse/lines.rb
CHANGED
@@ -11,6 +11,7 @@ module IniParse
|
|
11
11
|
@comment_prefix = opts.fetch(:comment_prefix, ' ')
|
12
12
|
@comment_offset = opts.fetch(:comment_offset, 0)
|
13
13
|
@indent = opts.fetch(:indent, '')
|
14
|
+
@option_sep = opts.fetch(:option_sep, nil)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Returns if this line has an inline comment.
|
@@ -54,7 +55,8 @@ module IniParse
|
|
54
55
|
comment_sep: @comment_sep,
|
55
56
|
comment_prefix: @comment_prefix,
|
56
57
|
comment_offset: @comment_offset,
|
57
|
-
indent: @indent
|
58
|
+
indent: @indent,
|
59
|
+
option_sep: @option_sep
|
58
60
|
}
|
59
61
|
end
|
60
62
|
end
|
@@ -248,9 +250,9 @@ module IniParse
|
|
248
250
|
class Option
|
249
251
|
include Line
|
250
252
|
|
251
|
-
@regex = /^\s*([^=]
|
252
|
-
|
253
|
-
(.*?)$
|
253
|
+
@regex = /^\s*([^=]+?) # Option, not greedy
|
254
|
+
(\s*=\s*) # Separator, greedy
|
255
|
+
(.*?)$ # Value
|
254
256
|
/x
|
255
257
|
|
256
258
|
attr_accessor :key, :value
|
@@ -263,11 +265,13 @@ module IniParse
|
|
263
265
|
def initialize(key, value, opts = {})
|
264
266
|
super(opts)
|
265
267
|
@key, @value = key.to_s, value
|
268
|
+
@option_sep = opts.fetch(:option_sep, ' = ')
|
266
269
|
end
|
267
270
|
|
268
271
|
def self.parse(line, opts)
|
269
272
|
if m = @regex.match(line)
|
270
|
-
[:
|
273
|
+
opts[:option_sep] = m[2]
|
274
|
+
[:option, m[1].strip, typecast(m[3].strip), opts]
|
271
275
|
end
|
272
276
|
end
|
273
277
|
|
@@ -291,9 +295,9 @@ module IniParse
|
|
291
295
|
# because of options key duplication
|
292
296
|
def line_contents
|
293
297
|
if value.kind_of?(Array)
|
294
|
-
value.map { |v, i| "#{key}
|
298
|
+
value.map { |v, i| "#{key}#{@option_sep}#{v}" }
|
295
299
|
else
|
296
|
-
"#{key}
|
300
|
+
"#{key}#{@option_sep}#{value}"
|
297
301
|
end
|
298
302
|
end
|
299
303
|
end
|
data/lib/iniparse/parser.rb
CHANGED
@@ -29,7 +29,7 @@ module IniParse
|
|
29
29
|
# source<String>:: The source string.
|
30
30
|
#
|
31
31
|
def initialize(source)
|
32
|
-
@source = source.dup
|
32
|
+
@source = source.dup.sub(/\n\z/,'')
|
33
33
|
end
|
34
34
|
|
35
35
|
# Parses the source string and returns the resulting data structure.
|
@@ -88,8 +88,6 @@ module IniParse
|
|
88
88
|
line[(m[1].length..-1)].index(m[2]) + m[1].length
|
89
89
|
|
90
90
|
line = m[1]
|
91
|
-
else
|
92
|
-
line.rstrip!
|
93
91
|
end
|
94
92
|
|
95
93
|
[line, opts]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iniparse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.4'
|
27
27
|
description: A pure Ruby library for parsing INI documents. Preserves the structure
|
28
28
|
of the original document, including whitespace and comments
|
29
29
|
email: hi@antw.me
|
@@ -66,9 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project: iniparse
|
69
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.5.1
|
70
70
|
signing_key:
|
71
71
|
specification_version: 2
|
72
72
|
summary: A pure Ruby library for parsing INI documents.
|
73
73
|
test_files: []
|
74
|
-
has_rdoc:
|