Sha256: 449001776ea55a9a9e13f32f4d110d49033e77e94a45bd0667d7b9c1a0224d36
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
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 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 def fetch_users response = shelly.apps_users(clouds) response.inject({}) do |result, app| result[app['code_name']] = app['users'].map do |user| user['name'] ? "#{user['email']} (#{user['name']})" : user['email'] end result end end end end
Version data entries
5 entries across 5 versions & 1 rubygems