Class: MojangSplitLWJGLSanitizer

Inherits:
BaseSanitizer show all
Defined in:
lib/wonko_the_sane/input/mojang_input.rb

Overview

extract lwjgl specific libraries and natives

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.lwjgl_extrasObject

Returns the value of attribute lwjgl_extras.



144
145
146
# File 'lib/wonko_the_sane/input/mojang_input.rb', line 144

def lwjgl_extras
  @lwjgl_extras
end

.lwjgl_listObject

Returns the value of attribute lwjgl_list.



144
145
146
# File 'lib/wonko_the_sane/input/mojang_input.rb', line 144

def lwjgl_list
  @lwjgl_list
end

Class Method Details

.sanitize(file) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/wonko_the_sane/input/mojang_input.rb', line 148

def self.sanitize(file)
  file.requires = [] if file.requires.nil?
  file.requires << Referenced.new('org.lwjgl')

  extras = [] # [Download]
  versioned = Hash.new { |hash, key| hash[key] = [] } # String => [Download]
  file.client.downloads.select! do |lib|
    nil == self.lwjgl_list.find do |lwjgl_candidate|
      if lib.name.include? lwjgl_candidate
        if self.lwjgl_extras.include? lib.maven.group
          extras << lib
        else
          versioned[lib.maven.version] << lib
        end
        true
      else
        false
      end
    end
  end

  files = [file]
  versioned.each do |version, downloads|
    lwjgl = WonkoVersion.new
    lwjgl.uid = 'org.lwjgl'
    lwjgl.type = 'release'
    lwjgl.version = version
    lwjgl.time = nil # re-fetches the time for the version from storage
    lwjgl.client.downloads = extras + downloads
    files << lwjgl
  end

  return files
end