npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hubot-cron-events

v1.0.1

Published

A hubot plugin to perform generic event emission scheduled using cron job.

Downloads

10

Readme

Hubot Cron Events Plugin

Version Downloads Build Status Dependency Status Coverage Status NPM

This plugin is a generic event emitter scheduled using cron job. It's very similar to hubot-cron, but instead of sending messages it emits events.

This plugin can be very handy when combined with other plugins that will receive the emitted events.

There is another similar plugin named hubot-at-events that applies the same principle for one-time actions at given dates.

Installation

In your hubot directory:

npm install hubot-cron-events --save

Then add hubot-cron-events to external-scripts.json

Configuration

If you use hubot-auth, the cron configuration commands will be restricted to user with the admin role. You can add a custom group, by setting the following env variable : HUBOT_CRON_AUTH_GROUP

But if hubot-auth is not loaded, all users can access those commands.

It's also advised to use a brain persistence plugin, whatever it is, to persist the cron jobs between restarts.

Commands

Commands prefixed by .cron are here taking in account we use the . as hubot prefix, just replace it with your prefix if it is different.

.cron version
    gives the version of the hubot-cron-events package loaded

.cron <name> <period> <eventname>
.cron <name> <period> <eventname> <tz>
.cron <name> <period> <eventname> [<tz>] with param1=value1
.cron <name> <period> <eventname> [<tz>] with param1=value1 param2=value2
.cron <name> <period> <eventname> [<tz>] with param1=long value with spaces param2=value2
    will create or update a job with unique identifier <name>
    the <period> has to match a valid cronjob syntax of type * * * * *
    if 6 items are provided (ie. * * * * * *), the first one will be the seconds
    the optional <tz> will be applied if provided
    if no eventname is provided, the job will not emit anything

    This also can be used to modify an existing job.
    If the tz and data are omitted they will not be changed

    Data params can be provided if you add 'with' and a list
    of attributions. There is a drawback, which is that in the
    current implementation, the values can't contain an equal sign ('=')

    example:
    .cron blah */5 * * * * * cron.message
        will emit a cron.message every 5 seconds
        that event requires 2 data params, room and message:
        .cron blah room = shell
        .cron blah message = tick tack
    or
    .cron blah */5 * * * * * cron.message with room=shell message=tick tack
    .cron start blah
        activates the job, which will run every 5 seconds
    .cron blah * * * * * 
        modifies the job blah to run every minutes instead
        and it will emit the same event cron.message
        and it will keep the already set data
        note that modifying a job stops it, 
        so it has to be restarted afterward
    .cron start blah
        now the job is active and will run every minute

.cron status <name>
    tells if the job is running or paused

.cron info <name>
.cron show <name>
    gives the details about a job

.cron list [<term>]
    lists all the jobs, or only the jobs with names matching <term>

.cron stop <name>
.cron pause <name>
    stops the job <name>

.cron start <name>
.cron resume <name>
    starts the job <name>

.cron delete <name>
    delete the job <name>

.cron <name> <key> = <value>
    sets a key-value pair in the job data
    if the key already exists, its value will be changed
    if you change the data for job that is currently running
    it will be stopped and restarted 

.cron <name> drop <key>
    removes a key-value pair form the job data
    this will also restart the job if it's running

Some events receivers are also provided for testing purposes:

cron.message
    requires data:
    - room
    - message
    it will just say the message in the given room

cron.date
    requires data:
    - room
    it will tell the date on the room

Testing

npm install

# will run make test and coffeelint
npm test 

# or
make test

# or, for watch-mode
make test-w

# or for more documentation-style output
make test-spec

# and to generate coverage
make test-cov

# and to run the lint
make lint

# run the lint and the coverage
make

Changelog

All changes are listed in the CHANGELOG

Contribute

Feel free to open a PR if you find any bug, typo, want to improve documentation, or think about a new feature.

Gandi loves Free and Open Source Software. This project is used internally at Gandi but external contributions are very welcome.

Authors

  • @mose - author and maintainer

License

This source code is available under MIT license.

Copyright

Copyright (c) 2016 - Gandi - https://gandi.net