From c57dab4903a6a23fb14dc79c76efea989e694460 Mon Sep 17 00:00:00 2001 From: Chris Price Date: Fri, 17 Aug 2012 04:48:28 -0700 Subject: 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 --- lib/puppet/util/external_iterator.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/puppet/util/external_iterator.rb') 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 -- cgit v1.2.3