Sha256: e6229b6000bdbb0edc0312e7fa651e291c2e58373531e88d6a1daa93b5c94667

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require "pathname"

module Runcom
  module XDG
    # Represents X Desktop Group (XGD) configuration support. XGD is also known as
    # [Free Desktop](https://www.freedesktop.org). Here is the exact
    # [specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) being
    # for this implementation.
    class Configuration
      def self.home_dir
        ENV.fetch "XDG_CONFIG_HOME", File.join(ENV["HOME"], ".config")
      end

      def self.dirs
        ENV.fetch("XDG_CONFIG_DIRS", "/etc/xdg").split ":"
      end

      def self.computed_dirs
        directories = dirs.unshift(home_dir).map { |directory| Pathname(directory).expand_path }
        directories.select(&:exist?)
      end

      def self.computed_dir
        computed_dirs.first
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
runcom-1.0.0 lib/runcom/xdg/configuration.rb