Sha256: 9a0d13710c526e6e6b54afb357dc20762f90e6bda9fb8ae983bb4e70c3c29ab2
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
# Copyright 2008-2011 Red Hat, Inc, and individual contributors. # # This is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of # the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this software; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA, or see the FSF site: http://www.fsf.org. require 'torquebox/vfs/glob_translator' module TorqueBox module VFS class GlobFilter include Java::org.jboss.vfs.VirtualFileFilter def initialize(child_path, glob, dirs_only) regexp_str = GlobTranslator.translate( glob ) if ( child_path && child_path != '' ) if ( child_path[-1,1] == '/' ) regexp_str = "^#{child_path}#{regexp_str}$" else regexp_str = "^#{child_path}/#{regexp_str}$" end else regexp_str = "^#{regexp_str}$" end @regexp = Regexp.new( regexp_str ) @dirs_only = dirs_only # puts "glob #{glob} ==> #{@regexp}" end def accepts(file) matched = !!( file.path_name =~ @regexp ) matched &&= file.directory? if @dirs_only matched end def to_s "#{@regexp}, dirs_only: #{@dirs_only}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
torquebox-vfs-1.0.1-java | lib/torquebox/vfs/glob_filter.rb |
torquebox-vfs-1.0.0-java | lib/torquebox/vfs/glob_filter.rb |