module DataPaths

Constants

VERSION

data_paths version

Public Class Methods

included(base) click to toggle source
# File lib/data_paths/data_paths.rb, line 6
def self.included(base)
  base.extend Methods
end
paths() click to toggle source

The registered ‘data/` directories.

@return [Array<String>]

The directories which contain static content.
# File lib/data_paths/data_paths.rb, line 16
def DataPaths.paths
  @data_paths ||= []
end
register(path) click to toggle source

Registers a ‘data/` directory.

@return [String]

The registered `data/` directory.

@raise [RuntimeError]

The given path was not a directory.

@since 0.3.0

# File lib/data_paths/data_paths.rb, line 31
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
unregister(path) click to toggle source

Unregisters a previously registered ‘data/` directory.

@return [String]

The unregistered `data/` directory.

@since 0.3.0

# File lib/data_paths/data_paths.rb, line 50
def DataPaths.unregister(path)
  paths.delete(File.expand_path(path))
end