Sha256: bffcd81e10e37c7203c586fbbd0a548047c7cd9f1002999ad2655219edd0bb44

Contents?: true

Size: 972 Bytes

Versions: 4

Compression:

Stored size: 972 Bytes

Contents

require 'data_paths/methods'

module DataPaths
  include Methods

  def self.included(base)
    base.extend Methods
  end

  #
  # The registered `data/` directories.
  #
  # @return [Array<String>]
  #   The directories which contain static content.
  #
  def DataPaths.paths
    @data_paths ||= []
  end

  #
  # Registers a `data/` directory.
  #
  # @return [String]
  #   The registered `data/` directory.
  #
  # @raise [RuntimeError]
  #   The given path was not a directory.
  #
  # @since 0.3.0
  #
  def DataPaths.register(path)
    path = File.expand_path(path)

    unless File.directory?(path)
      raise("#{path.dump} must be a directory")
    end

    paths << path unless paths.include?(path)
    return path
  end

  #
  # Unregisters a previously registered `data/` directory.
  #
  # @return [String]
  #   The unregistered `data/` directory.
  #
  # @since 0.3.0
  #
  def DataPaths.unregister(path)
    paths.delete(File.expand_path(path))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
data_paths-0.3.1 lib/data_paths/data_paths.rb
data_paths-0.3.0 lib/data_paths/data_paths.rb
data_paths-0.3.0.rc2 lib/data_paths/data_paths.rb
data_paths-0.3.0.rc1 lib/data_paths/data_paths.rb