generated from lostisland/faraday-adapter-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move HTTPClient adapter from Faraday
- Loading branch information
Showing
18 changed files
with
516 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main, setup-ci] | ||
schedule: | ||
- cron: '0 8 * * 1' # At 8:00 on Monday | ||
|
||
env: | ||
GIT_COMMIT_SHA: ${{ github.sha }} | ||
GIT_BRANCH: ${{ github.ref }} | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Ruby 2.7 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7 | ||
|
||
- name: Rubocop | ||
run: | | ||
bin/setup | ||
bin/ci-lint | ||
test: | ||
needs: [lint] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby: ['2.5', '2.6', '2.7', '3.0'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
|
||
- name: Build | ||
run: | | ||
bin/setup | ||
- name: Test | ||
run: | | ||
bin/ci-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
name: Publish to Rubygems | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Ruby 2.7 | ||
uses: actions/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.7.x | ||
|
||
- name: Publish to RubyGems | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
gem build faraday-httpclient.gemspec | ||
gem push faraday-httpclient-*.gem | ||
env: | ||
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
inherit_from: .rubocop_todo.yml | ||
|
||
require: | ||
- rubocop-packaging | ||
- rubocop-performance | ||
|
||
AllCops: | ||
DisplayCopNames: true | ||
DisplayStyleGuide: true | ||
TargetRubyVersion: 2.4 | ||
SuggestExtensions: false | ||
NewCops: enable | ||
|
||
Metrics/BlockLength: | ||
Exclude: | ||
- spec/**/*.rb | ||
- examples/**/*.rb | ||
|
||
Layout/EmptyLinesAroundAttributeAccessor: # (0.83) | ||
Enabled: true | ||
|
||
Layout/LineLength: | ||
Exclude: | ||
- spec/**/*.rb | ||
- examples/**/*.rb | ||
|
||
Layout/SpaceAroundMethodCallOperator: | ||
Enabled: true | ||
|
||
Lint/DeprecatedOpenSSLConstant: # (0.84) | ||
Enabled: true | ||
|
||
Lint/RaiseException: | ||
Enabled: true | ||
|
||
Lint/StructNewOverride: | ||
Enabled: true | ||
|
||
Style/DoubleNegation: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Exclude: | ||
- 'spec/**/*' | ||
- 'examples/**/*' | ||
|
||
Style/ExponentialNotation: | ||
Enabled: true | ||
Style/HashEachMethods: | ||
Enabled: true | ||
Style/HashTransformKeys: | ||
Enabled: true | ||
Style/HashTransformValues: | ||
Enabled: true | ||
Style/IfUnlessModifier: | ||
Enabled: false | ||
|
||
Style/SlicingWithRange: # (0.83) | ||
Enabled: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2021-07-04 13:33:15 UTC using RuboCop version 1.12.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 4 | ||
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. | ||
Metrics/AbcSize: | ||
Max: 37 | ||
|
||
# Offense count: 2 | ||
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. | ||
Metrics/MethodLength: | ||
Max: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer at giuffrida.mattia AT gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,62 @@ | ||
# Faraday Adapter Template | ||
# Faraday HTTPClient adapter | ||
|
||
This repo is a template for building [Faraday][faraday] adapters. | ||
This gem is a [Faraday][faraday] adapter for the [HTTPClient][httpclient] library. | ||
Faraday is an HTTP client library that provides a common interface over many adapters. | ||
Every adapter is defined into it's own gem. Use this repository to create your own adapter gem. | ||
Every adapter is defined into its own gem. This gem defines the adapter for HTTPClient. | ||
|
||
## Getting Started | ||
## Installation | ||
|
||
### Setting up and cloning the repo | ||
Add these lines to your application's Gemfile: | ||
|
||
You can start using GitHub's [Use this template][use-template] button. | ||
![Use this template](https://docs.github.com/assets/images/help/repository/use-this-template-button.png) | ||
```ruby | ||
gem 'httpclient', '>= 2.2' | ||
gem 'faraday' | ||
gem 'faraday-httpclient' | ||
``` | ||
|
||
This will create a repository based off from this template. | ||
After that is created, you can clone it locally to start working on it. | ||
And then execute: | ||
|
||
### Refactoring the template | ||
$ bundle install | ||
|
||
The next step is for you to find and replace all the "parametrised" names in this template and change them to make it unique. | ||
First of all, you should decide on the name of your adapter. | ||
The current convention (which is by no means mandatory) is to call adapter gems as `faraday-<adapter_name>`. | ||
Here are some examples: | ||
Or install them yourself as: | ||
|
||
* `HTTP`: [`faraday-http`][faraday-http] | ||
* `Net::HTTP`: [`faraday-net_http`][faraday-net_http] | ||
$ gem install httpclient -v '>= 2.2' | ||
$ gem install faraday faraday-httpclient | ||
|
||
In this template repository, the placeholder for your chosen adapter name is `MyAdapter` (`my_adapter`). | ||
So once you decide on the final name you want to use you should update all occurrences of `MyAdapter` and all files with `my_adapter` in their name with the new name you chose. | ||
## Usage | ||
|
||
### Main implementation | ||
Configure your Faraday connection to use this adapter like this: | ||
|
||
The bulk of the implementation is in the `Faraday::Adapter::MyAdapter` class. | ||
We've added lots of comments in there to guide you through it, but if you have any doubt/question please don't hesitate to get in touch! | ||
```ruby | ||
connection = Faraday.new(url, conn_options) do |conn| | ||
conn.adapter(:httpclient) | ||
end | ||
``` | ||
|
||
For more information on how to setup your Faraday connection and adapters usage, please refer to the [Faraday Website][faraday-website]. | ||
|
||
## Development | ||
|
||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. | ||
|
||
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](rubygems). | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on [GitHub][repo]. | ||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the [license][license]. | ||
|
||
## Code of Conduct | ||
|
||
Everyone interacting in the Faraday HTTPClient adapter project's codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][code-of-conduct]. | ||
|
||
[faraday]: https://github.com/lostisland/faraday | ||
[faraday-http]: https://github.com/lostisland/faraday-http | ||
[faraday-net_http]: https://github.com/lostisland/faraday-net_http | ||
[use-template]: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template | ||
[faraday-website]: https://lostisland.github.io/faraday | ||
[httpclient]: https://github.com/nahi/httpclient | ||
[rubygems]: https://rubygems.org | ||
[repo]: https://github.com/lostisland/faraday-httpclient | ||
[license]: https://github.com/lostisland/faraday-httpclient/blob/main/LICENSE.md | ||
[code-of-conduct]: https://github.com/lostisland/faraday-httpclient/blob/main/CODE_OF_CONDUCT.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.