Class: Plat4m::Sniffer::Darwin::MacPkgManager::MacPorts

Inherits:
PkgManager
  • Object
show all
Defined in:
lib/plat4m/sniff/darwin.rb

Instance Method Summary collapse

Methods inherited from PkgManager

#has_sudo?, #install, #select_available, #select_uninstalled, #uninstall

Constructor Details

#initialize(owner) ⇒ MacPorts

Returns a new instance of MacPorts.



139
140
141
142
143
144
# File 'lib/plat4m/sniff/darwin.rb', line 139

def initialize(owner)
  super()
  @owner = owner
  @has_sudo = @owner.has_sudo?
  @privileged = File.stat(`which port`.strip).uid == 0
end

Instance Method Details

#available?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/plat4m/sniff/darwin.rb', line 150

def available?(pkg)
  !(`port -q search --exact #{pkg}`.strip.empty?)
end

#installed?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


146
147
148
# File 'lib/plat4m/sniff/darwin.rb', line 146

def installed?(pkg)
  !(`port -q installed #{pkg}`.strip.empty?)
end

#make_install_command(*pkgs) ⇒ Object



154
155
156
# File 'lib/plat4m/sniff/darwin.rb', line 154

def make_install_command(*pkgs)
  auth_cmd("port install #{pkgs.join(' ')}")
end

#make_uninstall_command(*pkgs) ⇒ Object



158
159
160
# File 'lib/plat4m/sniff/darwin.rb', line 158

def make_uninstall_command(*pkgs)
  auth_cmd("port uninstall #{pkgs.join(' ')}")
end