Sha256: dc2cb19018832bf57ec9413da085e459fa0491ac481ff0b4315769462dca8c83

Contents?: true

Size: 749 Bytes

Versions: 9

Compression:

Stored size: 749 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 { |path| Pathname path }
                     .then { |path| [path.expand_path, standard.dynamic] }
      end

      def inspect
        [
          standard.key,
          dynamic.join(XDG::Paths::Directory::DELIMITER)
        ].compact.join(XDG::PAIR_DELIMITER)
      end

      private

      attr_reader :standard
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
runcom-8.7.0 lib/runcom/paths/home.rb
runcom-8.6.0 lib/runcom/paths/home.rb
runcom-8.5.0 lib/runcom/paths/home.rb
runcom-8.4.0 lib/runcom/paths/home.rb
runcom-8.3.3 lib/runcom/paths/home.rb
runcom-8.3.2 lib/runcom/paths/home.rb
runcom-8.3.1 lib/runcom/paths/home.rb
runcom-8.3.0 lib/runcom/paths/home.rb
runcom-8.2.0 lib/runcom/paths/home.rb