Sha256: 85dff703e3879784e495eb4ef668344b7dee1d5509f5b8e2f3fab9919044805b

Contents?: true

Size: 799 Bytes

Versions: 17

Compression:

Stored size: 799 Bytes

Contents

module Gem
  module Release
    module Helper
      module Hash
        MERGER = ->(key, lft, rgt) do
          if lft.is_a?(::Hash) && rgt.is_a?(::Hash)
            lft.merge(rgt, &MERGER)
          else
            rgt
          end
        end

        def deep_merge(hash, other)
          hash.merge(other, &MERGER)
        end

        def symbolize_keys(hash)
          hash.map do |key, obj|
            key = key.respond_to?(:to_sym) ? key.to_sym : key
            obj = symbolize_keys(obj) if obj.is_a?(::Hash)
            [key, obj]
          end.to_h
        end

        def only(hash, *keys)
          hash.select { |key, _| keys.include?(key) }
        end

        def except(hash, *keys)
          hash.reject { |key, _| keys.include?(key) }
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gem-release-2.2.2 lib/gem/release/helper/hash.rb
gem-release-2.2.1 lib/gem/release/helper/hash.rb
gem-release-2.2.0 lib/gem/release/helper/hash.rb
gem-release-2.1.1 lib/gem/release/helper/hash.rb
gem-release-2.1.0 lib/gem/release/helper/hash.rb
gem-release-2.0.4 lib/gem/release/helper/hash.rb
gem-release-2.0.3 lib/gem/release/helper/hash.rb
gem-release-2.0.2 lib/gem/release/helper/hash.rb
gem-release-2.0.1 lib/gem/release/helper/hash.rb
gem-release-2.0.0.rc.3 lib/gem/release/helper/hash.rb
gem-release-2.0.0.rc.2 lib/gem/release/helper/hash.rb
gem-release-2.0.0.rc.1 lib/gem/release/helper/hash.rb
gem-release-2.0.0.dev.5 lib/gem/release/helper/hash.rb
gem-release-2.0.0.dev.4 lib/gem/release/helper/hash.rb
gem-release-2.0.0.dev.3 lib/gem/release/helper/hash.rb
gem-release-2.0.0.dev.2 lib/gem/release/helper/hash.rb
gem-release-2.0.0.dev.1 lib/gem/release/helper/hash.rb