Sha256: 95612ae64af55abea22f149c148a77286bac6d9f3c61972901f7ba5c545ea1f2
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'yaml' require 'fileutils' module Socialcast module CommandLine def self.config_dir config_dir = File.expand_path '~/.socialcast' FileUtils.mkdir config_dir, :mode => 0700 unless File.exist?(config_dir) config_dir end def self.credentials_file ENV['SC_CREDENTIALS_FILE'] || File.join(config_dir, 'credentials.yml') end def self.credentials fail 'Unknown Socialcast credentials. Run `socialcast authenticate` to initialize' unless File.exist?(credentials_file) YAML.load_file(credentials_file) end def self.credentials=(options) File.open(credentials_file, "w") do |f| f.write(options.to_yaml) end File.chmod 0600, credentials_file end # configure restclient for api call def self.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({ :user => credentials[:user], :password => credentials[:password] }) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
socialcast-1.3.2 | lib/socialcast.rb |
socialcast-1.3.1 | lib/socialcast.rb |