summaryrefslogtreecommitdiff
path: root/lib/puppet/util/external_iterator.rb
diff options
context:
space:
mode:
authorChris Price <chris@pupppetlabs.com>2012-08-17 04:48:28 -0700
committerChris Price <chris@pupppetlabs.com>2012-08-17 04:48:28 -0700
commitc57dab4903a6a23fb14dc79c76efea989e694460 (patch)
tree6f8ef871f02465d21b231e931eba03739422d277 /lib/puppet/util/external_iterator.rb
parent4f0e7264e3c3089e489d05bbb4371c449b0ed78d (diff)
downloadpuppet-inifile-c57dab4903a6a23fb14dc79c76efea989e694460.tar.gz
puppet-inifile-c57dab4903a6a23fb14dc79c76efea989e694460.tar.bz2
Add support for "global" section at beginning of file
This commit does the following: * Fixes a bug in ExternalIterator * Adds support for a "global" section before the first named section at the beginning of the INI file * Improves test coverage
Diffstat (limited to 'lib/puppet/util/external_iterator.rb')
-rw-r--r--lib/puppet/util/external_iterator.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/puppet/util/external_iterator.rb b/lib/puppet/util/external_iterator.rb
index 67b3375..45c0fa4 100644
--- a/lib/puppet/util/external_iterator.rb
+++ b/lib/puppet/util/external_iterator.rb
@@ -3,7 +3,7 @@ module Util
class ExternalIterator
def initialize(coll)
@coll = coll
- @cur_index = 0
+ @cur_index = -1
end
def next
@@ -17,7 +17,11 @@ module Util
private
def item_at(index)
- [@coll[index], index]
+ if @coll.length > index
+ [@coll[index], index]
+ else
+ [nil, nil]
+ end
end
end
end