Module: Socialcast

Defined in:
lib/socialcast/cli.rb,
lib/socialcast.rb,
lib/socialcast/message.rb,
lib/socialcast/version.rb

Overview

uncomment to debug HTTP traffic class ActiveResource::Connection

def configure_http(http)
  http = apply_ssl_options(http)
  # Net::HTTP timeouts default to 60 seconds.
  if @timeout
    http.open_timeout = @timeout
    http.read_timeout = @timeout
  end
  http.set_debug_output STDOUT
  http
end

end

Defined Under Namespace

Classes: CLI, Message

Constant Summary collapse

VERSION =
"1.2.3"

Class Method Summary collapse

Class Method Details

.basic_auth_optionsObject



26
27
28
# File 'lib/socialcast.rb', line 26

def basic_auth_options
  {:user => credentials[:user], :password => credentials[:password]}
end

.config_dirObject



8
9
10
11
12
# File 'lib/socialcast.rb', line 8

def config_dir
  config_dir = File.expand_path '~/.socialcast'
  FileUtils.mkdir config_dir, :mode => 0700 unless File.exist?(config_dir)
  config_dir
end

.credentialsObject



16
17
18
19
# File 'lib/socialcast.rb', line 16

def credentials
  fail 'Unknown Socialcast credentials.  Run `socialcast authenticate` to initialize' unless File.exist?(credentials_file)
  @@credentials ||= YAML.load_file(credentials_file)
end

.credentials=(options) ⇒ Object



20
21
22
23
24
25
# File 'lib/socialcast.rb', line 20

def credentials=(options)
  File.open(credentials_file, "w") do |f|
    f.write(options.to_yaml)
  end
  File.chmod 0600, credentials_file
end

.credentials_fileObject



13
14
15
# File 'lib/socialcast.rb', line 13

def credentials_file
  File.join config_dir, 'credentials.yml'
end

.default_optionsObject



29
30
31
# File 'lib/socialcast.rb', line 29

def default_options
  basic_auth_options
end

.resource_for_path(path, options = {}, debug = true) ⇒ Object

configure restclient for api call



33
34
35
36
37
38
# File 'lib/socialcast.rb', line 33

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(default_options)
end