File: data.rb

package info (click to toggle)
ruby-xdg 9.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 136 kB
  • sloc: ruby: 199; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require "forwardable"
require "xdg/pair"

module XDG
  # Provides data support.
  class Data
    extend Forwardable

    HOME_PAIR = Pair["XDG_DATA_HOME", ".local/share"].freeze
    DIRS_PAIR = Pair["XDG_DATA_DIRS", "/usr/local/share:/usr/share"].freeze

    delegate %i[home directories all to_s to_str] => :combined

    def initialize home: Paths::Home, directories: Paths::Directory, environment: ENV
      @combined = Paths::Combined.new home.new(HOME_PAIR, environment),
                                      directories.new(DIRS_PAIR, environment)
      freeze
    end

    def inspect = "#<#{self.class}:#{object_id} #{self}>"

    private

    attr_reader :combined
  end
end