Module: DataPaths

Includes:
Methods
Defined in:
lib/data_paths/finders.rb,
lib/data_paths/methods.rb,
lib/data_paths/version.rb,
lib/data_paths/data_paths.rb

Defined Under Namespace

Modules: Finders, Methods

Constant Summary collapse

VERSION =

data_paths version

'0.3.1'

Class Method Summary collapse

Methods included from Methods

#data_paths, #register_data_dir, #register_data_path, #unregister_data_dir!, #unregister_data_dirs!, #unregister_data_path, #unregister_data_paths

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/data_paths/data_paths.rb', line 6

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

.pathsArray<String>

The registered data/ directories.

Returns:

  • (Array<String>)

    The directories which contain static content.



16
17
18
# File 'lib/data_paths/data_paths.rb', line 16

def DataPaths.paths
  @data_paths ||= []
end

.register(path) ⇒ String

Registers a data/ directory.

Returns:

  • (String)

    The registered data/ directory.

Raises:

  • (RuntimeError)

    The given path was not a directory.

Since:

  • 0.3.0



31
32
33
34
35
36
37
38
39
40
# 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) ⇒ String

Unregisters a previously registered data/ directory.

Returns:

  • (String)

    The unregistered data/ directory.

Since:

  • 0.3.0



50
51
52
# File 'lib/data_paths/data_paths.rb', line 50

def DataPaths.unregister(path)
  paths.delete(File.expand_path(path))
end