Sha256: 04c60f1fab04091c93227d26bd6b630a582b4a05488afa8a6c62c11f4b24ad45
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
module Shaddox class Installer def self.autodetect(pvr) return AptInstaller.new(pvr) if pvr.availiable? "apt-get" return BrewInstaller.new(pvr) if pvr.availiable? "brew" return PacmanInstaller.new(pvr) if pvr.availiable? "pacman" warn "Installer could not be automatically identified.", 1 require 'highline/import' choose do |menu| menu.prompt = "Please select a package manager to use:" menu.choice(:manual) { return ManualInstaller.new(pvr) } menu.choice(:apt) { return AptInstaller.new(pvr) } menu.choice(:brew) { return BrewInstaller.new(pvr) } end end def initialize(pvr) @pvr = pvr end def install(package) raise "This should be implemented by subclass." end def installed?(cmd) @pvr.availiable?(cmd) end end class ManualInstaller < Installer def install(package) return if installed?(package) puts "Please install '#{package}' manually." gets raise "Could not install #{package}" unless installed?(package) end end class AptInstaller < Installer # def initialize(pvr) # super(pvr) # @pvr.exec("sudo apt-get update") # end def install(package) return if installed?(package) @pvr.exec("sudo apt-get install #{package}") raise "Could not install #{package}" unless installed?(package) end end class BrewInstaller < Installer # def initialize(pvr) # super(pvr) # @pvr.exec("brew update") # end def install(package) return if installed?(package) @pvr.exec("brew install #{package}") raise "Could not install #{package}" unless installed?(package) end end class PacmanInstaller < Installer # def initialize(pvr) # super(pvr) # @pvr.exec("pacman -Sy") # end def install(package) return if installed?(package) @pvr.exec("pacman -S #{package}") raise "Could not install #{package}" unless installed?(package) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shaddox-0.1.2 | lib/shaddox/installer.rb |
shaddox-0.1.1 | lib/shaddox/installer.rb |
shaddox-0.1.0 | lib/shaddox/installer.rb |