Class: Specify::Configuration::HostConfig

Inherits:
Config
  • Object
show all
Defined in:
lib/specify/configuration/host_config.rb

Overview

A class that maps file directories to hosts

Instance Attribute Summary collapse

Attributes inherited from Config

#dir_names, #hosts

Instance Method Summary collapse

Methods inherited from Config

#add_database, #add_host, empty, #save, #saved?, #touch

Constructor Details

#initialize(file = nil) ⇒ HostConfig

Returns a new instance of HostConfig


9
10
11
12
# File 'lib/specify/configuration/host_config.rb', line 9

def initialize(file = nil)
  super(file)
  @saved = true
end

Instance Attribute Details

#directory_mapObject (readonly)

Returns the value of attribute directory_map


7
8
9
# File 'lib/specify/configuration/host_config.rb', line 7

def directory_map
  @directory_map
end

Instance Method Details

#directory?(directory) ⇒ Boolean

-> true or false Returns true if directory is mapped.

Returns:

  • (Boolean)

16
17
18
# File 'lib/specify/configuration/host_config.rb', line 16

def directory?(directory)
  params.key? directory
end

#map_directory(directory, host) ⇒ Object

Maps directory to host.


21
22
23
24
25
# File 'lib/specify/configuration/host_config.rb', line 21

def map_directory(directory, host)
  raise "Directory '#{directory}' already mapped" if params[directory]
  params[directory] = host
  touch
end

#paramsObject

-> Hash Returns a Hash with the parameters for the current directory mappings from the configuration YAML file.


30
31
32
# File 'lib/specify/configuration/host_config.rb', line 30

def params
  super.fetch :dir_names
end

#resolve_host(directory) ⇒ Object

-> String Returns the host name that is mapped to directory


36
37
38
# File 'lib/specify/configuration/host_config.rb', line 36

def resolve_host(directory)
  params.fetch directory
end