Class: Vagrant::Hivemind::Util::HiveFile

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/hivemind/util.rb

Class Method Summary collapse

Class Method Details

.exist?(path = Pathname.new(Dir.pwd)) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/vagrant/hivemind/util.rb', line 11

def self.exist?(path = Pathname.new(Dir.pwd))
  File.exist? get_hive_file_from_path path
end

.read_from(path = Pathname.new(Dir.pwd)) ⇒ Object



15
16
17
18
19
20
# File 'lib/vagrant/hivemind/util.rb', line 15

def self.read_from(path = Pathname.new(Dir.pwd))
  hive_file = get_hive_file_from_path path
  hosts_from_hive_file = {}
  hosts_from_hive_file = YAML.load_file(hive_file) if File.exist? hive_file
  hosts_from_hive_file
end

.write_to(hosts = {}, path = Pathname.new(Dir.pwd)) ⇒ Object



22
23
24
25
26
27
# File 'lib/vagrant/hivemind/util.rb', line 22

def self.write_to(hosts = {}, path = Pathname.new(Dir.pwd))
  hive_file = get_hive_file_from_path path
  File.open(hive_file, "w+") do |f|
    f.write(hosts.to_yaml)
  end
end