Module: Launchr::Path

Defined in:
lib/launchr/path.rb

Class Method Summary collapse

Class Method Details

.bin_homebrew_prefixObject



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_launchdaemonsObject



12
13
14
# File 'lib/launchr/path.rb', line 12

def boot_launchdaemons
  Pathname.new("/Library/LaunchDaemons")
end

.brew_launchdaemonsObject



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_prefixObject



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

Returns:

  • (Boolean)


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_prefixObject



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_binObject



28
29
30
# File 'lib/launchr/path.rb', line 28

def launchr_bin
  Pathname.new(LAUNCHR_BIN).expand_path
end

.launchr_default_bootObject



24
25
26
# File 'lib/launchr/path.rb', line 24

def launchr_default_boot
  Pathname.new("~/Library/Preferences/#{Launchr.label}.default-boot").expand_path
end

.launchr_rootObject



32
33
34
# File 'lib/launchr/path.rb', line 32

def launchr_root
  launchr_bin.dirname.parent
end

.launchr_versionObject



36
37
38
# File 'lib/launchr/path.rb', line 36

def launchr_version
  launchr_root+"VERSION"
end

.user_launchdaemonsObject



8
9
10
# File 'lib/launchr/path.rb', line 8

def user_launchdaemons
  Pathname.new("~/Library/LaunchAgents").expand_path
end