Module: DataPaths::Methods

Included in:
DataPaths
Defined in:
lib/data_paths/methods.rb

Instance Method Summary collapse

Instance Method Details

#data_pathsArray<String>

The directories registered within a specific module or class.

Returns:

  • (Array<String>)

    The directories registered so far.



9
10
11
# File 'lib/data_paths/methods.rb', line 9

def data_paths
  @data_paths ||= []
end

#register_data_dir(path) ⇒ Object

Deprecated.

Will be removed 1.0.0, please use #register_data_path instead.



43
44
45
46
47
# File 'lib/data_paths/methods.rb', line 43

def register_data_dir(path)
  STDERR.puts "DEPRECATED: Please use register_data_path instead."

  register_data_path(path)
end

#register_data_path(path) ⇒ String

Registers a path as a data directory.

Examples:

register_data_dir File.join(File.dirname(__FILE__),'..','..','..','data')

Parameters:

Returns:

  • (String)

    The fully qualified form of the specified path.

Raises:

  • (RuntimeError)

    The specified path is not a directory.

Since:

  • 0.3.0



30
31
32
33
34
35
36
37
# File 'lib/data_paths/methods.rb', line 30

def register_data_path(path)
  path = File.expand_path(path)

  DataPaths.register(path)

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

#unregister_data_dir!(path) ⇒ Object

Deprecated.

Will be removed 1.0.0, please use #unregister_data_path instead.



71
72
73
74
75
# File 'lib/data_paths/methods.rb', line 71

def unregister_data_dir!(path)
  STDERR.puts "DEPRECATED: Please use unregister_data_path instead."

  unregister_data_path(path)
end

#unregister_data_dirs!Object

Deprecated.

Will be removed 1.0.0, please use #unregister_data_paths instead.



95
96
97
98
99
# File 'lib/data_paths/methods.rb', line 95

def unregister_data_dirs!
  STDERR.puts "DEPRECATED: Please use unregister_data_paths instead."

  unregister_data_paths
end

#unregister_data_path(path) ⇒ String

Unregisters any matching data directories.

Parameters:

  • path (String)

    The path to unregister.

Returns:

  • (String)

    The unregistered data path.

Since:

  • 0.3.0



60
61
62
63
64
65
# File 'lib/data_paths/methods.rb', line 60

def unregister_data_path(path)
  path = File.expand_path(path)

  self.data_paths.delete(path)
  return DataPaths.unregister!(path)
end

#unregister_data_pathstrue

Unregisters all previously registered data directories.

Returns:

  • (true)

    Specifies all data paths were successfully unregistered.

Since:

  • 0.3.0



85
86
87
88
89
# File 'lib/data_paths/methods.rb', line 85

def unregister_data_paths
  data_paths.each { |path| DataPaths.unregister!(path) }
  data_paths.clear
  return true
end