Class: AtkPaths

Inherits:
Object
  • Object
show all
Defined in:
lib/atk/atk_info.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/atk/atk_info.rb', line 9

def self.[](name)
    # convert symbols to strings
    name = name.to_s
    case name
        when 'atk'
            return HOME/"atk"
        when 'temp'
            return self['atk']/"temp"
        when 'info'
            return HOME/"info.yaml"
        when 'ruby'
            atk_path_settings = Atk.info["paths"]
            if atk_path_settings.is_a?(Hash) and atk_path_settings["ruby"].is_a?(String)
                ruby_path = atk_path_settings["ruby"]
            elsif OS.is?(:mac)
                if `which rbenv`.chomp.size > 0
                    ruby_path = `rbenv which ruby`.chomp
                else
                    ruby_path = "/usr/bin/ruby"
                end
            elsif OS.is?(:unix)
                ruby_path = "/usr/bin/ruby"
            else
                ruby_path = OS.path_for_executable("ruby")
            end
            return ruby_path
        when 'gem'
            gem_path = AtkPaths["ruby"].sub(/\/ruby$/,"\/gem")
            if FS.file?(gem_path)
                return gem_path
            end
            # FUTURE: this should eventually have better error handling
            return OS.path_for_executable("gem")
        when 'repos'
            return HOME/"atk"/"repos"
        when 'commands'
            if OS.is?("unix")
                return "/usr/local/bin"
            else
                return "C:\\Users\\#{FS.username}\\AppData\\local\\Microsoft\\WindowsApps"
            end
    end
end