Sha256: 84a90eea466e878f21da1f03b6711ea05570b5c44a402ccef071d160cfd9e0d1
Contents?: true
Size: 708 Bytes
Versions: 35
Compression:
Stored size: 708 Bytes
Contents
module Wovnrb # inspired by https://github.com/isaacs/node-glob # # "*" Matches 0 or more characters in a single path portion # "**" If a "globstar" is alone in a path portion, # then it matches zero or more directories and subdirectories searching for matches. # # @note "?" or other pattern is not implemented class Glob def initialize(pattern) sub_directories = pattern.split('/**', -1) regexp = sub_directories.map do |sub_dir| sub_dir.split('*', -1) .map {|p| Regexp.escape(p)} .join('[^/]*') end.join('(/[^/]*)*') @regexp = Regexp.new("^#{regexp}$") end def match?(url) !@regexp.match(url).nil? end end end
Version data entries
35 entries across 35 versions & 1 rubygems