add support for RubyGems

This commit is contained in:
lilydjwg 2014-09-29 16:38:44 +08:00
parent b258adfc13
commit 2c3ba193e3
3 changed files with 25 additions and 1 deletions

View File

@ -122,6 +122,13 @@ Check `PyPI <https://pypi.python.org/>`_ for updates.
pypi
The name used on PyPI, e.g. ``PySide``.
Check RubyGems
--------------
Check `RubyGems <https://rubygems.org/>`_ for updates.
gems
The name used on RubyGems, e.g. ``sass``.
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 <https://wiki.archlinux.org/index.php/Pacman>`_.

View File

@ -3,7 +3,7 @@ from importlib import import_module
logger = logging.getLogger(__name__)
handler_precedence = (
'github', 'aur', 'pypi', 'archpkg', 'pacman',
'github', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
'cmd', 'gcode_hg', 'regex', 'manual',
)

17
nvchecker/source/gems.py Normal file
View File

@ -0,0 +1,17 @@
import json
from functools import partial
from tornado.httpclient import AsyncHTTPClient
GEMS_URL = 'https://rubygems.org/api/v1/versions/%s.json'
def get_version(name, conf, callback):
repo = conf.get('gems') or name
url = GEMS_URL % repo
AsyncHTTPClient().fetch(url, user_agent='lilydjwg/nvchecker',
callback=partial(_gems_done, name, callback))
def _gems_done(name, callback, res):
data = json.loads(res.body.decode('utf-8'))
version = data[0]['number']
callback(name, version)