Sha256: f9caa7f9d356a466f346248e78282f72475a93ea19d03dd4f92d63c5a09b7162

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

# Requirements
# =======================================================================

# Stdlib
# -----------------------------------------------------------------------

# Deps
# -----------------------------------------------------------------------

# Project / Package
# -----------------------------------------------------------------------


# Refinements
# =======================================================================

using NRSER


# Definitions
# =======================================================================

module Locd
  
  def self.resolve project_root, path = nil
    return project_root if path.nil?
    
    if path.start_with? '//'
      project_root / path[2..-1]
    elsif path.start_with? '/'
      path.to_pn
    else
      project_root / path
    end
  end
  
  
  # Just like {.resolve} but returns a {String} (instead of a {Pathname}).
  # 
  # @param (see .resolve)
  # @return [String]
  # 
  def self.resolve_to_s *args
    resolve( *args ).to_s
  end
  
end # module Locd

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locd-0.1.5 lib/locd/util.rb
locd-0.1.4 lib/locd/util.rb
locd-0.1.3 lib/locd/util.rb