Skip to content

Commit

Permalink
lib/ruby_ext.rb: support Hash#transform_values for ruby < 2.4
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Li <philip.li@intel.com>
  • Loading branch information
rli9 committed Jan 14, 2024
1 parent e3fbcc6 commit b307e9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions filters/need_kconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'ostruct'
require "#{LKP_SRC}/lib/kernel_tag"
require "#{LKP_SRC}/lib/log"
require "#{LKP_SRC}/lib/ruby_ext"

def load_kernel_context
context_file = File.expand_path '../context.yaml', kernel
Expand Down
1 change: 1 addition & 0 deletions lib/lkp_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'active_support/core_ext/string'
require "#{LKP_SRC}/lib/yaml"
require "#{LKP_SRC}/lib/lkp_path"
require "#{LKP_SRC}/lib/ruby_ext"

module LKP
class Pattern
Expand Down
9 changes: 9 additions & 0 deletions lib/ruby_ext.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env ruby

if RUBY_VERSION < '2.4'
class Hash
def transform_values
map { |k, v| [ k, yield v ] }.to_h
end
end
end

0 comments on commit b307e9c

Please sign in to comment.