testbox.system.coverage.data

Class PathPatternMatcher

lucee.Component
    extended by testbox.system.coverage.data.PathPatternMatcher

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I am a utility to match file system path patterns End a pattern with a slash to only match a directory. Start a pattern with a slash to start in the root. Ex: - foo will match any file or folder in the directory tree - /foo will only match a file or folder in the root - foo/ will only match a directory anywhere in the directory tree - /foo/ will only match a folder in the root Use a single * to match zero or more characters INSIDE a file or folder name (won't match a slash) Ex: - foo* will match any file or folder starting with "foo" - foo*.txt will match any file or folder starting with "foo" and ending with .txt - *foo will match any file or folder ending with "foo" - a/* /z will match a/b/z but not a/b/c/z Use a double ** to match zero or more characters including slashes. This allows a pattern to span directories Ex: - a/** /z will match a/z and a/b/z and a/b/c/z

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Constructor Summary
    init()
    Method Summary
    boolean matchPattern(string pattern, string path)
         Match a single path to a single pattern.
    boolean matchPatterns(array patterns, string path)
         Match an array of patterns against a single path.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()


    Method Detail

    matchPattern

    public boolean matchPattern(string pattern, string path)

    Match a single path to a single pattern. Returns true if the path matches the pattern, otherwise false.

    Parameters:
    pattern - The pattern to match against the path
    path - The file system path to test. Can be a file or directory. Direcories MUST end with a trailing slash

    matchPatterns

    public boolean matchPatterns(array patterns, string path)

    Match an array of patterns against a single path. Returns true if at least one pattern matches, otherwise false.

    Parameters:
    patterns - An array of patterns to match against the path
    path - The file system path to test. Can be a file or directory. Direcories MUST end with a trailing slash