Sha256: 6c6a234eec1fef262e1f10324b3c27e1f64ef698085932738e0daee7a8966c32
Contents?: true
Size: 903 Bytes
Versions: 218
Compression:
Stored size: 903 Bytes
Contents
module Eco module Data module Files class FilePattern def initialize(file = "") @source_file = file end def resolve(dir: nil, start: "") pattern(dir).gsub('*', start) end def match?(file, dir: nil) /#{Regexp.escape(self.pattern(dir))}/i.match?(file) end def any?(files, dir: nil) return false unless files.is_a?(Array) files.any? { |file| match?(file, dir: dir) } end def pattern(dir = nil) return File.join(dir, "*") if @source_file.to_s.empty? filename = File.basename(@source_file) path = File.dirname(@source_file) path = File.join(dir, path) if dir wildcard = (filename =~ /\*/)? "" : "*" File.join(path, wildcard + filename) end end end end end
Version data entries
218 entries across 218 versions & 1 rubygems