class Sparoid::CLI
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/sparoid/cli.rb, line 37 def self.exit_on_failure? true end
Public Instance Methods
auth(host, port = 8484)
click to toggle source
# File lib/sparoid/cli.rb, line 11 def auth(host, port = 8484) send_auth(host, port, options[:config]) rescue Errno::ENOENT abort "Sparoid: Config not found" rescue StandardError => e abort "Sparoid: #{e.message} (#{host})" end
connect(host, port, spa_port = 8484)
click to toggle source
# File lib/sparoid/cli.rb, line 21 def connect(host, port, spa_port = 8484) begin send_auth(host, spa_port, options[:config]) rescue Errno::ENOENT warn "Sparoid: Config not found" end Sparoid.fdpass(host, port) rescue StandardError => e abort "Sparoid: #{e.message} (#{host})" end
keygen()
click to toggle source
# File lib/sparoid/cli.rb, line 33 def keygen Sparoid.keygen end
Private Instance Methods
get_keys(config)
click to toggle source
# File lib/sparoid/cli.rb, line 57 def get_keys(config) config.values_at("key", "hmac-key") end
parse_ini(path)
click to toggle source
# File lib/sparoid/cli.rb, line 48 def parse_ini(path) File.readlines(File.expand_path(path)).map! { |line| line.split("=", 2).map!(&:strip) }.to_h rescue Errno::ENOENT { "key" => ENV["SPAROID_KEY"], "hmac-key" => ENV["SPAROID_HMAC_KEY"] } end
send_auth(host, port, config)
click to toggle source
# File lib/sparoid/cli.rb, line 43 def send_auth(host, port, config) key, hmac_key = get_keys(parse_ini(config)) Sparoid.auth(key, hmac_key, host, port.to_i) end