module Socialcast::CommandLine
Constants
- VERSION
Public Class Methods
authentication(options)
click to toggle source
# File lib/socialcast.rb, line 51 def self.authentication(options) if options[:external_system] { :headers => { :Authorization => "SocialcastApiClient #{credentials[:api_client_identifier]}:#{credentials[:api_client_secret]}" } } else { :user => credentials[:user], :password => credentials[:password] } end end
config_dir()
click to toggle source
# File lib/socialcast.rb, line 16 def self.config_dir config_dir = File.expand_path '~/.socialcast' FileUtils.mkdir config_dir, :mode => 0700 unless File.exist?(config_dir) config_dir end
credentials()
click to toggle source
# File lib/socialcast.rb, line 26 def self.credentials fail 'Unknown Socialcast credentials. Run `socialcast authenticate` to initialize' unless File.exist?(credentials_file) YAML.load_file(credentials_file) end
credentials=(options)
click to toggle source
# File lib/socialcast.rb, line 31 def self.credentials=(options) File.open(credentials_file, "a+") do |f| existing_content = YAML.load(f.read) || {} f.truncate(0) f.write(existing_content.merge(options).to_yaml) end File.chmod 0600, credentials_file end
credentials_file()
click to toggle source
# File lib/socialcast.rb, line 22 def self.credentials_file ENV['SC_CREDENTIALS_FILE'] || File.join(config_dir, 'credentials.yml') end
resource_for_path(path, options = {}, debug = false)
click to toggle source
configure restclient for api call
# File lib/socialcast.rb, line 41 def self.resource_for_path(path, options = {}, debug = false) RestClient.log = Logger.new(STDOUT) if debug RestClient.proxy = credentials[:proxy] if credentials[:proxy] rest_client_options = options.merge(authentication(options)) rest_client_options[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE if rest_client_options.delete('skip_ssl_validation') url = ['https://', credentials[:domain], path].join RestClient::Resource.new url, rest_client_options end