commandbox.system.util

Class Watcher

lucee.Component
    extended by commandbox.system.util.Watcher

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I am a watcher that will run code any time files in a directory change. I am intended to be used as a transient. Create a new instance of me for each watch operation. getInstance( 'watcher' ) .paths( '**.cfc' ) .inDirectory( getCWD() ) .onChange( function( changeData ) { // changeData.added // changeData.removed // changeData.changed command( 'testbox run' ) .run(); } ) .start();

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    string baseDirectory


    • access = public
    • returntype = any
    true false
    struct changeData


    • access = public
    • returntype = any
    true false
    string changeHash


    • access = public
    • returntype = any
    true false
    function changeUDF


    • access = public
    • returntype = any
    true false
    commandbox.system.util.number delayMS


    • access = public
    • returntype = any
    true false
    struct fileIndex


    • access = public
    • returntype = any
    true false
    any fileSeparator


    • access = public
    • returntype = any
    • inject = fileSeparator@constants
    true false
    any fileSystemUtil


    • access = public
    • returntype = any
    • inject = FileSystem
    true false
    any pathPatternMatcher


    • access = public
    • returntype = any
    • inject = provider:pathPatternMatcher@globber
    true false
    array pathsToWatch


    • access = public
    • returntype = any
    true false
    any print


    • access = public
    • returntype = any
    • inject = PrintBuffer
    true false
    any shell


    • access = public
    • returntype = any
    • inject = shell
    true false
    boolean watcherRun


    • access = public
    • returntype = any
    true false
    Method Summary
    private any calculateHashes()
    private any changeDetected()
    string getBaseDirectory()
    string getChangeData()
    string getChangeHash()
    string getChangeUDF()
    string getDelayMS()
    string getFileIndex()
    string getFileSeparator()
    string getFileSystemUtil()
    string getPathPatternMatcher()
    string getPathsToWatch()
    string getPrint()
    string getShell()
    string getWatcherRun()
    any inDirectory([any baseDirectory])
         Pass in the base directory that the globbing patterns are relative to.
    any onChange([any changeUDF])
         Pass in a UDF refernce to be executed when the watcher senses a chnage on the file system.
    any onDIComplete()
    any paths()
         Pass in an array of file globbing paths or any numberof string globbing arguments.
    any setBaseDirectory(string baseDirectory)
    any setChangeData(struct changeData)
    any setChangeHash(string changeHash)
    any setChangeUDF(function changeUDF)
    any setDelayMS(commandbox.system.util.number delayMS)
    any setFileIndex(struct fileIndex)
    any setFileSeparator(any fileSeparator)
    any setFileSystemUtil(any fileSystemUtil)
    any setPathPatternMatcher(any pathPatternMatcher)
    any setPathsToWatch(array pathsToWatch)
    any setPrint(any print)
    any setShell(any shell)
    any setWatcherRun(boolean watcherRun)
    any start()
         Call to start the watcher.
    any withDelay([any delayMS])
         Pass in the number of miliseconds to wait between polls.
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    baseDirectory

    property string baseDirectory

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    changeData

    property struct changeData

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    changeHash

    property string changeHash

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    changeUDF

    property function changeUDF

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    delayMS

    property commandbox.system.util.number delayMS

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    fileIndex

    property struct fileIndex

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    fileSeparator

    property any fileSeparator

    Attributes:
    access - public
    required - false
    returntype - any
    inject - fileSeparator@constants
    serializable - true

    fileSystemUtil

    property any fileSystemUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - FileSystem
    serializable - true

    pathPatternMatcher

    property any pathPatternMatcher

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:pathPatternMatcher@globber
    serializable - true

    pathsToWatch

    property array pathsToWatch

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    print

    property any print

    Attributes:
    access - public
    required - false
    returntype - any
    inject - PrintBuffer
    serializable - true

    shell

    property any shell

    Attributes:
    access - public
    required - false
    returntype - any
    inject - shell
    serializable - true

    watcherRun

    property boolean watcherRun

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    Method Detail

    calculateHashes

    private any calculateHashes()


    changeDetected

    private any changeDetected()


    getBaseDirectory

    public string getBaseDirectory()


    getChangeData

    public string getChangeData()


    getChangeHash

    public string getChangeHash()


    getChangeUDF

    public string getChangeUDF()


    getDelayMS

    public string getDelayMS()


    getFileIndex

    public string getFileIndex()


    getFileSeparator

    public string getFileSeparator()


    getFileSystemUtil

    public string getFileSystemUtil()


    getPathPatternMatcher

    public string getPathPatternMatcher()


    getPathsToWatch

    public string getPathsToWatch()


    getPrint

    public string getPrint()


    getShell

    public string getShell()


    getWatcherRun

    public string getWatcherRun()


    inDirectory

    public any inDirectory([any baseDirectory])

    Pass in the base directory that the globbing patterns are relative to

    Parameters:
    baseDirectory

    onChange

    public any onChange([any changeUDF])

    Pass in a UDF refernce to be executed when the watcher senses a chnage on the file system

    Parameters:
    changeUDF

    onDIComplete

    public any onDIComplete()


    paths

    public any paths()

    Pass in an array of file globbing paths or any numberof string globbing arguments.


    setBaseDirectory

    public any setBaseDirectory(string baseDirectory)

    Parameters:
    baseDirectory

    setChangeData

    public any setChangeData(struct changeData)

    Parameters:
    changeData

    setChangeHash

    public any setChangeHash(string changeHash)

    Parameters:
    changeHash

    setChangeUDF

    public any setChangeUDF(function changeUDF)

    Parameters:
    changeUDF

    setDelayMS

    public any setDelayMS(commandbox.system.util.number delayMS)

    Parameters:
    delayMS

    setFileIndex

    public any setFileIndex(struct fileIndex)

    Parameters:
    fileIndex

    setFileSeparator

    public any setFileSeparator(any fileSeparator)

    Parameters:
    fileSeparator

    setFileSystemUtil

    public any setFileSystemUtil(any fileSystemUtil)

    Parameters:
    fileSystemUtil

    setPathPatternMatcher

    public any setPathPatternMatcher(any pathPatternMatcher)

    Parameters:
    pathPatternMatcher

    setPathsToWatch

    public any setPathsToWatch(array pathsToWatch)

    Parameters:
    pathsToWatch

    setPrint

    public any setPrint(any print)

    Parameters:
    print

    setShell

    public any setShell(any shell)

    Parameters:
    shell

    setWatcherRun

    public any setWatcherRun(boolean watcherRun)

    Parameters:
    watcherRun

    start

    public any start()

    Call to start the watcher. This method will block until the user ends it with Ctrl+C


    withDelay

    public any withDelay([any delayMS])

    Pass in the number of miliseconds to wait between polls

    Parameters:
    delayMS