lapis-minecraft-versioning 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.codeclimate.yml +18 -0
- data/.gitignore +151 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.md +16 -0
- data/README.md +83 -0
- data/Rakefile +28 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lapis-minecraft-versioning.gemspec +35 -0
- data/lib/lapis/minecraft/version.rb +89 -0
- data/lib/lapis/minecraft/versioning.rb +26 -0
- data/lib/lapis/minecraft/versioning/asset.rb +44 -0
- data/lib/lapis/minecraft/versioning/asset_index.rb +61 -0
- data/lib/lapis/minecraft/versioning/basic.rb +56 -0
- data/lib/lapis/minecraft/versioning/detailed.rb +69 -0
- data/lib/lapis/minecraft/versioning/launcher_properties.rb +48 -0
- data/lib/lapis/minecraft/versioning/library.rb +51 -0
- data/lib/lapis/minecraft/versioning/manifest.rb +49 -0
- data/lib/lapis/minecraft/versioning/marshalling.rb +15 -0
- data/lib/lapis/minecraft/versioning/marshalling/asset_index_parser.rb +41 -0
- data/lib/lapis/minecraft/versioning/marshalling/manifest_parser.rb +66 -0
- data/lib/lapis/minecraft/versioning/marshalling/version_parser.rb +204 -0
- data/lib/lapis/minecraft/versioning/meta_server.rb +52 -0
- data/lib/lapis/minecraft/versioning/os_rule.rb +45 -0
- data/lib/lapis/minecraft/versioning/resource.rb +44 -0
- data/lib/lapis/minecraft/versioning/resource_set.rb +61 -0
- data/lib/lapis/minecraft/versioning/rule.rb +32 -0
- data/lib/lapis/minecraft/versioning/version.rb +7 -0
- data/lib/lapis/minecraft/versioning/version_list.rb +64 -0
- data/spec/factories/asset_factory.rb +11 -0
- data/spec/factories/asset_index_document_factory.rb +25 -0
- data/spec/factories/asset_index_factory.rb +15 -0
- data/spec/factories/basic_factory.rb +28 -0
- data/spec/factories/detailed_factory.rb +16 -0
- data/spec/factories/launcher_properties_factory.rb +11 -0
- data/spec/factories/library_factory.rb +21 -0
- data/spec/factories/manifest_document_factory.rb +48 -0
- data/spec/factories/manifest_factory.rb +12 -0
- data/spec/factories/meta_server_mock_factory.rb +33 -0
- data/spec/factories/os_rule_factory.rb +30 -0
- data/spec/factories/resource_factory.rb +32 -0
- data/spec/factories/resource_set_factory.rb +16 -0
- data/spec/factories/rule_factory.rb +17 -0
- data/spec/factories/version_document_factory.rb +176 -0
- data/spec/factories/version_factory.rb +18 -0
- data/spec/lapis/minecraft/version_spec.rb +181 -0
- data/spec/lapis/minecraft/versioning/asset_index_spec.rb +89 -0
- data/spec/lapis/minecraft/versioning/asset_spec.rb +65 -0
- data/spec/lapis/minecraft/versioning/basic_spec.rb +75 -0
- data/spec/lapis/minecraft/versioning/detailed_spec.rb +175 -0
- data/spec/lapis/minecraft/versioning/launcher_properties_spec.rb +73 -0
- data/spec/lapis/minecraft/versioning/library_spec.rb +91 -0
- data/spec/lapis/minecraft/versioning/manifest_spec.rb +71 -0
- data/spec/lapis/minecraft/versioning/marshalling/asset_index_parser_spec.rb +27 -0
- data/spec/lapis/minecraft/versioning/marshalling/manifest_parser_spec.rb +74 -0
- data/spec/lapis/minecraft/versioning/marshalling/version_parser_spec.rb +101 -0
- data/spec/lapis/minecraft/versioning/meta_server_spec.rb +59 -0
- data/spec/lapis/minecraft/versioning/os_rule_spec.rb +73 -0
- data/spec/lapis/minecraft/versioning/resource_set_spec.rb +87 -0
- data/spec/lapis/minecraft/versioning/resource_spec.rb +55 -0
- data/spec/lapis/minecraft/versioning/rule_spec.rb +36 -0
- data/spec/lapis/minecraft/versioning/version_list_spec.rb +66 -0
- data/spec/spec_helper.rb +90 -0
- data/spec/time_helper.rb +39 -0
- metadata +289 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
=====================
|
3
|
+
|
4
|
+
*Copyright (c) 2016 Lapis MC*
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
7
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
8
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
9
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
Minecraft Version Info
|
2
|
+
======================
|
3
|
+
|
4
|
+
[](https://travis-ci.org/lapis-mc/minecraft-versioning)
|
5
|
+
[](https://codeclimate.com/github/lapis-mc/minecraft-versioning)
|
6
|
+
[](https://codeclimate.com/github/lapis-mc/minecraft-versioning/coverage)
|
7
|
+
[](https://codeclimate.com/github/lapis-mc/minecraft-versioning)
|
8
|
+
|
9
|
+
Retrieves and processes information about versions of Minecraft.
|
10
|
+
Small library for getting version information from Mojang about Minecraft.
|
11
|
+
Includes a command-line utility as well.
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'lapis-minecraft-versioning'
|
20
|
+
```
|
21
|
+
|
22
|
+
Or to your gemspec:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
spec.add_dependency 'lapis-minecraft-versioning'
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install lapis-minecraft-versioning
|
35
|
+
|
36
|
+
Usage
|
37
|
+
-----
|
38
|
+
|
39
|
+
Include the gem by adding this to your scripts:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'lapis/minecraft/versioning'
|
43
|
+
```
|
44
|
+
|
45
|
+
### Accessing Minecraft version data
|
46
|
+
|
47
|
+
Retrieve the official Minecraft version list:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
list = Lapis::Minecraft::Versioning::VersionList.official
|
51
|
+
```
|
52
|
+
|
53
|
+
Display a list of all versions:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
list.each do |version|
|
57
|
+
puts version.id
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Get the client URL for the latest release:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
list.latest_release.client_download.url
|
65
|
+
```
|
66
|
+
|
67
|
+
Development
|
68
|
+
-----------
|
69
|
+
|
70
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
71
|
+
Then, run `bundle exec rake test` to run the tests.
|
72
|
+
It's recommended that you run `bundle exec rake inspect` to run inspections.
|
73
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
74
|
+
`bundle exec rake doc` will generate documentation.
|
75
|
+
|
76
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
77
|
+
To release a new version, update the version number in `versioning/version.rb`, and then run `bundle exec rake release`.
|
78
|
+
This will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
79
|
+
|
80
|
+
Contributing
|
81
|
+
------------
|
82
|
+
|
83
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/lapis-mc/minecraft-versioning).
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'reek/rake/task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require 'rubocop'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'yard'
|
7
|
+
|
8
|
+
task :default => [:build, :test]
|
9
|
+
task :inspect => [:reek, :rubocop]
|
10
|
+
|
11
|
+
RSpec::Core::RakeTask.new(:spec)
|
12
|
+
task :test => :spec
|
13
|
+
|
14
|
+
Reek::Rake::Task.new do |task| # :reek
|
15
|
+
task.name = :reek
|
16
|
+
task.source_files = 'lib/**/*.rb'
|
17
|
+
task.fail_on_error = false
|
18
|
+
end
|
19
|
+
|
20
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
21
|
+
task.patterns = ['lib/**/*.rb']
|
22
|
+
task.fail_on_error = false
|
23
|
+
end
|
24
|
+
|
25
|
+
YARD::Rake::YardocTask.new do |task| # :yard
|
26
|
+
task.files = %w(lib/**/*.rb - *.md)
|
27
|
+
end
|
28
|
+
task :doc => :yard
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'lapis/minecraft/versioning'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lapis/minecraft/versioning/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'lapis-minecraft-versioning'
|
8
|
+
spec.version = Lapis::Minecraft::Versioning::VERSION
|
9
|
+
spec.authors = ['Michael Miller']
|
10
|
+
spec.email = ['bluepixelmike@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Retrieves and processes information about versions of Minecraft.}
|
13
|
+
spec.description = %q{Small library for getting version information from Mojang about Minecraft.
|
14
|
+
Includes a command-line utility as well.}
|
15
|
+
spec.homepage = 'https://github.com/lapis-mc/minecraft-versioning'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/(lapis|minecraft)-}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'httpclient', '~> 2.1'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'factory_girl', '~> 4.0'
|
30
|
+
spec.add_development_dependency 'webmock', '~> 2.0'
|
31
|
+
spec.add_development_dependency 'reek', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.38.0'
|
33
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
34
|
+
spec.add_development_dependency 'yard'
|
35
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative 'versioning/basic'
|
2
|
+
|
3
|
+
module Lapis
|
4
|
+
module Minecraft
|
5
|
+
|
6
|
+
# Complete information about a Minecraft version.
|
7
|
+
# @note This class uses lazy-loading to retrieve additional information only when it is needed.
|
8
|
+
class Version < Versioning::Basic
|
9
|
+
|
10
|
+
# Creates version information.
|
11
|
+
# @param basic_info [Versioning::Basic] Minimal information to extend from.
|
12
|
+
# @param meta_server [Versioning::MetaServer] Connection used to retrieve version information.
|
13
|
+
def initialize(basic_info, meta_server)
|
14
|
+
super(basic_info.id, basic_info.type, basic_info.time, basic_info.url)
|
15
|
+
@meta_server = meta_server
|
16
|
+
end
|
17
|
+
|
18
|
+
# List of assets needed for this version.
|
19
|
+
# @return [Array<Versioning::Asset>] Asset list.
|
20
|
+
def assets
|
21
|
+
@assets ||= @meta_server.get_assets(asset_index.url)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Overview of assets included in this version.
|
25
|
+
# @return [Versioning::AssetIndex] Asset overview.
|
26
|
+
def asset_index
|
27
|
+
details.asset_index
|
28
|
+
end
|
29
|
+
|
30
|
+
# List of downloads available for this version.
|
31
|
+
# @return [Array<Versioning::Resource>] Download list.
|
32
|
+
def downloads
|
33
|
+
details.downloads
|
34
|
+
end
|
35
|
+
|
36
|
+
# Retrieves the client jar information for this version.
|
37
|
+
# @return [Versioning::Resource] Download information for the client.
|
38
|
+
# @return [nil] There is no client for this version.
|
39
|
+
def client_download
|
40
|
+
details.client_download
|
41
|
+
end
|
42
|
+
|
43
|
+
# Retrieves the server jar information for this version.
|
44
|
+
# @return [Versioning::Resource] Download information for the server.
|
45
|
+
# @return [nil] There is no server for this version.
|
46
|
+
def server_download
|
47
|
+
details.server_download
|
48
|
+
end
|
49
|
+
|
50
|
+
# List of libraries needed to run this version.
|
51
|
+
# @return [Array<Versioning::Library>] Library list.
|
52
|
+
def libraries
|
53
|
+
details.libraries
|
54
|
+
end
|
55
|
+
|
56
|
+
# Information about how to start the client in a launcher.
|
57
|
+
# @return [Versioning::LauncherProperties] Client launcher information.
|
58
|
+
def launcher_properties
|
59
|
+
details.launcher_properties
|
60
|
+
end
|
61
|
+
|
62
|
+
# Compares one version to another.
|
63
|
+
# @param other [Version] Version to compare against.
|
64
|
+
# @return [true] The versions are the same.
|
65
|
+
# @return [false] The versions are different.
|
66
|
+
def ==(other)
|
67
|
+
# Ordered by least expensive to most expensive.
|
68
|
+
super(other) &&
|
69
|
+
other.asset_index == asset_index &&
|
70
|
+
other.launcher_properties == launcher_properties &&
|
71
|
+
other.client_download == client_download &&
|
72
|
+
other.server_download == server_download &&
|
73
|
+
other.downloads == downloads &&
|
74
|
+
other.libraries == libraries &&
|
75
|
+
other.assets == assets
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# Retrieves and caches detailed version information.
|
81
|
+
# @return [Versioning::Detailed] Detailed version information.
|
82
|
+
def details
|
83
|
+
@detailed ||= @meta_server.get_details(url)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Lapis
|
2
|
+
module Minecraft
|
3
|
+
|
4
|
+
# Brings in information for Minecraft versions.
|
5
|
+
module Versioning
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative 'versioning/version'
|
12
|
+
require_relative 'versioning/basic'
|
13
|
+
require_relative 'versioning/asset'
|
14
|
+
require_relative 'versioning/asset_index'
|
15
|
+
require_relative 'versioning/resource'
|
16
|
+
require_relative 'versioning/resource_set'
|
17
|
+
require_relative 'versioning/rule'
|
18
|
+
require_relative 'versioning/os_rule'
|
19
|
+
require_relative 'versioning/library'
|
20
|
+
require_relative 'versioning/launcher_properties'
|
21
|
+
require_relative 'versioning/detailed'
|
22
|
+
require_relative 'version'
|
23
|
+
require_relative 'versioning/manifest'
|
24
|
+
require_relative 'versioning/meta_server'
|
25
|
+
require_relative 'versioning/marshalling'
|
26
|
+
require_relative 'versioning/version_list'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Lapis
|
2
|
+
module Minecraft
|
3
|
+
module Versioning
|
4
|
+
|
5
|
+
# Information about a content file needed for the client.
|
6
|
+
class Asset
|
7
|
+
|
8
|
+
# Size of the asset in bytes.
|
9
|
+
# @return [Fixnum]
|
10
|
+
attr_reader :size
|
11
|
+
|
12
|
+
# SHA1 hash of the asset's contents in hexadecimal.
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :sha1
|
15
|
+
|
16
|
+
# Path, relative to the installation directory, to store the asset.
|
17
|
+
# @return [String, nil] Relative path or +nil+ if the asset can be placed anywhere.
|
18
|
+
attr_reader :path
|
19
|
+
|
20
|
+
# Creates information about an asset.
|
21
|
+
# @param size [Fixnum] Size of the asset in bytes.
|
22
|
+
# @param sha1 [String] SHA1 hash of the asset's contents in hexadecimal.
|
23
|
+
# @param path [String, nil] Path, relative to the installation directory, to store the asset.
|
24
|
+
def initialize(size, sha1, path)
|
25
|
+
@size = size
|
26
|
+
@sha1 = sha1.dup.freeze
|
27
|
+
@path = path ? path.dup.freeze : nil
|
28
|
+
end
|
29
|
+
|
30
|
+
# Compares one asset to another.
|
31
|
+
# @param other [Asset] Asset to compare against.
|
32
|
+
# @return [true] The assets are the same.
|
33
|
+
# @return [false] The assets are different.
|
34
|
+
def ==(other)
|
35
|
+
other.size == @size &&
|
36
|
+
other.sha1 == @sha1 &&
|
37
|
+
other.path == @path
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Lapis
|
2
|
+
module Minecraft
|
3
|
+
module Versioning
|
4
|
+
|
5
|
+
# Container for tracking information about assets.
|
6
|
+
# @note This class isn't used directly for accessing asset instances.
|
7
|
+
# It is used for retrieving information about assets.
|
8
|
+
# @see Asset
|
9
|
+
class AssetIndex
|
10
|
+
|
11
|
+
# Unique name of the collection of assets.
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :id
|
14
|
+
|
15
|
+
# SHA1 hash of the asset list document in hexadecimal.
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :sha1
|
18
|
+
|
19
|
+
# Size of the asset list document in bytes.
|
20
|
+
# @return [Fixnum]
|
21
|
+
attr_reader :size
|
22
|
+
|
23
|
+
# Location of where the asset list document can be found.
|
24
|
+
# @return [String]
|
25
|
+
attr_reader :url
|
26
|
+
|
27
|
+
# Total size of all the assets combined.
|
28
|
+
# @return [Fixnum]
|
29
|
+
attr_reader :total_size
|
30
|
+
|
31
|
+
# Creates an asset index.
|
32
|
+
# @param id [String] Unique name of the collection of assets.
|
33
|
+
# @param sha1 [String] SHA1 hash of the asset list document in hexadecimal.
|
34
|
+
# @param size [Fixnum] Size of the asset list document in bytes.
|
35
|
+
# @param url [String] Location of where the asset list document can be found.
|
36
|
+
# @param total_size [Fixnum] Total size of all the assets combined.
|
37
|
+
def initialize(id, sha1, size, url, total_size)
|
38
|
+
@id = id.dup.freeze
|
39
|
+
@sha1 = sha1.dup.freeze
|
40
|
+
@size = size
|
41
|
+
@url = url.dup.freeze
|
42
|
+
@total_size = total_size
|
43
|
+
end
|
44
|
+
|
45
|
+
# Compares one asset index to another.
|
46
|
+
# @param other [AssetIndex] Asset index to compare against.
|
47
|
+
# @return [true] The asset indices are the same.
|
48
|
+
# @return [false] The asset indices are different.
|
49
|
+
def ==(other)
|
50
|
+
other.id == @id &&
|
51
|
+
other.sha1 == @sha1 &&
|
52
|
+
other.size == @size &&
|
53
|
+
other.url == @url &&
|
54
|
+
other.total_size == @total_size
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Lapis
|
2
|
+
module Minecraft
|
3
|
+
module Versioning
|
4
|
+
|
5
|
+
# Minimal information about a Minecraft version.
|
6
|
+
class Basic
|
7
|
+
|
8
|
+
# Unique identifier used to reference the version.
|
9
|
+
# @return [String] Unique identifier.
|
10
|
+
attr_reader :id
|
11
|
+
|
12
|
+
# Type of version.
|
13
|
+
# This can be one of:
|
14
|
+
# - +:release+ - Official release.
|
15
|
+
# - +:snapshot+ - Unstable, in development.
|
16
|
+
# - +:beta+ - Old beta.
|
17
|
+
# - +:alpha+ - Old alpha.
|
18
|
+
# @return [Symbol] +:release+, +:snapshot+, +:beta+, or +:alpha+.
|
19
|
+
attr_reader :type
|
20
|
+
|
21
|
+
# Date and time the version was made available to the public.
|
22
|
+
# @return [Time]
|
23
|
+
attr_reader :time
|
24
|
+
|
25
|
+
# URL pointing to detailed information about the version.
|
26
|
+
# @return [String] Version URL.
|
27
|
+
attr_reader :url
|
28
|
+
|
29
|
+
# Creates the basic information for a Minecraft version.
|
30
|
+
# @param id [String] Unique identifier used to reference the version.
|
31
|
+
# @param type [Symbol] +:release+, +:snapshot+, +:beta+, or +:alpha+.
|
32
|
+
# @param time [Time] Date and time the version was made available to the public.
|
33
|
+
# @param url [String] URL pointing to detailed information about the version.
|
34
|
+
def initialize(id, type, time, url)
|
35
|
+
@id = id.dup.freeze
|
36
|
+
@type = type
|
37
|
+
@time = time
|
38
|
+
@url = url.dup.freeze
|
39
|
+
end
|
40
|
+
|
41
|
+
# Compares one version to another.
|
42
|
+
# @param other [Basic] Version to compare against.
|
43
|
+
# @return [true] The versions are the same.
|
44
|
+
# @return [false] The versions are different.
|
45
|
+
def ==(other)
|
46
|
+
other.id == @id &&
|
47
|
+
other.type == @type &&
|
48
|
+
other.time == @time &&
|
49
|
+
other.url == @url
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|