Merge remote-tracking branch 'origin/pr/17'

This commit is contained in:
lilydjwg 2015-11-04 18:21:26 +08:00
commit 0cd587c6ba
3 changed files with 25 additions and 1 deletions

View file

@ -166,6 +166,13 @@ Check `NPM Registry <https://registry.npmjs.org/>`_ for updates.
npm
The name used on NPM Registry, e.g. ``coffee-script``.
Check Hackage
----------
Check `Hackage <https://hackage.haskell.org/>`_ for updates.
hackage
The name used on Hackage, e.g. ``pandoc``.
Check Local Pacman Database
---------------------------
This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_.

View file

@ -5,7 +5,7 @@ logger = logging.getLogger(__name__)
handler_precedence = (
'github', 'gitcafe', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
'cmd', 'bitbucket', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs',
'npm',
'npm', 'hackage',
)
def get_version(name, conf, callback):

View file

@ -0,0 +1,17 @@
import json
from functools import partial
from tornado.httpclient import AsyncHTTPClient
HACKAGE_URL = 'https://hackage.haskell.org/package/%s/preferred.json'
def get_version(name, conf, callback):
repo = conf.get('hackage') or name
url = HACKAGE_URL % repo
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
callback=partial(_hackage_done, name, callback))
def _hackage_done(name, callback, res):
data = json.loads(res.body.decode('utf-8'))
version = data['normal-version'][0]
callback(name, version)