Code Monkey home page Code Monkey logo

fssm's Introduction

Monitor API

There are three ways you can run the monitor.

  1. call monitor with a path parameter, and define callbacks in a block
  2. call monitor with a block to configure multiple paths and callbacks
  3. create a monitor object and run each step manually

Monitor with path

This form watches one path, and enters the run loop automatically. The first parameter is the path to watch, and the second parameter is an optional glob pattern or array of glob patterns that a file must match in order to trigger a callback. The default glob, if ommitted, is '**/*'.

FSSM.monitor('/some/directory/', '**/*') do
  update {|base, relative|}
  delete {|base, relative|}
  create {|base, relative|}
end

Monitor with block

This form watches one or more paths, and enters the run loop automatically. The glob configuration call can be ommitted, and defaults to '**/*'.

FSSM.monitor do
  path '/some/directory/' do
    glob '**/*.yml'

    update {|base, relative|}
    delete {|base, relative|}
    create {|base, relative|}
  end

  path '/some/other/directory/' do
    update {|base, relative|}
    delete {|base, relative|}
    create {|base, relative|}
  end
end

Monitor object

This form doesn't enter the run loop automatically.

monitor = FSSM::Monitor.new

monitor.path '/some/directory/' do
  update {|base, relative|}
  delete {|base, relative|}
  create {|base, relative|}
end

monitor.run

fssm's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.