Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix undefined method: inject for String #20

Merged
merged 1 commit into from

2 participants

@robbat2

The physical_volumes extraction using inject function doesn't work.
Change to using split/grep/map.

/Stage[main]/Releng::Disks/Volume_groupvg: Could not evaluate: undefined method `inject' for " PV,VG\n/dev/sda4,vg\n":String

Signed-off-by: Robin H. Johnson robbat2@gentoo.org

@robbat2 robbat2 Fix undefined method: inject for String
The physical_volumes extraction using inject function doesn't work.
Change to using split/grep/map.

/Stage[main]/Releng::Disks/Volume_group[vg] (err): Could not evaluate: undefined method `inject' for "  PV,VG\n/dev/sda4,vg\n":String

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
95cecec
@adrienthebo
Owner

For clarification, this fix is necessary because Ruby 1.9 removed String#inject. I've checked it and it looks good.

@adrienthebo adrienthebo merged commit b831542 into puppetlabs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 11, 2013
  1. @robbat2

    Fix undefined method: inject for String

    robbat2 authored
    The physical_volumes extraction using inject function doesn't work.
    Change to using split/grep/map.
    
    /Stage[main]/Releng::Disks/Volume_group[vg] (err): Could not evaluate: undefined method `inject' for "  PV,VG\n/dev/sda4,vg\n":String
    
    Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 8 deletions.
  1. +3 −8 lib/puppet/provider/volume_group/lvm.rb
View
11 lib/puppet/provider/volume_group/lvm.rb
@@ -32,14 +32,9 @@ def physical_volumes=(new_volumes = [])
def physical_volumes
lines = pvs('-o', 'pv_name,vg_name', '--separator', ',')
- lines.inject([]) do |memo, line|
- pv, vg = line.split(',').map { |s| s.strip }
- if vg == @resource[:name]
- memo << pv
- else
- memo
- end
- end
+ lines.split(/\n/).grep(/,#{@resource[:name]}$/).map { |s|
+ s.split(/,/)[0].strip
+ }
end
private
Something went wrong with that request. Please try again.