Sha256: e7835551dadd3e06c141ab8ff0a1a7eca37ced991aeb1358b744a097df62d2b4
Contents?: true
Size: 1014 Bytes
Versions: 2
Compression:
Stored size: 1014 Bytes
Contents
module Shelly class Cloudfile < Base 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['email']} (#{user['name']})" end result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shelly-0.0.21.pre | lib/shelly/cloudfile.rb |
shelly-0.0.20.pre | lib/shelly/cloudfile.rb |