Sha256: cd7a6bc2e9a928c92167a64b08c0f7aa15ca713fd40a362f8d6f78feb5f74141
Contents?: true
Size: 817 Bytes
Versions: 2
Compression:
Stored size: 817 Bytes
Contents
# frozen_string_literal: true require "forwardable" require "pathname" module XDG module Paths # A XDG home path. class Standard extend Forwardable HOME_KEY = "HOME" delegate %i[key value] => :pair def initialize pair, environment = ENV @pair = pair @environment = environment end def default expand String(value) end def dynamic String(environment[key]).then { |path| path.empty? ? default : expand(path) } end def inspect [pair.key, dynamic].compact.join XDG::PAIR_DELIMITER end private attr_reader :pair, :environment def expand path home.join(path).expand_path end def home Pathname environment.fetch(HOME_KEY) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xdg-3.1.1 | lib/xdg/paths/standard.rb |
xdg-3.1.0 | lib/xdg/paths/standard.rb |