Sha256: ab61eba9b49f17657d749bacc56bbf209d7e397b5551be9fef0f36e2277b4336
Contents?: true
Size: 893 Bytes
Versions: 4
Compression:
Stored size: 893 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 } 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::DELIMITER private attr_reader :pair, :environment def key = String pair.key def value = String pair.value def expand(path) = Pathname(path).expand_path end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
xdg-7.1.3 | lib/xdg/paths/directory.rb |
xdg-7.1.2 | lib/xdg/paths/directory.rb |
xdg-7.1.1 | lib/xdg/paths/directory.rb |
xdg-7.1.0 | lib/xdg/paths/directory.rb |