Class: Lapis::Minecraft::Versioning::MetaServer

Inherits:
Object
  • Object
show all
Defined in:
lib/lapis/minecraft/versioning/meta_server.rb

Overview

TODO:

Add more checks to response data.

Provides functionality for translating version information from a meta-data server. A meta-data server is a server that responds to requests about Minecraft versions.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ MetaServer

Creates a reference to a Minecraft meta-data server.


14
15
16
17
18
19
# File 'lib/lapis/minecraft/versioning/meta_server.rb', line 14

def initialize(client)
  @client = client
  @manifest_parser    = Marshalling::ManifestParser.new
  @version_parser     = Marshalling::VersionParser.new
  @asset_index_parser = Marshalling::AssetIndexParser.new
end

Instance Method Details

#get_assets(url) ⇒ Array<Asset>

Retrieves a listing of assets for a Minecraft version.


42
43
44
45
46
# File 'lib/lapis/minecraft/versioning/meta_server.rb', line 42

def get_assets(url)
  response = @client.get(url)
  fail "Failed to retrieve assets - #{response.status} (#{response.reason})" if response.status != 200
  @asset_index_parser.parse(response.content)
end

#get_details(url) ⇒ Detailed

Retrieves additional information about a Minecraft version.


33
34
35
36
37
# File 'lib/lapis/minecraft/versioning/meta_server.rb', line 33

def get_details(url)
  response = @client.get(url)
  fail "Failed to retrieve version - #{response.status} (#{response.reason})" if response.status != 200
  @version_parser.parse(response.content, url)
end

#get_manifest(url) ⇒ Manifest

Retrieves the manifest from the meta-data server.


24
25
26
27
28
# File 'lib/lapis/minecraft/versioning/meta_server.rb', line 24

def get_manifest(url)
  response = @client.get(url)
  fail "Failed to retrieve manifest - #{response.status} (#{response.reason})" if response.status != 200
  @manifest_parser.parse(response.content)
end