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

This commit is contained in:
lilydjwg 2015-11-04 18:23:04 +08:00
commit 03e77aa1af
3 changed files with 26 additions and 1 deletions

View File

@ -173,6 +173,13 @@ Check `Hackage <https://hackage.haskell.org/>`_ for updates.
hackage
The name used on Hackage, e.g. ``pandoc``.
Check CPAN
--------------
Check `MetaCPAN <https://metacpan.org/>`_ for updates.
cpan
The name used on CPAN, e.g. ``YAML``.
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', 'hackage',
'npm', 'hackage', 'cpan',
)
def get_version(name, conf, callback):

18
nvchecker/source/cpan.py Normal file
View File

@ -0,0 +1,18 @@
import json
from functools import partial
from tornado.httpclient import AsyncHTTPClient
# Using metacpan
CPAN_URL = 'https://api.metacpan.org/release/%s'
def get_version(name, conf, callback):
repo = conf.get('cpan') or name
url = CPAN_URL % repo
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
callback=partial(_cpan_done, name, callback))
def _cpan_done(name, callback, res):
data = json.loads(res.body.decode('utf-8'))
version = data['version']
callback(name, version)