-
Notifications
You must be signed in to change notification settings - Fork 0
Test Pr #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Pr #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The safe navigation operator (&.) with any? could cause issues if params is not nil but also not a collection that responds to any?. Should check if params is a Hash first or use params.is_a?(Hash) && !params.empty? |
||
| options[:debug_output] = $stdout if @debug | ||
|
|
||
| response = self.class.get @base_url, options | ||
| response = Sync do | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code uses 'Sync' which appears to be undefined. For async/await pattern in Ruby, it should be 'Async' (capital A) instead of 'Sync'. This is a common class provided by the async gem. |
||
| internet = Async::HTTP::Internet.new | ||
| internet.get @base_url, options | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Async::HTTP::Internet#get method expects headers to be passed directly, not nested in an options hash. The correct format should be internet.get(@base_url, headers: { 'User-Agent' => @user_agent }) |
||
| end | ||
|
|
||
| @data = JSON.parse(response.body) | ||
| self | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dependency is specified without a version constraint. This can lead to compatibility issues if breaking changes are introduced in future versions. It's recommended to specify version constraints for all dependencies (e.g. '~> 1.0'). |
||
|
|
||
| # Dev dependencies | ||
| spec.add_development_dependency 'simplecov', '< 0.18' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using an upper bound version constraint ('< 0.18') without a lower bound can be problematic. It's better to specify a range with both lower and upper bounds (e.g. '>= 0.17.1, < 0.18') to ensure compatibility. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an older version of the json gem (2.5.1). More recent versions include security fixes and performance improvements. Should upgrade to latest stable version.