
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
ApiWrapper
is a Ruby gem that offers an easy and flexible way to handle API interactions.
Add this to your Gemfile:
gem 'api_wrapper'
Then run
bundle install
By default, ApiWrapper looks for an API configuration file at config/api_endpoints.yml
(see API Configuration File) in your root directory of your application and uses in-memory caching. You can fetch data from an API endpoint like this:
require 'api_wrapper'
# Fetch data from an API endpoint using the default settings
response = ApiWrapper.fetch_data('endpoint_key')
puts response.body
You can customize the API configuration path and cache store by configuring ApiWrapper:
require 'api_wrapper'
# Configure ApiWrapper with custom settings
ApiWrapper.configure do |config|
config.api_configuration_path = 'custom/path/to/api_configuration.yml'
config.cache_store = CustomCacheStore.new # TODO: Update details on CustomCacheStore later
end
# Fetch data with the custom configuration
response = ApiWrapper.fetch_data('endpoint_key')
puts response.body
If you change the configuration and want to reset the API manager, call:
ApiWrapper.reset_api_manager!
This will create a new instance of ApiManager with the updated settings.
You can adjust two main settings:
API Configuration Path: This is the path to the YAML file that defines your API endpoints. By default, it’s set to config/api_endpoints.yml. You can also set it through the environment variable ENV['API_CONFIGURATION_PATH'].
Cache Store: This is where API responses are stored. By default, ApiWrapper uses an in-memory cache. You can customize this to use a different cache store, such as Redis. You can also set the cache type through ENV['CACHE_STORE_TYPE'].
Your configuration file (api_endpoints.yml) defines the base URL for the API and the available endpoints. Here’s an example:
base_url: https://api.example.com/
apis:
endpoint1:
path: 'path/to/endpoint1'
description: 'Endpoint 1 description'
no_cache: true
endpoint2:
path: 'path/to/endpoint2'
description: 'Endpoint 2 description'
ttl: 600
ApiWrapper.fetch_data(endpoint_key, force_refresh: false)
: Fetches data from the specified API endpoint.ApiWrapper.configure { |config| ... }
: Allows you to configure the gem with custom settings.ApiWrapper.reset_api_manager!
: Resets the ApiManager instance, which will use any new settings.To get started with contributing to ApiWrapper, follow these steps:
Clone the repository:
First, clone the repository to your local machine and navigate to the project directory:
git clone https://github.com/ahasunos/api_wrapper.git
cd api_wrapper
Install dependencies:
After navigating to the project directory, install the required gems using Bundler:
bundle install
The project uses RSpec for testing. Before submitting any changes, make sure to run the test suite to ensure that everything works as expected:
bundle exec rspec
To maintain consistent code quality and style, the project uses RuboCop for linting. Before submitting a pull request, ensure that your code adheres to the project's style guidelines by running RuboCop:
bundle exec rubocop
If RuboCop identifies any issues, it will provide suggestions for how to fix them.
Bug reports and pull requests are welcome on GitHub at https://github.com/ahasunos/api_wrapper. For major changes, please open an issue first to discuss what you would like to change.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the NseData project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that api_wrapper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.