Sha256: 00529e05defe0ac20bbbff6e1f3ab7f508d42e87c0471eabe3380271efc3df8c

Contents?: true

Size: 527 Bytes

Versions: 7

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

require "pathname"

module Runcom
  # A developer friendly wrapper of XDG data.
  Data = Struct.new :name, :home, :environment, keyword_init: true do
    def initialize *arguments
      super

      self[:home] ||= Runcom::Paths::Friendly
      self[:environment] ||= ENV
      freeze
    end

    def path
      paths.find(&:exist?)
    end

    def paths
      XDG::Data.new(home: home, environment: environment).all.map do |root|
        Pathname "#{root}/#{name}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
runcom-5.0.2 lib/runcom/data.rb
runcom-5.0.1 lib/runcom/data.rb
runcom-5.0.0 lib/runcom/data.rb
runcom-4.2.1 lib/runcom/data.rb
runcom-4.2.0 lib/runcom/data.rb
runcom-4.1.0 lib/runcom/data.rb
runcom-4.0.0 lib/runcom/data.rb