Class: LaunchCraft::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/launchcraft/update.rb

Defined Under Namespace

Classes: Entry, Global

Instance Method Summary collapse

Constructor Details

#initializeUpdate

Returns a new instance of Update.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/launchcraft/update.rb', line 45

def initialize
  @dir = File.join(LaunchCraft.working_dir, 'bin')
  @os = OS.parse.to_s.gsub(/^macos$/, 'macosx')

  @entries = {
    lwjgl: Entry.new('lwjgl.jar', Config['url.download'] + 'lwjgl.jar'),
    jinput: Entry.new('jinput.jar', Config['url.download'] + 'jinput.jar'),
    lwjgl_util: Entry.new('lwjgl_util.jar', Config['url.download'] + 'lwjgl_util.jar'),
    "#{@os}_natives".to_sym => Entry.new("#{@os}_natives.jar.lzma", Config['url.download'] + "#{@os}_natives.jar.lzma"),
    minecraft: Entry.new('minecraft.jar', 'http://cloud.github.com/downloads/shurizzle/MyCraft/minecraft.jar')
  }
end

Instance Method Details

#checkObject



58
59
60
61
62
63
# File 'lib/launchcraft/update.rb', line 58

def check
  @entries.each {|name, entry|
    yield entry if block_given?
    entry.md5, entry.size = get_infos(entry.url)
  }
end

#force_update(&blk) ⇒ Object



71
72
73
# File 'lib/launchcraft/update.rb', line 71

def force_update (&blk)
  _update @entries.values, &blk
end

#update(&blk) ⇒ Object



65
66
67
68
69
# File 'lib/launchcraft/update.rb', line 65

def update (&blk)
  _update @entries.map {|name, entry|
    entry if MD5File.send(name) != entry.md5
  }.compact, &blk
end