From bb84940a7ab52fd69f7c25e548ca2443a99766a1 Mon Sep 17 00:00:00 2001 From: bpmcdevitt Date: Thu, 2 Jan 2020 01:19:10 -0600 Subject: [PATCH] slowly updating documentation with rdoc stuff so we can generate yard server --- lib/pastebinner/api_client.rb | 20 ++++++++++++++++---- pastebinner.gemspec | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/pastebinner/api_client.rb b/lib/pastebinner/api_client.rb index b096ad0..98ae8ca 100644 --- a/lib/pastebinner/api_client.rb +++ b/lib/pastebinner/api_client.rb @@ -101,6 +101,9 @@ module Pastebinner params = { 'api_dev_key': api_dev_key } end + # Send a POST request to the /api_post.php endpoint. + # @param params [Hash] object + # @return [RestClient::Response] object def api_post(params) response = RestClient::Request.execute( method: :post, @@ -109,8 +112,10 @@ module Pastebinner ) end - # params is optional for now. to query specific language ?lang=ruby as an example - # right now its set to grab the max 250, default is 50. param is ?limit=value + # Scrape public pastes can specify specific language with options + # @param params DOES NOT WORK - optional, specific language query with ?lang=ruby as an example. + # @param limit the number of pastes to scrape + # @return [RestClient::Response] object def scrape_public_pastes(_params = nil, limit) response = RestClient::Request.execute( method: :get, @@ -118,13 +123,17 @@ module Pastebinner ) end - # will extract just the keys from recent public pastes - # i think this can be maybe made into a hash instead + # Extracts just the keys from recent public pastes. + # @param public_pastes [Restclient::Resposne, Restclient::Response] An array of public paste responses returned from the scrape_public_pastes method. + # @return ['paste_key1, paste_key2, paste_key3'] An Array of Strings that are unique paste keys. def get_unique_paste_keys(public_pastes) pp = JSON.parse(public_pastes) pp.map { |p| p['key'] } end + # Sends a GET request to the scraping API with the unique paste key of the paste intended to download + # @param unique_paste_key [String] The unique paste key of the paste + # @return [RestClient::Response] object def raw_paste_data(unique_paste_key) response = RestClient::Request.execute( method: :get, @@ -132,6 +141,9 @@ module Pastebinner ) end + # Sends a GET request to the scraping API with the unique paste key of the paste intended. Pulls metadata info. + # @param raw_paste_metadata [String] The unique paste key of the paste + # @return [Json object?] need to test this. def raw_paste_metadata(unique_paste_key) response = RestClient::Request.execute( method: :get, diff --git a/pastebinner.gemspec b/pastebinner.gemspec index c1164d7..dae045c 100644 --- a/pastebinner.gemspec +++ b/pastebinner.gemspec @@ -33,5 +33,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'pry', '~> 0.11' + spec.add_development_dependency 'yard', '~> 0.9.22' spec.add_runtime_dependency 'rest-client', '~> 2.0' end