Add support for CPAN
This commit is contained in:
parent
3dce06ca21
commit
2431922619
|
@ -159,6 +159,13 @@ Check `RubyGems <https://rubygems.org/>`_ for updates.
|
|||
gems
|
||||
The name used on RubyGems, e.g. ``sass``.
|
||||
|
||||
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`_.
|
||||
|
|
|
@ -5,6 +5,7 @@ logger = logging.getLogger(__name__)
|
|||
handler_precedence = (
|
||||
'github', 'gitcafe', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
|
||||
'cmd', 'bitbucket', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs',
|
||||
'cpan',
|
||||
)
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue