def nested_directory_map(paths)
      directories = {}

      options[:patterns].product(paths).each do |pattern, path|
        next unless (matches = path.match(pattern))

        target = options[:output] || File.dirname(path)
        if (subpath = matches[1])
          target = File.join(target, File.dirname(subpath)).gsub(/\/\.$/, '')
        end

        (directories[target] ||= []) << path
      end

      directories
    end
def nested_directory_map(paths)
      directories = {}

      options[:patterns].product(paths).each do |pattern, path|
        next unless (matches = path.match(pattern))

        target = options[:output] || File.dirname(path)
        if (subpath = matches[1])
          target = File.join(target, File.dirname(subpath)).gsub(/\/\.$/, '')
        end

        (directories[target] ||= []) << path
      end

      directories
    end
Creates a hash of changed files keyed by their target nested directory,
 which is based on either the original source directory or the :output
 option, plus the regex match group in a watcher like:

    %r{^app/stylesheets/(.+\.less)$}