Skip to content

Latest commit

 

History

History
87 lines (53 loc) · 1.67 KB

README.md

File metadata and controls

87 lines (53 loc) · 1.67 KB

rss-watcher Build StatusCoverage Status

NPM

What is it

RSS-Watcher is Small Library for RSS/Atom Feed Reader

##install

####NPM INSTALL:

npm install rss-watcher

####package.json:

{
  "dependencies":{
    "rss-watcher": "*"
  }
}

Usage

Watcher = require 'rss-watcher'
feed = 'http://github.com/nikezono.atom'

watcher = new Watcher(feed)

watcher.on 'new article',(article)->
  console.log article

watcher.run (err,articles)->
  console.error err if err
  console.log articles # current articles

option

watcher = new Watcher(feed)
watcher.set
  feed:feed # feed url
  interval: 60  # request per interval seconds. default:average update frequency

functional option

watcher.set
  interval: (average)->
    return 60 * 3 if average < 60 * 3 # ex:Throttle HTTP Access

exposed events

watcher.on "error",(error)->
  console.error error

watcher.on "new article",(article)->
  console.log article # article object

watcher.on "stop", ->
  console.log 'stop'

watcher.stop()

CLI tool

> rss-watcher 'http://github.com/nikezono.atom' -i 20000 # 20000s interval

Image

gyazo

Test

Spec Report:

npm -i -g grunt grunt-cli
grunt test

Coverage dump:

grunt coverage
open coverage.html