lib/gom/remote/connection.rb in gom-script-0.1.3 vs lib/gom/remote/connection.rb in gom-script-0.1.4
- old
+ new
@@ -64,9 +64,23 @@
def write_node path, attributes
raise "not yet implemented"
end
+ def destroy path
+ url = "#{@target_url}#{path}"
+ uri = URI.parse url
+ req = Net::HTTP::Delete.new uri.path
+
+ session = (Net::HTTP.new uri.host, uri.port)
+ case res = session.start { |http| http.request req }
+ when Net::HTTPSuccess, Net::HTTPRedirection
+ # OK
+ else
+ res.error!
+ end
+ end
+
def read path
url = "#{@target_url}#{path}"
open(url).read
rescue Timeout::Error => e
raise "connection timeout: #{url}"