Sha256: 2938691a1b7b45d8347be8555db97a161b1794f82d31f0f2738ccc9ac96fd0c3
Contents?: true
Size: 597 Bytes
Versions: 2
Compression:
Stored size: 597 Bytes
Contents
# frozen_string_literal: true module Glob class Map def self.call(target) new(target).call end def initialize(target) @target = target end def call @target .map {|(key, value)| compute(value, escape(key)) } .flatten .sort end private def escape(key) key.to_s.gsub(".", "\\.") end private def compute(value, path) if value.is_a?(Hash) value.map do |key, other_value| compute(other_value, "#{path}.#{escape(key)}") end else path.to_s end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
glob-0.4.1 | lib/glob/map.rb |
glob-0.4.0 | lib/glob/map.rb |