Class: QuoraNotify::Install
- Inherits:
-
Object
- Object
- QuoraNotify::Install
- Defined in:
- lib/quora_notify/install.rb
Constant Summary collapse
- INSTALL_PATH =
File.join(ENV["HOME"], "Library", "LaunchAgents")
- LAUNCHD_PROCESS_NAME =
"com.joeycarmello.quora_notify"
- LAUNCHD_FILE_NAME =
"#{LAUNCHD_PROCESS_NAME}.plist"
- LAUNCHD_FILE_PATH =
File.join(File.(File.dirname(__FILE__)), "config", LAUNCHD_FILE_NAME)
Class Method Summary collapse
Class Method Details
.run! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/quora_notify/install.rb', line 11 def run! uninstall! # Used with the ERB binding gem_path = ENV['GEM_HOME'] ruby_path = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"') bin_path = `which quora_notify`.chomp template = ERB.new File.read(erb_path) launchd_contents = template.result(binding) File.open(install_file_path, 'w') { |file| file.puts launchd_contents } start end |
.uninstall! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/quora_notify/install.rb', line 25 def uninstall! if File.exists?(install_file_path) stop File.delete install_file_path end end |