Sha256: c342430fee083b392a2c2c403e51c21b470b0166569bd26346ab89800d8b0328

Contents?: true

Size: 485 Bytes

Versions: 3

Compression:

Stored size: 485 Bytes

Contents

require 'yaml'

module Hobo
  module Config
    class File
      def self.save(file, config)
        dir = ::File.dirname file
        FileUtils.mkdir_p dir unless ::File.exists? dir
        ::File.open(file, 'w+') do |f|
          f.puts config.to_yaml
        end
      end

      def self.load(file)
        config = ::File.exists?(file) ? YAML.load_file(file) : {}
        raise "Invalid hobo configuration (#{file})" unless config
        return config
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.4 lib/hobo/config/file.rb
hobo-inviqa-0.0.3 lib/hobo/config/file.rb
hobo-inviqa-0.0.2 lib/hobo/config/file.rb