lib/spaceship/client.rb in spaceship-0.15.2 vs lib/spaceship/client.rb in spaceship-0.16.0
- old
+ new
@@ -62,15 +62,16 @@
def self.hostname
raise "You must implemented self.hostname"
end
def initialize
+ @cookie = HTTP::CookieJar.new
@client = Faraday.new(self.class.hostname) do |c|
c.response :json, content_type: /\bjson$/
c.response :xml, content_type: /\bxml$/
c.response :plist, content_type: /\bplist$/
- c.use :cookie_jar
+ c.use :cookie_jar, jar: @cookie
c.adapter Faraday.default_adapter
if ENV['DEBUG']
# for debugging only
# This enables tracking of networking requests using Charles Web Proxy
@@ -82,11 +83,11 @@
# The logger in which all requests are logged
# /tmp/spaceship[time].log by default
def logger
unless @logger
- if $verbose || ENV["VERBOSE"]
+ if ENV["VERBOSE"]
@logger = Logger.new(STDOUT)
else
# Log to file by default
path = "/tmp/spaceship#{Time.now.to_i}.log"
@logger = Logger.new(path)
@@ -96,9 +97,17 @@
"[#{datetime.strftime('%H:%M:%S')}]: #{msg}\n"
end
end
@logger
+ end
+
+ ##
+ # Return the session cookie.
+ #
+ # @return (String) the cookie-string in the RFC6265 format: https://tools.ietf.org/html/rfc6265#section-4.2.1
+ def cookie
+ @cookie.map(&:to_s).join(';')
end
#####################################################
# @!group Automatic Paging
#####################################################