Sha256: 1e1b007aa418715804960b1743c92a2dd62dc4a775d00fc215d167b868971625

Contents?: true

Size: 637 Bytes

Versions: 4

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

require "forwardable"

module Runcom
  module Paths
    # A XDG home path with a loose adherence to XDG specification by preferring local path if it
    # exists, otherwise defaulting to standard computed path.
    class Friendly
      extend Forwardable

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

      def initialize pair, environment = ENV
        @standard = Standard.new pair, environment
      end

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

      private

      attr_reader :standard
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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