Sha256: 82e74bf5ad941fb6ad5e1d99d2ef1602aa4761cb8ea85a9d9a0b07d4e0227b4d

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require 'bukin/utils'
require 'json'

# Base url used for bukkit downloads
BUKKIT_DL_BASE = "http://dl.bukkit.org"

# Bukkit download api
# Docs: http://dl.bukkit.org/about/
BUKKIT_DL_API = "#{BUKKIT_DL_BASE}/api/1.0/downloads"


class Bukin::BukkitDl
    attr_accessor :api_url

    def initialize(url = BUKKIT_DL_API)
        @api_url = url
    end

    def download(name, version)
        url = BUKKIT_DL_BASE + info(name, version)['file']['url']
        download_file(url)
    end

    def info(name, version)
        url = "#{@api_url}/projects/#{name}/view/#{version}/"
        JSON.parse(open(url).read)
    end

    def resolve_build(name, version)
        "build-#{info(name, version)['build_number']}"
    end

    def resolve_version(name, version)
        info(name, version)['version']
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bukin-0.1.0 lib/bukin/providers/bukkit_dl.rb