Sha256: b657dd6a533ee49ae8509c7b7d925b1342dd0434b9ff2917f0dc46da8b517887

Contents?: true

Size: 679 Bytes

Versions: 4

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

require "pathname"

module Runcom
  module Paths
    # A collection of XDG directories with a strict adherence to the XDG specification.
    class Directory
      DELIMITER = ":"

      def initialize pair, environment = ENV
        @pair = pair
        @environment = environment
      end

      def default
        String(pair.value).split(DELIMITER).map { |path| Pathname(path).expand_path }
      end

      def dynamic
        environment.fetch(pair.key, String(pair.value)).split(DELIMITER).uniq.map do |path|
          Pathname(path).expand_path
        end
      end

      private

      attr_reader :pair, :environment
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
runcom-4.2.1 lib/runcom/paths/directory.rb
runcom-4.2.0 lib/runcom/paths/directory.rb
runcom-4.1.0 lib/runcom/paths/directory.rb
runcom-4.0.0 lib/runcom/paths/directory.rb