Skip to content

Commit

Permalink
Pass an offset to with_index to calculate line numbers
Browse files Browse the repository at this point in the history
Rather than starting from 0 and always adding 1, this tells with_index
to start at 1.
  • Loading branch information
ekohl committed May 30, 2024
1 parent 2068cc1 commit 67edd23
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/puppet/provider/postgresql_conf/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def parse_config
active_settings = []
# iterate the file and construct a hash for every matching/active setting
# the hash is pushed to the array and the array is returned
File.foreach(resource[:target]).with_index do |line, index|
line_number = index + 1
File.foreach(resource[:target]).with_index(1) do |line, line_number|
matches = line.match(active_values_regex)
if matches
value = if matches[:value].to_i.to_s == matches[:value]
Expand Down

0 comments on commit 67edd23

Please sign in to comment.