Class: CurseClient::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/curse_client/installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Installer

Returns a new instance of Installer.



3
4
5
# File 'lib/curse_client/installer.rb', line 3

def initialize(client)
  @client = client
end

Instance Method Details

#install(modpack, path, version) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/curse_client/installer.rb', line 7

def install(modpack, path, version)
  modpack_file = find_file(modpack, version)
  unless modpack_file
    puts "Could not find #{modpack[:name]} version #{version}"
    return
  end

  puts "Installing #{modpack[:name]}"
  file = download(modpack_file[:download_url])

  path = File.expand_path(path)
  FileUtils::mkpath(path) unless File.exists?(path)
  unless File.directory?(path)
    puts "#{path} is not a directory"
    return
  end

  manifest = unzip(file, path)
  download_mods(manifest, path)
  write_configuration(path, modpack, modpack_file)

  puts "\nInstalled #{modpack[:name]} to #{File.expand_path(path)}"
  puts "Requires minecraft #{manifest["minecraft"]["version"]} and #{manifest["minecraft"]["modLoaders"][0]["id"]}"
end