class Kosmos::Package
Attributes
download_dir[R]
ksp_path[R]
Public Class Methods
download!()
click to toggle source
# File lib/kosmos/package.rb, line 43 def download! PackageDownloads.download_package(self) end
find(name)
click to toggle source
# File lib/kosmos/package.rb, line 60 def find(name) @@packages.find do |package| package.names.any? do |candidate_name| normalize_for_find(candidate_name) == normalize_for_find(name) end end end
inherited(package)
click to toggle source
a callback for when a subclass of this class is created
# File lib/kosmos/package.rb, line 48 def inherited(package) (@@packages ||= []) << package end
normalize_for_find(name)
click to toggle source
# File lib/kosmos/package.rb, line 52 def normalize_for_find(name) name.downcase.gsub(' ', "-") end
normalized_title()
click to toggle source
# File lib/kosmos/package.rb, line 56 def normalized_title normalize_for_find(title) end
search(name)
click to toggle source
# File lib/kosmos/package.rb, line 68 def search(name) @@packages.min_by do |package| package.names.map do |candidate_name| DamerauLevenshtein.distance(name, candidate_name) end.min end end
unzip!()
click to toggle source
# File lib/kosmos/package.rb, line 39 def unzip! PackageDownloads.download_and_unzip_package(self) end
Public Instance Methods
install!(ksp_path)
click to toggle source
Internal version of the `install` method, which handles procedures commong to all packages, such as saving work before and after installation, as well as downloading and unzipping packages and running post-processors.
# File lib/kosmos/package.rb, line 17 def install!(ksp_path) @ksp_path = ksp_path install_prerequisites! @download_dir = self.class.unzip! Util.log "Saving your work before installing ..." Versioner.mark_preinstall(ksp_path, self) Util.log "Installing #{title} ..." install Util.log "Cleaning up ..." Util.run_post_processors!(ksp_path) Versioner.mark_postinstall(ksp_path, self) install_postrequisites! end
Private Instance Methods
install_postrequisites!()
click to toggle source
# File lib/kosmos/package.rb, line 88 def install_postrequisites! resolve_postrequisites.each do |package| unless Versioner.installed_packages(ksp_path).include?(package.title) Util.log "#{title} has postrequisite #{package.title}." package.new.install!(ksp_path) end end end
install_prerequisites!()
click to toggle source
# File lib/kosmos/package.rb, line 79 def install_prerequisites! resolve_prerequisites.each do |package| unless Versioner.installed_packages(ksp_path).include?(package.title) Util.log "#{title} has prerequisite #{package.title}." package.new.install!(ksp_path) end end end