Module: BubbleWrap::Requirement::PathManipulation
- Included in:
- BubbleWrap::Requirement, BubbleWrap::Requirement
- Defined in:
- lib/bubble-wrap/requirement/path_manipulation.rb
Instance Method Summary collapse
- #convert_caller_to_path(string) ⇒ Object
- #convert_caller_to_root_path(path) ⇒ Object
- #convert_to_absolute_path(path) ⇒ Object
- #convert_to_relative(path, root) ⇒ Object
- #strip_up_to_last_lib(path) ⇒ Object
Instance Method Details
#convert_caller_to_path(string) ⇒ Object
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 |
#convert_caller_to_root_path(path) ⇒ Object
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 |
#convert_to_absolute_path(path) ⇒ Object
20 21 22 |
# File 'lib/bubble-wrap/requirement/path_manipulation.rb', line 20 def convert_to_absolute_path(path) File.(path) end |
#convert_to_relative(path, root) ⇒ Object
39 40 41 42 43 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |