From 07024cdb390e1c84020c899e56d94891ed343819 Mon Sep 17 00:00:00 2001 From: RemoteCTO <768254+RemoteCTO@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:31:25 +0000 Subject: [PATCH] Test. Not working yet --- Gemfile.lock | 47 +++++++++++++++++++++++++++++++++++------- lib/remoteok/client.rb | 9 ++++---- remoteok.gemspec | 2 +- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 00ec061..6fe0b2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,25 +2,54 @@ PATH remote: . specs: remoteok (0.1.0) - httparty (~> 0.18.1) + async-http GEM remote: https://rubygems.org/ specs: ast (2.4.2) + async (2.20.0) + console (~> 1.29) + fiber-annotation + io-event (~> 1.6, >= 1.6.5) + async-http (0.83.1) + async (>= 2.10.2) + async-pool (~> 0.9) + io-endpoint (~> 0.14) + io-stream (~> 0.6) + metrics (~> 0.12) + protocol-http (~> 0.43) + protocol-http1 (>= 0.28.1) + protocol-http2 (~> 0.19) + traces (~> 0.10) + async-pool (0.10.2) + async (>= 1.25) + traces + console (1.29.0) + fiber-annotation + fiber-local (~> 1.1) + json diff-lcs (1.4.4) docile (1.3.5) - httparty (0.18.1) - mime-types (~> 3.0) - multi_xml (>= 0.5.2) + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.0) + io-endpoint (0.14.0) + io-event (1.7.3) + io-stream (0.6.1) json (2.5.1) - mime-types (3.3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) - multi_xml (0.6.0) + metrics (0.12.1) parallel (1.20.1) parser (3.0.1.1) ast (~> 2.4.1) + protocol-hpack (1.5.1) + protocol-http (0.44.0) + protocol-http1 (0.28.1) + protocol-http (~> 0.22) + protocol-http2 (0.20.0) + protocol-hpack (~> 1.4) + protocol-http (~> 0.18) rainbow (3.0.0) rake (13.0.3) regexp_parser (2.1.1) @@ -60,9 +89,11 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + traces (0.14.1) unicode-display_width (2.0.0) PLATFORMS + arm64-darwin-24 x86_64-darwin-19 DEPENDENCIES diff --git a/lib/remoteok/client.rb b/lib/remoteok/client.rb index 2b00635..eba303d 100644 --- a/lib/remoteok/client.rb +++ b/lib/remoteok/client.rb @@ -4,11 +4,9 @@ module RemoteOK # Client class to interact with the API itself class Client require 'json' - require 'httparty' + require 'async/http/internet' require_relative 'job' - include HTTParty - def initialize(**config) @base_url = config[:base_url] || 'https://remoteok.io/api' @debug = config[:debug] || false @@ -20,7 +18,10 @@ def with_fetch(params = {}) options[:query] = params if params&.any? options[:debug_output] = $stdout if @debug - response = self.class.get @base_url, options + response = Sync do + internet = Async::HTTP::Internet.new + internet.get @base_url, options + end @data = JSON.parse(response.body) self diff --git a/remoteok.gemspec b/remoteok.gemspec index 78bf759..71df2a2 100644 --- a/remoteok.gemspec +++ b/remoteok.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] # Prod dependencies - spec.add_dependency 'httparty', '~> 0.18.1' + spec.add_dependency 'async-http' # Dev dependencies spec.add_development_dependency 'simplecov', '< 0.18'