Sha256: 894a09e2cb194489f461f6fc833d131740d0f70e62ffef836ac6c690f63df2f7

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

require 'json'

# Bukkit download api
# Docs: http://dl.bukkit.org/about/
class Bukin::BukkitDl
  DEFAULT_URL = 'http://dl.bukkit.org'
  attr_reader :data

  def initialize(data)
    @data = data
  end

  def resolve_info
    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[:download] = data[:bukkit_dl] + info['file']['url']
    data
  end

private
  def api_url
    "#{data[:bukkit_dl]}/api/1.0/downloads"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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