Sha256: 8e01ce32474ef8b5e9014ad01f08e928052e5072a8bb6fb37cd605de562f0a21
Contents?: true
Size: 818 Bytes
Versions: 41
Compression:
Stored size: 818 Bytes
Contents
require "yaml" module Shelly class Cloudfile < Model attr_accessor :content def self.present? File.exists?(File.join(Dir.pwd, "Cloudfile")) end def initialize open if File.exists?(path) end def path File.join(Dir.pwd, "Cloudfile") end def open @content = YAML.load(File.open(path)) end def write(hash) @content = hash File.open(path, "w") do |f| f.write(yaml(hash)) end end # FIXME: this should return instances of App def clouds @content.keys.sort end def yaml(hash) string = hash.deep_stringify_keys.to_yaml # FIXME: check if it possible to remove sub("---", "") by passing options to_yaml string.sub("---","").split("\n").map(&:rstrip).join("\n").strip end end end
Version data entries
41 entries across 41 versions & 1 rubygems