File tree Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,13 @@ def self.blastlist(hash)
41
41
42
42
output = Puppet ::Util . withenv ( :PAGER => "/usr/bin/cat" ) { pkgget command }
43
43
44
- list = output . split ( "\n " ) . collect do |line |
44
+ list = output . split ( "\n " ) . filter_map do |line |
45
45
next if line =~ /^#/
46
46
next if line =~ /^WARNING/
47
47
next if line =~ /localrev\s +remoterev/
48
48
49
49
blastsplit ( line )
50
- end . compact
50
+ end
51
51
52
52
if hash [ :justme ]
53
53
return list [ 0 ]
Original file line number Diff line number Diff line change @@ -120,8 +120,7 @@ def self.gemlist(options)
120
120
121
121
begin
122
122
list = execute_gem_command ( options [ :command ] , command_options ) . lines
123
- . map { |set | gemsplit ( set ) }
124
- . compact
123
+ . filter_map { |set | gemsplit ( set ) }
125
124
rescue Puppet ::ExecutionFailure => detail
126
125
raise Puppet ::Error , _ ( "Could not list gems: %{detail}" ) % { detail : detail } , detail . backtrace
127
126
end
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ def self.instances(hash = {})
65
65
def self . availlist
66
66
output = pkguti [ "-a" ]
67
67
68
- output . split ( "\n " ) . collect do |line |
68
+ output . split ( "\n " ) . filter_map do |line |
69
69
next if line =~ /^common\s +package/ # header of package list
70
70
next if noise? ( line )
71
71
@@ -74,7 +74,7 @@ def self.availlist
74
74
else
75
75
Puppet . warning _ ( "Cannot match %{line}" ) % { line : line }
76
76
end
77
- end . compact
77
+ end
78
78
end
79
79
80
80
# Turn our pkgutil -c listing into a hash for a single package.
@@ -94,12 +94,12 @@ def self.parse_pkglist(output, hash = {})
94
94
return nil
95
95
end
96
96
97
- list = output . collect do |line |
97
+ list = output . filter_map do |line |
98
98
next if line =~ /installed\s +catalog/ # header of package list
99
99
next if noise? ( line )
100
100
101
101
pkgsplit ( line )
102
- end . compact
102
+ end
103
103
104
104
if hash [ :justme ]
105
105
# Single queries may have been for an alias so return the name requested
Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ def dochook(name, &block)
20
20
21
21
# Generate the full doc string.
22
22
def doc
23
- extra = methods . find_all { |m | m . to_s =~ /^dochook_.+/ } . sort . collect { |m |
23
+ extra = methods . find_all { |m | m . to_s =~ /^dochook_.+/ } . sort . filter_map { |m |
24
24
self . send ( m )
25
- } . compact . collect { |r | "* #{ r } " } . join ( "\n " )
25
+ } . collect { |r | "* #{ r } " } . join ( "\n " )
26
26
27
27
if @doc
28
28
scrub ( @doc ) + ( extra . empty? ? '' : "\n \n #{ extra } " )
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ def initialize(type,
105
105
def join ( details )
106
106
joinchar = self . joiner
107
107
108
- fields . collect { |field |
108
+ fields . filter_map { |field |
109
109
# If the field is marked absent, use the appropriate replacement
110
110
if details [ field ] == :absent or details [ field ] == [ :absent ] or details [ field ] . nil?
111
111
if self . optional . include? ( field )
@@ -116,7 +116,7 @@ def join(details)
116
116
else
117
117
details [ field ] . to_s
118
118
end
119
- } . compact . join ( joinchar )
119
+ } . join ( joinchar )
120
120
end
121
121
122
122
# Customize this so we can do a bit of validation.
You can’t perform that action at this time.
0 commit comments