Module: Launchr::Path
- Defined in:
- lib/launchr/path.rb
Class Method Summary collapse
- .bin_homebrew_prefix ⇒ Object
- .boot_launchdaemons ⇒ Object
- .brew_launchdaemons ⇒ Object
- .chown_down(path) ⇒ Object
- .cwd_homebrew_prefix ⇒ Object
-
.global_const_defined?(string) ⇒ Boolean
Same as Kernel.const_defined?, except it works for global constants.
- .homebrew_prefix ⇒ Object
- .launchr_bin ⇒ Object
- .launchr_default_boot ⇒ Object
- .launchr_root ⇒ Object
- .launchr_version ⇒ Object
- .user_launchdaemons ⇒ Object
Class Method Details
.bin_homebrew_prefix ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/launchr/path.rb', line 65 def bin_homebrew_prefix case @bin_homebrew_prefix when nil if global_const_defined?("HOMEBREW_PREFIX") @bin_homebrew_prefix = HOMEBREW_PREFIX elsif launchr_root.include?("Cellar/launchr") @bin_homebrew_prefix = Pathname.new(launchr_root.to_s.gsub(/\/Cellar\/launchr.*$/,"")) end @bin_homebrew_prefix ||= false else @bin_homebrew_prefix end end |
.boot_launchdaemons ⇒ Object
12 13 14 |
# File 'lib/launchr/path.rb', line 12 def boot_launchdaemons Pathname.new("/Library/LaunchDaemons") end |
.brew_launchdaemons ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/launchr/path.rb', line 16 def brew_launchdaemons if homebrew_prefix homebrew_prefix+"Library/LaunchDaemons" else false end end |
.chown_down(path) ⇒ Object
85 86 87 88 89 |
# File 'lib/launchr/path.rb', line 85 def chown_down path if Launchr.superuser? FileUtils.chown_R Launchr.user, Launchr.group, path.to_s end end |
.cwd_homebrew_prefix ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/launchr/path.rb', line 40 def cwd_homebrew_prefix case @cwd_homebrew_prefix when nil Pathname.pwd.ascend do |path| if (path+"/Library/Homebrew").exist? @cwd_homebrew_prefix = path break end end @cwd_homebrew_prefix ||= false else @cwd_homebrew_prefix end end |
.global_const_defined?(string) ⇒ Boolean
Same as Kernel.const_defined?, except it works for global constants
56 57 58 59 60 61 62 63 |
# File 'lib/launchr/path.rb', line 56 def global_const_defined? string begin eval string true rescue NameError false end end |
.homebrew_prefix ⇒ Object
80 81 82 83 |
# File 'lib/launchr/path.rb', line 80 def homebrew_prefix # cwd_homebrew_prefix || bin_homebrew_prefix bin_homebrew_prefix end |
.launchr_bin ⇒ Object
28 29 30 |
# File 'lib/launchr/path.rb', line 28 def launchr_bin Pathname.new(LAUNCHR_BIN). end |
.launchr_default_boot ⇒ Object
24 25 26 |
# File 'lib/launchr/path.rb', line 24 def launchr_default_boot Pathname.new("~/Library/Preferences/#{Launchr.label}.default-boot"). end |
.launchr_root ⇒ Object
32 33 34 |
# File 'lib/launchr/path.rb', line 32 def launchr_root launchr_bin.dirname.parent end |
.launchr_version ⇒ Object
36 37 38 |
# File 'lib/launchr/path.rb', line 36 def launchr_version launchr_root+"VERSION" end |
.user_launchdaemons ⇒ Object
8 9 10 |
# File 'lib/launchr/path.rb', line 8 def user_launchdaemons Pathname.new("~/Library/LaunchAgents"). end |