UK Petition poller
Polls a given petition on https://petition.parliament.uk
for the current signature count. It reads the signature count every 60 seconds.
Made during what you might describe as a one person hackathon on a Thursday.
Building
/uk-petition-poller <master> % yarn install/uk-petition-poller <master> % yarn build
Unit tests
The unit tests use Jest via the Yarn test
command like so:
/uk-petition-poller ‹master*› % yarn test
The example script
Run the example like so:
git clone https://github.com/spacekitcat/uk-petition-pollercd uk-petition-poller/uk-petition-poller <master> % yarn install/uk-petition-poller <master> % yarn build/uk-petition-poller <master> % node sample.js☆ SIGNATURES 3047041 :: UPDATE SUCCESS true :: LAST UPDATE 12:44★ SIGNATURES 3047041 :: UPDATE SUCCESS true :: LAST UPDATE 12:45
Adding to your project
First, add the dependency to your project like so:
/your-rad-project ‹master*› % yarn add uk-petition-poller
And then you just use the library like the example below (use import syntax if you have Babel configured for it). I was experimenting with a little bit of ascii animation, so it's a little messy and complex, but I think it's clear enough to illustrate how to use this library.
const PetitionTracker = ;var Spinner = Spinner; var spinner = '%s';spinner;spinner;spinner;spinnerstart; const petitionTracker = ; const generateStatusString = signatureCount lastUpdateSuccess lastUpdate let separator = Buffer; let lastUpdateDate = lastUpdate; let updatedStatus = Buffer; return updatedStatus;; petitionTracker; petitionTrackerstart'241584';