Sha256: 04277c21855ca1e56a94b743126457b19ec43147632a26f13b598ed6a1445e07

Contents?: true

Size: 887 Bytes

Versions: 15

Compression:

Stored size: 887 Bytes

Contents

require 'yaml'

module VagrantPlugins
  module Skytap
    class Properties
      attr_reader :properties
      attr_reader :data_dir

      def self.filename
        raise NotImplementedError.new('Must override')
      end

      def self.read(data_dir)
        file = data_dir.join(filename)
        if file.exist?
          YAML.load_file(file)
        end
      end

      def self.write(data_dir, properties={})
        existing_props = read(data_dir) || {}
        props = existing_props.merge(properties)

        IO.write(data_dir.join(filename),
                 YAML.dump(props))
      end

      def initialize(data_dir)
        @properties = self.class.read(data_dir)
        @data_dir = data_dir
      end

      def read
        self.class.read(@data_dir)
      end

      def write(properties={})
        self.class.write(@data_dir, properties)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.11 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.10 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.9 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.8 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.7 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.6 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.5 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.4 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.3 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.2 lib/vagrant-skytap/properties.rb
vagrant-skytap-0.1.1a lib/vagrant-skytap/properties.rb