Sha256: 7062570c67a672c8a2fb9282f5fef8dd8e0f1aa6edf2ac31f7419821ddff75d1

Contents?: true

Size: 619 Bytes

Versions: 8

Compression:

Stored size: 619 Bytes

Contents

# frozen_string_literal: true
# encoding: UTF-8

# 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

8 entries across 8 versions & 1 rubygems

Version Path
locd-0.1.13 lib/locd/util.rb
locd-0.1.12 lib/locd/util.rb
locd-0.1.11 lib/locd/util.rb
locd-0.1.10 lib/locd/util.rb
locd-0.1.9 lib/locd/util.rb
locd-0.1.8 lib/locd/util.rb
locd-0.1.7 lib/locd/util.rb
locd-0.1.6 lib/locd/util.rb