Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fix undefined method: inject for String #20

Merged
merged 1 commit into from over 1 year ago

2 participants

Robin H. Johnson Adrien Thebo
Robin H. Johnson

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

Robin H. Johnson 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
Adrien Thebo
Owner

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

Adrien Thebo adrienthebo merged commit b831542 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 11, 2013
  1. Robin H. Johnson

    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>
    robbat2 authored
This page is out of date. Refresh to see the latest.
Show diff stats Hide diff stats
Showing 1 changed file with 3 additions and 8 deletions.
  1. +3 8 lib/puppet/provider/volume_group/lvm.rb
11 lib/puppet/provider/volume_group/lvm.rb
View
@@ -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.