module Dotsmack

Dotsmack - File, dotignore, and dotconfig scanner.

Scans for files recursively.

Searches for dotfiles in:

dotignore assumes fnmatch format. dotconfig may be in any format.

Dotsmack

Constants

FNMATCH_FLAGS
HOME
PARENT_OF_HOME
VERSION

Public Class Methods

fnmatch?(pattern, path) click to toggle source

More intuitive behavior for fnmatch

# File lib/dotsmack.rb, line 31
def self.fnmatch?(pattern, path)
  # Assume non-directory path
  if File.fnmatch(pattern, path, FNMATCH_FLAGS) ||
      File.fnmatch("**#{File::SEPARATOR}#{pattern}", path, FNMATCH_FLAGS)
    true
  # Consider path as directory
  else
    path =
      if path.end_with?(File::SEPARATOR)
        path
      else
        "#{path}#{File::SEPARATOR}"
      end

    pattern =
      if pattern.end_with?(File::SEPARATOR)
        "#{pattern}*"
      else
        "#{pattern}#{File::SEPARATOR}*"
      end

    File.fnmatch(pattern, path, FNMATCH_FLAGS) ||
      File.fnmatch("**#{File::SEPARATOR}#{pattern}", path, FNMATCH_FLAGS)
  end
end