Class: Masquito::Installer

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

Constant Summary collapse

SERVICE_NAME =
'com.evrone.masquito'
SERVICE_PLIST =
"#{SERVICE_NAME}.plist"
SERVICE_TEMPLATE_PATH =
File.join(GEM_PATH, 'config', "#{SERVICE_PLIST}.erb")

Instance Method Summary collapse

Constructor Details

#initializeInstaller

Returns a new instance of Installer.



37
38
39
# File 'lib/masquito/installer.rb', line 37

def initialize
  @lunchy = Lunchy.new
end

Instance Method Details

#installObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/masquito/installer.rb', line 41

def install
  switch_privileges {
    FileUtils.mkdir_p(CONFIG_PATH)
  }

  plist = ERB.new File.read(SERVICE_TEMPLATE_PATH)
  template = plist.result(binding)

  filename = File.join(Dir.tmpdir, SERVICE_PLIST)
  File.open(filename, 'w') { |f| f.write(template) }
  @lunchy.install([filename])
  @lunchy.start([SERVICE_NAME])
  File.unlink(filename)

  puts "Daemon was successfully installed."
end

#removeObject



58
59
60
61
62
# File 'lib/masquito/installer.rb', line 58

def remove
  @lunchy.stop([SERVICE_NAME])
  @lunchy.uninstall([SERVICE_PLIST])
  puts "You can remove #{CONFIG_PATH} if you don't need these settings"
end