Class: Lunchy

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

Overview

Lunchy doesn’t have uninstall method and also installs all plists to LaunchAgents. We can send a PR on spare time.

Constant Summary collapse

CONFIG =
{ :verbose => false, :write => nil }

Instance Method Summary collapse

Instance Method Details

#install(params) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/masquito/installer.rb', line 8

def install(params)
  raise ArgumentError, "install [file]" if params.empty?
  filename = params[0]
  %w(/Library/LaunchDaemons).each do |dir|
    if File.exist?(File.expand_path(dir))
      FileUtils.cp filename, File.join(File.expand_path(dir), File.basename(filename))
      return puts "#{filename} installed to #{dir}"
    end
  end
end

#uninstall(params) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
27
28
# File 'lib/masquito/installer.rb', line 19

def uninstall(params)
  raise ArgumentError, "uninstall [file]" if params.empty?
  filename = params[0]
  %w(/Library/LaunchDaemons).each do |dir|
    if File.exist?(File.expand_path(dir))
      FileUtils.rm_rf(File.join(File.expand_path(dir), File.basename(filename)))
      return puts "#{filename} removed from #{dir}"
    end
  end
end