Class: Vagrant::Hivemind::Util::HiveFile
- Inherits:
-
Object
- Object
- Vagrant::Hivemind::Util::HiveFile
- Defined in:
- lib/vagrant/hivemind/util.rb
Class Method Summary collapse
- .exist?(path = Pathname.new(Dir.pwd)) ⇒ Boolean
- .read_from(path = Pathname.new(Dir.pwd)) ⇒ Object
- .write_to(hosts = {}, path = Pathname.new(Dir.pwd)) ⇒ Object
Class Method Details
.exist?(path = Pathname.new(Dir.pwd)) ⇒ 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 |