mirror of
https://gitea.invidious.io/iv-org/shard-athena-negotiation.git
synced 2024-08-15 00:53:23 +00:00
Fix lint issues
Add getters for more specialized negotiators
This commit is contained in:
parent
3850074f02
commit
b860bdfd27
7 changed files with 24 additions and 5 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -32,6 +32,8 @@ jobs:
|
|||
image: crystallang/crystal:latest-alpine
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Dependencies
|
||||
run: shards install
|
||||
- name: Specs
|
||||
run: crystal spec --order random --error-on-warnings
|
||||
test_nightly:
|
||||
|
@ -40,5 +42,7 @@ jobs:
|
|||
image: crystallang/crystal:nightly-alpine
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Dependencies
|
||||
run: shards install
|
||||
- name: Specs
|
||||
run: crystal spec --order random --error-on-warnings
|
||||
|
|
4
.github/workflows/deployment.yml
vendored
4
.github/workflows/deployment.yml
vendored
|
@ -14,8 +14,10 @@ jobs:
|
|||
- name: Install Build Dependencies
|
||||
run: apk add --update rsync
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Dependencies
|
||||
run: shards install
|
||||
- name: Build
|
||||
run: crystal docs
|
||||
run: crystal docs lib/athena-spec/src/athena-spec.cr src/athena-negotiation.cr
|
||||
- name: Deploy
|
||||
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||
with:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[](https://github.com/athena-framework/negotiation/actions?query=workflow%3ACI)
|
||||
[](https://github.com/athena-framework/negotiation/releases)
|
||||
|
||||
Framework agnostic content negotiation library.
|
||||
Framework agnostic [content negotiation](https://tools.ietf.org/html/rfc7231#section-5.3) library based on [willdurand/Negotiation](https://github.com/willdurand/Negotiation).
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ abstract class Athena::Negotiation::AbstractNegotiator
|
|||
|
||||
matches = self.find_matches accepted_headers, accepted_priorties
|
||||
|
||||
specific_matches = matches.reduce({} of Int32 => ANG::AcceptMatch) do |matches, match|
|
||||
ANG::AcceptMatch.reduce matches, match
|
||||
specific_matches = matches.reduce({} of Int32 => ANG::AcceptMatch) do |acc, match|
|
||||
ANG::AcceptMatch.reduce acc, match
|
||||
end.values
|
||||
|
||||
specific_matches.sort!
|
||||
|
|
|
@ -14,5 +14,15 @@ require "./exceptions/*"
|
|||
alias ANG = Athena::Negotiation
|
||||
|
||||
module Athena::Negotiation
|
||||
# Returns an `ANG::Negotiation` singleton instance.
|
||||
class_getter(negotiator) { ANG::Negotiator.new }
|
||||
|
||||
# Returns an `ANG::CharsetNegotiator` singleton instance.
|
||||
class_getter(charset_negotiator) { ANG::CharsetNegotiator.new }
|
||||
|
||||
# Returns an `ANG::EncodingNegotiator` singleton instance.
|
||||
class_getter(encoding_negotiator) { ANG::EncodingNegotiator.new }
|
||||
|
||||
# Returns an `ANG::LanguageNegotiator` singleton instance.
|
||||
class_getter(language_negotiator) { ANG::LanguageNegotiator.new }
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ abstract struct Athena::Negotiation::BaseAccept
|
|||
unless @parameters.empty?
|
||||
io << "; "
|
||||
# TODO: Do we care the parameters aren't sorted?
|
||||
parameters.join(io, "; ") { |(k, v), io| io << "#{k}=#{v}" }
|
||||
parameters.join(io, "; ") { |(k, v), join_io| join_io << "#{k}=#{v}" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require "./abstract_negotiator"
|
||||
|
||||
class Athena::Negotiation::Negotiator < Athena::Negotiation::AbstractNegotiator
|
||||
# TODO: Make this method less complex.
|
||||
#
|
||||
# ameba:disable Metrics/CyclomaticComplexity
|
||||
protected def match(accept : ANG::Accept, priority : ANG::Accept, index : Int32) : ANG::AcceptMatch?
|
||||
accept_base = accept.base_part
|
||||
priority_base = priority.base_part
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue