Sha256: 10b3d1302d63995a599f909163f42d425ba3bf1300c2824ee372e7aa5288f0b7
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require 'yaml' module VagrantPlugins module Environments class Config < Vagrant.plugin(2, :config) attr_accessor :file, :active attr_reader :data DEFAULT_SETTINGS = { file: 'environments.yaml' }.freeze def initialize @file = UNSET_VALUE @active = UNSET_VALUE end def file=(path) @file = path unless path.empty? end def active if @active == UNSET_VALUE && !ENV['VAGRANT_ENVIRONMENT'].nil? @active = ENV['VAGRANT_ENVIRONMENT'] end @active end def data validate environments = YAML.load_file(@file) environments[@active] end def validate(_) finalize! errors = _detected_errors if File.file?(@file) begin environments = YAML.load_file(@file) errors.push("There is no #{@active} environment in #{@file}") unless environments.has_key?(@active) rescue Exception errors.push("file #{@file} have wrong format") end else errors.push("file #{@file} does not exists") end { 'environments' => errors } end def finalize! @file = DEFAULT_SETTINGS[:file] if @file == UNSET_VALUE active end end #Config end #Envrionments end # VagrantPlugins
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-environments-0.1.2 | lib/vagrant-environments/config.rb |