Sha256: 3b3d29fb6e0abf6da91ac1b0ec33df4900ccf74f6feb64bf11cb197f3fb72c3a

Contents?: true

Size: 838 Bytes

Versions: 4

Compression:

Stored size: 838 Bytes

Contents

require 'fileutils'

module AppMap
  module Depends
    module Util
      extend self

      def normalize_path(path, pwd: Dir.pwd)
        normalize_path_fn(pwd).(path)
      end

      def normalize_paths(paths, pwd: Dir.pwd)
        paths.map(&normalize_path_fn(pwd))
      end
            
      def delete_appmap(appmap_path)
        FileUtils.rm_rf(appmap_path)
        appmap_file_path = [ appmap_path, 'appmap.json' ].join('.')
        File.unlink(appmap_file_path) if File.exists?(appmap_file_path)
      rescue
        warn "Unable to delete AppMap: #{$!}"
      end

      private

      def normalize_path_fn(pwd)
        lambda do |path|
          next path if AppMap::Util.blank?(path)

          path = path[pwd.length + 1..-1] if path.index(pwd) == 0
          path.split(':')[0]
        end  
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appmap-0.66.1 lib/appmap/depends/util.rb
appmap-0.66.0 lib/appmap/depends/util.rb
appmap-0.65.1 lib/appmap/depends/util.rb
appmap-0.65.0 lib/appmap/depends/util.rb