Module: BubbleWrap::Requirement::PathManipulation

Included in:
BubbleWrap::Requirement, BubbleWrap::Requirement
Defined in:
lib/bubble-wrap/requirement/path_manipulation.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) convert_caller_to_path(string)



11
12
13
14
15
16
17
18
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 11

def convert_caller_to_path(string)
  chunks = string.split(':')
  if chunks.size >= 3
    string = chunks[0..-3].join(':')
    string = File.dirname(string)
  end
  string
end

- (Object) convert_caller_to_root_path(path)



5
6
7
8
9
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 5

def convert_caller_to_root_path(path)
  path = convert_caller_to_path path
  path = convert_to_absolute_path path
  strip_up_to_last_lib path
end

- (Object) convert_to_absolute_path(path)



20
21
22
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 20

def convert_to_absolute_path(path)
  File.expand_path(path)
end

- (Object) convert_to_relative(path, root)



35
36
37
38
39
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 35

def convert_to_relative(path,root)
  path = path.gsub(root,'')
  path = path[1..-1] if path[0] == '/'
  path
end

- (Object) strip_up_to_last_lib(path)



24
25
26
27
28
29
30
31
32
33
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 24

def strip_up_to_last_lib(path)
  path = path.split('lib')
  path = if path.size > 1
           path[0..-2].join('lib')
         else
           path[0]
         end
  path = path[0..-2] if path[-1] == '/'
  path
end