Sha256: bd002b4c6c1ac4d47b70387c68ab4db17e72ac593ac4b7db8e7bb02369be566d

Contents?: true

Size: 677 Bytes

Versions: 11

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "pathname"

module Runcom
  module Paths
    # A XDG home path that prefers local over global path.
    class Home
      extend Forwardable

      delegate %i[key value default] => :standard

      def initialize pair, environment = ENV
        @standard = XDG::Paths::Home.new pair, environment
      end

      def dynamic
        String(value).then do |path|
          File.exist?(path) ? Pathname(path).expand_path : standard.dynamic
        end
      end

      def inspect
        [standard.key, dynamic].compact.join XDG::PAIR_DELIMITER
      end

      private

      attr_reader :standard
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
runcom-7.1.0 lib/runcom/paths/home.rb
runcom-7.0.0 lib/runcom/paths/home.rb
runcom-6.6.0 lib/runcom/paths/home.rb
runcom-6.5.0 lib/runcom/paths/home.rb
runcom-6.4.0 lib/runcom/paths/home.rb
runcom-6.3.0 lib/runcom/paths/home.rb
runcom-6.2.0 lib/runcom/paths/home.rb
runcom-6.1.1 lib/runcom/paths/home.rb
runcom-6.1.0 lib/runcom/paths/home.rb
runcom-6.0.1 lib/runcom/paths/home.rb
runcom-6.0.0 lib/runcom/paths/home.rb