Sha256: 6998a7b26c4b811455229b3c988168d3139d50b49a4671aac187bcddfcabdc84
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true class ImageOptim class Runner # Helper methods for glob module GlobHelpers class << self # Match inner curly braces in glob # Negative lookbehind is not used as is not supported by ruby before 1.9 BRACE_REGEXP = / \A ( (?:.*[^\\]|) # anything ending not with slash or nothing (?:\\\\)* # any number of self escaped slashes ) \{ # open brace ( (?:|.*?[^\\]) # nothing or non greedy anything ending not with slash (?:\\\\)* # any number of self escaped slashes ) \} # close brace ( .* # what is left ) \z /x.freeze # Expand curly braces in glob as fnmatch in ruby before 2.0 doesn't # support them def expand_braces(original_glob) expanded = [] unexpanded = [original_glob] while (glob = unexpanded.shift) if (m = BRACE_REGEXP.match(glob)) m[2].split(',', -1).each do |variant| unexpanded << "#{m[1]}#{variant}#{m[3]}" end else expanded << glob end end expanded.uniq end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems