From 830fcbbbfe5b333d46f4e5cdba88178e702480d1 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Fri, 17 Feb 2023 20:39:51 +0000 Subject: [PATCH 1/3] Enhanced RDoc for Net::HTTP --- lib/net/http.rb | 119 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 22 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 4a6ad8b0..cac2edc7 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1634,7 +1634,7 @@ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+ # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Head object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+ and initial headers hash +initheader+: # # res = http.head('/todos/1') # => # # res.body # => nil @@ -1644,6 +1644,7 @@ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+ # ["content-type", ["application/json; charset=utf-8"]], # ["connection", ["close"]]] # + # def head(path, initheader = nil) request(Head.new(path, initheader)) end @@ -1709,66 +1710,140 @@ def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segm send_entity(path, data, initheader, dest, Patch, &block) end - def put(path, data, initheader = nil) #:nodoc: + # Sends a PUT request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Put object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.put('/todos/1', data) # => # + # + def put(path, data, initheader = nil) request(Put.new(path, initheader), data) end - # Sends a PROPPATCH request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a PROPPATCH request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Proppatch object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.proppatch('/todos/1', data) + # def proppatch(path, body, initheader = nil) request(Proppatch.new(path, initheader), body) end - # Sends a LOCK request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a LOCK request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Lock object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.lock('/todos/1', data) + # def lock(path, body, initheader = nil) request(Lock.new(path, initheader), body) end - # Sends a UNLOCK request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends an UNLOCK request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Unlock object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.unlock('/todos/1', data) + # def unlock(path, body, initheader = nil) request(Unlock.new(path, initheader), body) end - # Sends a OPTIONS request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends an Options request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Options object + # created from string +path+ and initial headers hash +initheader+. + # + # http.options('/') + # def options(path, initheader = nil) request(Options.new(path, initheader)) end - # Sends a PROPFIND request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a PROPFIND request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Propfind object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.propfind('/todos/1', data) + # def propfind(path, body = nil, initheader = {'Depth' => '0'}) request(Propfind.new(path, initheader), body) end - # Sends a DELETE request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a DELETE request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Delete object + # created from string +path+ and initial headers hash +initheader+. + # + # http.delete('/todos/1') + # def delete(path, initheader = {'Depth' => 'Infinity'}) request(Delete.new(path, initheader)) end - # Sends a MOVE request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a MOVE request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Move object + # created from string +path+ and initial headers hash +initheader+. + # + # http.move('/todos/1') + # def move(path, initheader = nil) request(Move.new(path, initheader)) end - # Sends a COPY request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a COPY request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Copy object + # created from string +path+ and initial headers hash +initheader+. + # + # http.copy('/todos/1') + # def copy(path, initheader = nil) request(Copy.new(path, initheader)) end - # Sends a MKCOL request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a MKCOL request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Mkcol object + # created from string +path+ and initial headers hash +initheader+. + # + # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' + # http.mkcol('/todos/1', data) + # def mkcol(path, body = nil, initheader = nil) request(Mkcol.new(path, initheader), body) end - # Sends a TRACE request to the +path+ and gets a response, - # as an HTTPResponse object. + # Sends a TRACE request to the server; + # returns an instance of a subclass of Net::HTTPResponse. + # + # The request is based on the Net::HTTP::Trace object + # created from string +path+ and initial headers hash +initheader+. + # + # http.trace('/todos/1') + # def trace(path, initheader = nil) request(Trace.new(path, initheader)) end From 6b3cf2a67d042373ed95ebd55b102c8aab1b3e28 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Fri, 17 Feb 2023 20:42:02 +0000 Subject: [PATCH 2/3] Enhanced RDoc for Net::HTTP --- lib/net/http.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index cac2edc7..afa50dab 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1644,7 +1644,6 @@ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+ # ["content-type", ["application/json; charset=utf-8"]], # ["connection", ["close"]]] # - # def head(path, initheader = nil) request(Head.new(path, initheader)) end From 624df3381e9399c74cc803be1e38c4e76a531ec6 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Fri, 17 Feb 2023 22:06:59 +0000 Subject: [PATCH 3/3] Enhanced RDoc for Net::HTTP --- lib/net/http.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index afa50dab..a6d41b38 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1713,7 +1713,7 @@ def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segm # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Put object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +data+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.put('/todos/1', data) # => # @@ -1726,7 +1726,7 @@ def put(path, data, initheader = nil) # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Proppatch object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +body+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.proppatch('/todos/1', data) @@ -1739,7 +1739,7 @@ def proppatch(path, body, initheader = nil) # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Lock object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +body+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.lock('/todos/1', data) @@ -1752,7 +1752,7 @@ def lock(path, body, initheader = nil) # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Unlock object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +body+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.unlock('/todos/1', data) @@ -1777,7 +1777,7 @@ def options(path, initheader = nil) # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Propfind object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +body+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.propfind('/todos/1', data) @@ -1826,7 +1826,7 @@ def copy(path, initheader = nil) # returns an instance of a subclass of Net::HTTPResponse. # # The request is based on the Net::HTTP::Mkcol object - # created from string +path+ and initial headers hash +initheader+. + # created from string +path+, string +body+, and initial headers hash +initheader+. # # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' # http.mkcol('/todos/1', data)