Sha256: 308df5494bab7b3b491ef7dee07dab6dae8f549afe2827170dc8e1f2d885d77f
Contents?: true
Size: 967 Bytes
Versions: 2
Compression:
Stored size: 967 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 paths.split(DELIMITER).map(&method(:expand)) end def dynamic String(environment[key]).then { |env_paths| env_paths.empty? ? paths : env_paths } .split(DELIMITER) .uniq .map(&method(:expand)) 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 paths String pair.value end def expand path Pathname(path).expand_path end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xdg-3.1.1 | lib/xdg/paths/directory.rb |
xdg-3.1.0 | lib/xdg/paths/directory.rb |