lib/yao/faraday_middlewares.rb in yao-0.6.3 vs lib/yao/faraday_middlewares.rb in yao-0.7.0
- old
+ new
@@ -104,12 +104,13 @@
end
Faraday::Response.register_middleware os_dumper: -> { Faraday::Response::OSDumper }
class Faraday::Response::OSResponseRecorder < Faraday::Response::Middleware
def on_complete(env)
- require 'pathname'
- root = Pathname.new(File.expand_path('../../../tmp', __FILE__))
- Dir.mkdir(root) unless File.exist?(root)
+ require 'tmpdir'
+
+ @@tmpdir ||= Dir.mktmpdir('yao-')
+ root = Pathname.new(@@tmpdir)
path = [env.method.to_s.upcase, env.url.path.gsub('/', '-')].join("-") + ".json"
puts root.join(path)
File.open(root.join(path), 'w') do |f|