Class Tap::Env::Path
In: lib/tap/env/path.rb
Parent: Object

Methods

==   []   []=   escape   join   load   new   split   to_s  

Constants

FILE = 'tap.yml'

Attributes

base  [R]  The path base.
map  [R]  A mapping of types to paths.

Public Class methods

[Source]

    # File lib/tap/env/path.rb, line 26
26:         def escape(str)
27:           "'#{str.gsub("'", "\\\\'")}'"
28:         end

[Source]

    # File lib/tap/env/path.rb, line 18
18:         def join(paths)
19:           paths.join(':')
20:         end

[Source]

    # File lib/tap/env/path.rb, line 22
22:         def load(path_file)
23:           Root.trivial?(path_file) ? {} : (YAML.load_file(path_file) || {})
24:         end

Creates a new Path relative to the base.

[Source]

    # File lib/tap/env/path.rb, line 40
40:       def initialize(base, map={})
41:         @base = File.expand_path(base)
42:         @map = {}
43:         
44:         map.each_pair {|type, paths| self[type] = paths }
45:       end

Splits the path string along ’:’ boundaries and expands each resulting fragments relative to dir. Duplicate paths are removed. Returns the resulting paths.

An array of pre-split paths may also be provided as an input.

[Source]

    # File lib/tap/env/path.rb, line 11
11:         def split(str, dir=Dir.pwd)
12:           paths = str.kind_of?(String) ? str.split(':') : str
13:           paths.collect! {|path| File.expand_path(path, dir) } if dir
14:           paths.uniq!
15:           paths
16:         end

Public Instance methods

[Source]

    # File lib/tap/env/path.rb, line 59
59:       def ==(another)
60:         another.kind_of?(Path) &&
61:         base == another.base &&
62:         map == another.map
63:       end

Returns an array of expanded paths associated with the type; by default the type expanded under base.

[Source]

    # File lib/tap/env/path.rb, line 49
49:       def [](type)
50:         map[type] ||= [File.expand_path(type.to_s, base)]
51:       end

Sets the path for the type. Paths are split and expanded relative to base (see Path.split).

[Source]

    # File lib/tap/env/path.rb, line 55
55:       def []=(type, paths)
56:         map[type] = Path.split(paths, base)
57:       end

Returns the base path.

[Source]

    # File lib/tap/env/path.rb, line 66
66:       def to_s
67:         base
68:       end

[Validate]