iniparse 1.2.0 → 1.3.0

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: b3fc88cab6fd9b214be0c4baa4b5d3b6729add3e
4
- data.tar.gz: 006036392b16391ab8b80394b22607975144cf73
3
+ metadata.gz: a6b464db624dce7fb8e739ef4052ae6731160b5c
4
+ data.tar.gz: 34a23d15c017f66eb3c3a8b917de440c9bfcdbe0
5
5
  SHA512:
6
- metadata.gz: 83b9c5fb87539797e3cda761063bbbc5d7c26fe5eda392d7d19d60e99e7f5f2833e5744887bef07ed6bc3d2c474337922334b12b1c9e8526dda00a6a8e9eba62
7
- data.tar.gz: a4858ba30df58a5bf5c10a9928f6ccaf44bc7f9ade77f8e53effed28b31c4230f4d63391231ff5180c532fe8dfab6a16465774e82c1d4f1809a87158d1151e9c
6
+ metadata.gz: 0b31696c7ba53c6491a52371e34dc9b72c44eb8e4ba78009f3167b67df0a2642308bc7fd8ed5f76bc4ba5fd24fe4477faeb9d27ada8e2d262b340f161d55c40c
7
+ data.tar.gz: 90e65a58a1ac00d42bcd096a8542dbf0b32272d786661c827fceefaf66862f9a0eb46e2aa18b91bccdccb1f85987f0707f9ada537a2dd2ff04d9441fe041f4ce
data/README.rdoc CHANGED
@@ -88,6 +88,14 @@ Options which appear before the first section will be added to a section called
88
88
  document['a_section']['an_option']
89
89
  # => "a new value"
90
90
 
91
+ Delete entire sections by calling `#delete` with the section name...
92
+
93
+ document.delete('a_section')
94
+
95
+ ... or a single option with `#delete` on the section object:
96
+
97
+ document['a_section'].delete('an_option')
98
+
91
99
  === Creating a new INI file
92
100
 
93
101
  See IniParse::Generator.
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.2.0'
16
- s.date = '2014-04-08'
15
+ s.version = '1.3.0'
16
+ s.date = '2014-04-09'
17
17
  s.rubyforge_project = 'iniparse'
18
18
 
19
19
  s.summary = 'A pure Ruby library for parsing INI documents.'
data/lib/iniparse.rb CHANGED
@@ -7,7 +7,7 @@ require File.join(dir, 'lines')
7
7
  require File.join(dir, 'parser')
8
8
 
9
9
  module IniParse
10
- VERSION = '1.2.0'
10
+ VERSION = '1.3.0'
11
11
 
12
12
  # A base class for IniParse errors.
13
13
  class IniParseError < StandardError; end
@@ -32,6 +32,15 @@ module IniParse
32
32
  @lines[key.to_s]
33
33
  end
34
34
 
35
+ # Deletes the section whose name matches the given +key+.
36
+ #
37
+ # Returns the document.
38
+ #
39
+ def delete(*args)
40
+ @lines.delete(*args)
41
+ self
42
+ end
43
+
35
44
  # Returns this document as a string suitable for saving to a file.
36
45
  def to_ini
37
46
  @lines.to_a.map { |line| line.to_ini }.join($/)
@@ -66,6 +66,8 @@ module IniParse
66
66
 
67
67
  # Removes the value identified by +key+.
68
68
  def delete(key)
69
+ key = key.key if key.respond_to?(:key)
70
+
69
71
  unless (idx = @indicies[key]).nil?
70
72
  @indicies.delete(key)
71
73
  @indicies.each { |k,v| @indicies[k] = v -= 1 if v > idx }
@@ -153,6 +153,15 @@ module IniParse
153
153
  end
154
154
  end
155
155
 
156
+ # Deletes the option identified by +key+.
157
+ #
158
+ # Returns the section.
159
+ #
160
+ def delete(*args)
161
+ @lines.delete(*args)
162
+ self
163
+ end
164
+
156
165
  # Like [], except instead of returning just the option value, it returns
157
166
  # the matching line instance.
158
167
  #
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.2.0
4
+ version: 1.3.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: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec