Sha256: 3f2306b213f0687797687ae78894443f406da873c1baab6cfe6ad5b30aad8854
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
require 'bukin/utils' require 'json' require 'cgi' # BukGet api # Docs: http://bukget.org/pages/docs/API3.html class Bukin::Bukget attr_reader :url def initialize(url = 'http://api.bukget.org') @url = url end def api_url "#{url}/3" end def resolve_info(data) return data if data[:download] name = data[:name] version = data[:version] || 'latest' server = data[:server] server = 'bukkit' if server == 'craftbukkit' url = "#{api_url}/plugins/#{CGI.escape(server)}/#{CGI.escape(name)}/#{CGI.escape(version)}" info = JSON.parse(open(url).read) versions = info['versions'] if versions.empty? raise Bukin::InstallError, "The plugin #{name} (#{version}) has no available downloads from BukGet." end version_data = versions.find {|version_data| jar_extension?(version_data)} if version_data data[:version] = version_data['version'] data[:download] = version_data['download'] else data[:version] = versions.first['version'] data[:download] = versions.first['download'] end data end def jar_extension?(version_data) File.extname(version_data['filename']) == '.jar' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bukin-0.5.0 | lib/bukin/providers/bukget.rb |
bukin-0.4.0 | lib/bukin/providers/bukget.rb |