Sha256: a30666b4ef122cdf9609d9ac9e234cc4f2e545c0bf60375b052176be1bf95bf9

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

require 'bukin/utils'
require 'json'

# Bukkit download api
# Docs: http://dl.bukkit.org/about/
class Bukin::BukkitDl
  attr_reader :url

  def initialize(url = 'http://dl.bukkit.org')
    @url = url
  end

  def api_url
    "#{url}/api/1.0/downloads"
  end

  def resolve_info(data)
    if data[:download]
      data[:display_version] = data[:version]
      return data
    end

    name = data[:name]
    version = data[:version] || 'latest-rb'

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

    data[:version] = "build-#{info['build_number']}"
    data[:display_version] = info['version']
    data[:download] = @url + info['file']['url']
    data
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bukin-0.4.0 lib/bukin/providers/bukkit_dl.rb
bukin-0.3.0 lib/bukin/providers/bukkit_dl.rb