lib/scouter/pocket.rb in scouter-0.0.4 vs lib/scouter/pocket.rb in scouter-0.0.5

- old
+ new

@@ -1,43 +1,15 @@ module Scouter - class Pocket < Scouter::Base::Object + class Pocket < Scouter::Base::SingleUrlApi END_POINT = 'https://widgets.getpocket.com'.freeze - # Get Pocket Count - # @param [String or Array] urls - # @return [Hashie::Mash, Array] URL & count hash, Error - def self.get_count(urls) - urls = check_and_trans_url(urls) - results, errors = {}, [] - urls.each_with_index do |u, idx| - sleep(WAIT_SEC) if idx != 0 - res, error = get_and_parse_response(u) - errors << error && next if error - results.merge!(res) - end - res_hash = Hashie::Mash.new(results) - return [res_hash, errors] - end - # Set API parameter for test mock # @param [String or Array] num def self.set_api_random(num) @@api_rand_num = num end private - - # Get and parse response data - # @param [String] url URL - # @return [Hash, String] URL & count hash, Error message - def self.get_and_parse_response(url) - html = get_response(api_url(url)) - res = parse_response(html, url) - return [res, nil] - rescue => e - message = "#{e.message}, url: #{url}" - return [nil, message] - end # Build Pocket API URL # @param [String] url # @return [String] API url def self.api_url(url)