module BubbleWrap::Requirement::PathManipulation

Public Instance Methods

convert_caller_to_path(string) click to toggle source
# 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
convert_caller_to_root_path(path) click to toggle source
# 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
convert_to_absolute_path(path) click to toggle source
# File lib/bubble-wrap/requirement/path_manipulation.rb, line 20
def convert_to_absolute_path(path)
  File.expand_path(path)
end
convert_to_relative(path,root) click to toggle source
# File lib/bubble-wrap/requirement/path_manipulation.rb, line 39
def convert_to_relative(path,root)
  path = path.gsub(root,'')
  path = path[1..-1] if path[0] == '/'
  path
end
strip_up_to_last_lib(path) click to toggle source
# File lib/bubble-wrap/requirement/path_manipulation.rb, line 24
def strip_up_to_last_lib(path)
  if path =~ /\/lib$/
    path = path.gsub(/\/lib$/, "")
  else
    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] == '/'
  end
  path
end