Sha256: 3466fee47e09a8380b1e84c1378e66bb2079ecf5edf796d6d63e81df240b124c

Contents?: true

Size: 713 Bytes

Versions: 9

Compression:

Stored size: 713 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::DELIMITER
      end

      private

      attr_reader :standard
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
runcom-10.2.1 lib/runcom/paths/home.rb
runcom-10.2.0 lib/runcom/paths/home.rb
runcom-10.1.0 lib/runcom/paths/home.rb
runcom-10.0.1 lib/runcom/paths/home.rb
runcom-10.0.0 lib/runcom/paths/home.rb
runcom-9.0.3 lib/runcom/paths/home.rb
runcom-9.0.2 lib/runcom/paths/home.rb
runcom-9.0.1 lib/runcom/paths/home.rb
runcom-9.0.0 lib/runcom/paths/home.rb