Method: ImageOptim::Runner::GlobHelpers.expand_braces

Defined in:
lib/image_optim/runner/glob_helpers.rb

.expand_braces(original_glob) ⇒ Object

Expand curly braces in glob as fnmatch in ruby before 2.0 doesn’t support them



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/image_optim/runner/glob_helpers.rb', line 28

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