Sha256: 344b3685f9afcfc87f53f28497c374d2ff1a005be5caadec8577bee275bebdb6

Contents?: true

Size: 1.07 KB

Versions: 24

Compression:

Stored size: 1.07 KB

Contents

module BubbleWrap
  class Requirement
    module PathManipulation

      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

      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

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

      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

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

    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
bubble-wrap-1.9.7 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.6 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.5 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.4 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.3 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.2 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.1 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.9.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.8.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.7.1 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.7.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.6.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.6.0.rc1 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.5.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.5.0.rc1 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.4.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.3.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.3.0.osx lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.2.0 lib/bubble-wrap/requirement/path_manipulation.rb
bubble-wrap-1.2.0.pre lib/bubble-wrap/requirement/path_manipulation.rb