iniparse 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +41 -0
- data/Rakefile +0 -6
- data/iniparse.gemspec +3 -3
- data/lib/iniparse.rb +1 -1
- data/lib/iniparse/line_collection.rb +15 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54777f2c94d29a5e70dd169e7c29b22cfe9d4ff5950e11fcfc29de8598d133ec
|
4
|
+
data.tar.gz: 10cbe66f1aae3b50bbbeab08e49e507cb72641baf6363f408376cedf83bf987c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a948e61819671e50baa31ab3546326609d9c8e806d44dc0b76a4edc99cb3403224b4238762edb4d539c47e8a163e66e2f4c6705e6952d77cc4956898884783a2
|
7
|
+
data.tar.gz: 00b9a86378d0d1592914237e9c307bcc7804723293d834d440aaa9a23c552192b4961bae904433bd90851b8037d25bfb73c2aef350179c1577710f978472c1e7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
### 1.5.0
|
2
|
+
|
3
|
+
* OptionCollection no longer yields duplicate keys as an array, but instead yields each key in turn.
|
4
|
+
|
5
|
+
For example, given an INI file:
|
6
|
+
|
7
|
+
[test]
|
8
|
+
a = 1
|
9
|
+
a = 2
|
10
|
+
b = 3
|
11
|
+
|
12
|
+
IniParse would previously yield a single "a" key: an array containing two `Line`s:
|
13
|
+
|
14
|
+
doc['test'].map { |line| line }
|
15
|
+
# => [[<a = 1>, <a = 2>], <b = 3>]
|
16
|
+
|
17
|
+
Instead, each key/value pair will be yielded in turn:
|
18
|
+
|
19
|
+
doc['test'].map { |line| line }
|
20
|
+
# => [<a = 1>, <a = 2>, <b = 3>]
|
21
|
+
|
22
|
+
Directly accessing values via `[]` will still return an array of values as before:
|
23
|
+
|
24
|
+
doc['test']['a']
|
25
|
+
# => [1, 2]
|
26
|
+
|
27
|
+
* LineCollection#each may be called without a block, returning an Enumerator.
|
28
|
+
|
29
|
+
doc = IniParse.parse(<<~EOF)
|
30
|
+
[test]
|
31
|
+
a = x
|
32
|
+
b = y
|
33
|
+
EOF
|
34
|
+
|
35
|
+
doc[test].each
|
36
|
+
# => #<Enumerator: ...>
|
37
|
+
|
38
|
+
This allows for chaining as in the standard library:
|
39
|
+
|
40
|
+
doc['test'].map.with_index { |a, i| { index: i, value: a.value } }
|
41
|
+
# => [{ index: 0, value: 'x' }, { index: 1, value: 'y' }]
|
data/Rakefile
CHANGED
@@ -23,10 +23,6 @@ def date
|
|
23
23
|
Date.today.to_s
|
24
24
|
end
|
25
25
|
|
26
|
-
def rubyforge_project
|
27
|
-
name
|
28
|
-
end
|
29
|
-
|
30
26
|
def gemspec_file
|
31
27
|
"#{name}.gemspec"
|
32
28
|
end
|
@@ -77,8 +73,6 @@ task :gemspec => :validate do
|
|
77
73
|
replace_header(head, :name)
|
78
74
|
replace_header(head, :version)
|
79
75
|
replace_header(head, :date)
|
80
|
-
#comment this out if your rubyforge_project has a different name
|
81
|
-
replace_header(head, :rubyforge_project)
|
82
76
|
|
83
77
|
# determine file list from git ls-files
|
84
78
|
files = `git ls-files`.
|
data/iniparse.gemspec
CHANGED
@@ -12,9 +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.
|
16
|
-
s.date = '
|
17
|
-
s.rubyforge_project = 'iniparse'
|
15
|
+
s.version = '1.5.0'
|
16
|
+
s.date = '2020-02-27'
|
18
17
|
|
19
18
|
s.summary = 'A pure Ruby library for parsing INI documents.'
|
20
19
|
s.authors = ['Anthony Williams']
|
@@ -36,6 +35,7 @@ Gem::Specification.new do |s|
|
|
36
35
|
|
37
36
|
# = MANIFEST =
|
38
37
|
s.files = %w[
|
38
|
+
CHANGELOG.md
|
39
39
|
Gemfile
|
40
40
|
LICENSE
|
41
41
|
README.rdoc
|
data/lib/iniparse.rb
CHANGED
@@ -57,6 +57,8 @@ module IniParse
|
|
57
57
|
# include_blank<Boolean>:: Include blank/comment lines?
|
58
58
|
#
|
59
59
|
def each(include_blank = false)
|
60
|
+
return enum_for(:each, include_blank) unless block_given?
|
61
|
+
|
60
62
|
@lines.each do |line|
|
61
63
|
if include_blank || ! (line.is_a?(Array) ? line.empty? : line.blank?)
|
62
64
|
yield(line)
|
@@ -161,10 +163,22 @@ module IniParse
|
|
161
163
|
self
|
162
164
|
end
|
163
165
|
|
166
|
+
def each(*args)
|
167
|
+
return enum_for(:each, *args) unless block_given?
|
168
|
+
|
169
|
+
super(*args) do |value|
|
170
|
+
if value.is_a?(Array)
|
171
|
+
value.each { |item| yield(item) }
|
172
|
+
else
|
173
|
+
yield value
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
164
178
|
# Return an array containing the keys for the lines added to this
|
165
179
|
# collection.
|
166
180
|
def keys
|
167
|
-
map
|
181
|
+
map(&:key).uniq
|
168
182
|
end
|
169
183
|
end
|
170
184
|
end
|
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
|
+
version: 1.5.0
|
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: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -33,6 +33,7 @@ extra_rdoc_files:
|
|
33
33
|
- LICENSE
|
34
34
|
- README.rdoc
|
35
35
|
files:
|
36
|
+
- CHANGELOG.md
|
36
37
|
- Gemfile
|
37
38
|
- LICENSE
|
38
39
|
- README.rdoc
|
@@ -65,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
66
|
- !ruby/object:Gem::Version
|
66
67
|
version: '0'
|
67
68
|
requirements: []
|
68
|
-
|
69
|
-
rubygems_version: 2.5.1
|
69
|
+
rubygems_version: 3.0.3
|
70
70
|
signing_key:
|
71
71
|
specification_version: 2
|
72
72
|
summary: A pure Ruby library for parsing INI documents.
|