Sha256: a6e17b6b1c32b84ffc0ab36b2064f7975b0a26d2285b2e3d9921f3970e3b97e8
Contents?: true
Size: 977 Bytes
Versions: 3
Compression:
Stored size: 977 Bytes
Contents
# frozen_string_literal: true require "pathname" module XDG module Paths # A collection of XDG directories. class Directory DELIMITER = ":" def initialize pair, environment = ENV @pair = pair @environment = environment end def default value.split(DELIMITER).map { |path| expand path } end def dynamic String(environment[key]).then { |env_value| env_value.empty? ? value : env_value } .split(DELIMITER) .uniq .map { |path| expand path } end def inspect [key, dynamic.join(DELIMITER)].reject(&:empty?).join XDG::PAIR_DELIMITER end private attr_reader :pair, :environment def key String pair.key end def value String pair.value end def expand path Pathname(path).expand_path end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xdg-5.1.0 | lib/xdg/paths/directory.rb |
xdg-5.0.0 | lib/xdg/paths/directory.rb |
xdg-4.5.0 | lib/xdg/paths/directory.rb |