Class: VagrantDNS::Registry

Inherits:
Object
  • Object
show all
Includes:
Store
Defined in:
lib/vagrant-dns/registry.rb

Overview

This is the dns pattern registry (aka “config”) It basically delegates everything to a YAML::Store but handles the conversion of Regexp dns-patterns into YAML string keys and reverse.

Constant Summary collapse

NAME =
"config"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Store

included

Constructor Details

#initialize(tmp_path) ⇒ Registry

Returns a new instance of Registry.



10
11
12
# File 'lib/vagrant-dns/registry.rb', line 10

def initialize(tmp_path)
  @store = YAML::Store.new(File.join(tmp_path, NAME), true)
end

Class Method Details

.open(tmp_path) ⇒ VagrantDNS::Registry?

Returns Eitehr an instance or nil if cofig file does not exist.

Returns:



15
16
17
# File 'lib/vagrant-dns/registry.rb', line 15

def self.open(tmp_path)
  new(tmp_path) if File.exist?(File.join(tmp_path, NAME))
end