Skip to content

Commit

Permalink
微修正,readme修正
Browse files Browse the repository at this point in the history
  • Loading branch information
nikezono committed Jul 22, 2014
1 parent 1c3fa2b commit ca173c5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
36 changes: 23 additions & 13 deletions README.md
Expand Up @@ -29,34 +29,46 @@ rss-watcher [![Build Status](https://travis-ci.org/nikezono/node-rss-watcher.png

watcher = new Watcher(feed)

# it is optional
watcher.on 'new article',(article)->
console.log article

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


### option

watcher = new Watcher(feed)
watcher.set
feed:feed # feed url
interval: 10000 # milliseconds. default:avarage update frequency
interval: # request per interval seconds. default:avarage update frequency

### functional option

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

# run
watcher.run()

# exposed event while running
### exposed events

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

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

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

watcher.stop()

## CLI tool

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

then,
### Image

![gyazo](http://gyazo.com/35357bf10711857403eaa7abe6b70037.png)

Expand All @@ -65,13 +77,11 @@ then,

Spec Report:

npm test
npm -i -g grunt grunt-cli
grunt test

Coverage dump:

npm run-script test-cover
grunt coverage
open coverage.html

Coverage report to Coveralls:

npm run-script test-coveralls
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rss-watcher",
"version": "1.0.8",
"version": "1.2.0",
"description": "RSS reader/watcher",
"main": "lib/watcher.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/watcher.coffee
Expand Up @@ -30,7 +30,7 @@ class Watcher extends EventEmitter

return setInterval ->
fetch(@feedUrl)
,@interval
,@interval*1000


set:(obj)->
Expand All @@ -49,7 +49,7 @@ class Watcher extends EventEmitter
initialize = (callback)=>
request @feedUrl,(err,articles)=>
return callback new Error(err),null if err? and callback?
@lastPubDate = articles[articles.length-1].pubDate
@lastPubDate = articles[articles.length-1].pubDate / 1000
@timer = @watch()
return callback null,articles if callback?

Expand Down

0 comments on commit ca173c5

Please sign in to comment.