Sha256: 05d3500ab3f9f46f0ff4ec298a612edf6b25c8c7ed1b9a7978204b900ee60b91
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
require 'yaml' require 'fileutils' module Socialcast class << self def config_dir config_dir = File.expand_path '~/.socialcast' FileUtils.mkdir config_dir, :mode => 0700 unless File.exist?(config_dir) config_dir end def credentials_file File.join config_dir, 'credentials.yml' end def credentials fail 'Unknown Socialcast credentials. Run `socialcast authenticate` to initialize' unless File.exist?(credentials_file) @@credentials ||= YAML.load_file(credentials_file) end def credentials=(options) File.open(credentials_file, "w") do |f| f.write(options.to_yaml) end File.chmod 0600, credentials_file end def basic_auth_options {:user => credentials[:user], :password => credentials[:password]} end # configure restclient for api call def resource_for_path(path, options = {}, debug = true) RestClient.log = Logger.new(STDOUT) if debug RestClient.proxy = credentials[:proxy] if credentials[:proxy] url = ['https://', credentials[:domain], path].join RestClient::Resource.new url, options.merge(basic_auth_options) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
socialcast-1.0.6 | lib/socialcast.rb |
socialcast-1.0.5 | lib/socialcast.rb |
socialcast-1.0.4 | lib/socialcast.rb |
socialcast-1.0.3 | lib/socialcast.rb |