accept_language 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{LICENSE.txt → LICENSE.md} +1 -1
- data/README.md +40 -21
- data/lib/accept_language.rb +9 -6
- data/lib/accept_language/intersection.rb +32 -26
- data/lib/accept_language/parser.rb +13 -19
- metadata +92 -50
- data/.gitignore +0 -8
- data/.rspec +0 -3
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -29
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -61
- data/Rakefile +0 -20
- data/VERSION.semver +0 -1
- data/accept_language.gemspec +0 -30
- data/bin/console +0 -8
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b2ef71586c1b52c839323443779e12b8feff9b54aa818b11d427762b1fac5ae
|
4
|
+
data.tar.gz: 99f4391638e32daa51aac44ca008cef6bfaf37a4a40a3ffdab10959dcb023753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b61d1f98342c9e8e90bd72c9b3c906a9b52c01f8adb7a1edd7165a6303c61dbd8e202cfdc45eb9d8f1d57ab855052bc2d8c6bfac4e73c2b4a3df95be70bed24
|
7
|
+
data.tar.gz: 2cd335536235546b9c95b2ebcca1f6cfadfa9a0c9d03b5d33f3cc1a6b8965bec958ada7a79c78248ca7f8d7aa083ee42d3e5181b1496f717d99f9768c1c94213
|
data/{LICENSE.txt → LICENSE.md}
RENAMED
data/README.md
CHANGED
@@ -5,15 +5,15 @@ A tiny library for parsing the `Accept-Language` header from browsers (as define
|
|
5
5
|
## Status
|
6
6
|
|
7
7
|
[](https://badge.fury.io/rb/accept_language)
|
8
|
-
[](https://inch-ci.org/github/cyril/accept_language)
|
8
|
+
[](https://travis-ci.org/cyril/accept_language.rb)
|
9
|
+
[](https://inch-ci.org/github/cyril/accept_language.rb)
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem
|
16
|
+
gem "accept_language"
|
17
17
|
```
|
18
18
|
|
19
19
|
And then execute:
|
@@ -28,31 +28,54 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
It's intended to be used in a Web server that supports some level of internationalization (i18n), but can be used anytime an `Accept-Language` header string is available.
|
30
30
|
|
31
|
-
|
31
|
+
Examples:
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
AcceptLanguage.parse(
|
35
|
-
AcceptLanguage.parse(
|
34
|
+
AcceptLanguage.parse("da, en-gb;q=0.8, en;q=0.7") # => {:da=>1.0, :"en-gb"=>0.8, :en=>0.7}
|
35
|
+
AcceptLanguage.parse("fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5") # => {:"fr-ch"=>1.0, :fr=>0.9, :en=>0.8, :de=>0.7, :*=>0.5}
|
36
36
|
```
|
37
37
|
|
38
38
|
In order to help facilitate better i18n, a method is provided to return the intersection of the languages the user prefers and the languages your application supports.
|
39
39
|
|
40
|
-
|
40
|
+
Examples:
|
41
41
|
|
42
42
|
```ruby
|
43
|
-
AcceptLanguage.intersection(
|
44
|
-
AcceptLanguage.intersection(
|
45
|
-
AcceptLanguage.intersection(
|
46
|
-
AcceptLanguage.intersection(
|
47
|
-
AcceptLanguage.intersection(
|
48
|
-
AcceptLanguage.intersection(
|
49
|
-
AcceptLanguage.intersection(
|
50
|
-
AcceptLanguage.intersection('fr;q=0, zh;q=0.4', :fr) # => nil
|
43
|
+
AcceptLanguage.intersection("da, en-gb;q=0.8, en;q=0.7", :ja, :ro, :da) # => :da
|
44
|
+
AcceptLanguage.intersection("da, en-gb;q=0.8, en;q=0.7", :ja, :ro) # => nil
|
45
|
+
AcceptLanguage.intersection("fr-CH", :fr, two_letter_truncate: false) # => nil
|
46
|
+
AcceptLanguage.intersection("fr-CH", :fr, two_letter_truncate: true) # => :fr
|
47
|
+
AcceptLanguage.intersection("de, zh;q=0.4, fr;q=0", :fr) # => nil
|
48
|
+
AcceptLanguage.intersection("de, zh;q=0.4, *;q=0.5, fr;q=0", :fr) # => nil
|
49
|
+
AcceptLanguage.intersection("de, zh;q=0.4, *;q=0.5, fr;q=0", :ar) # => :ar
|
51
50
|
```
|
52
51
|
|
53
|
-
|
52
|
+
### Rails integration example
|
54
53
|
|
55
|
-
|
54
|
+
```ruby
|
55
|
+
# app/controllers/application_controller.rb
|
56
|
+
class ApplicationController < ActionController::Base
|
57
|
+
before_action :best_locale_from_request!
|
58
|
+
|
59
|
+
def best_locale_from_request!
|
60
|
+
I18n.locale = best_locale_from_request
|
61
|
+
end
|
62
|
+
|
63
|
+
def best_locale_from_request
|
64
|
+
return I18n.default_locale unless request.headers.key?("HTTP_ACCEPT_LANGUAGE")
|
65
|
+
|
66
|
+
string = request.headers.fetch("HTTP_ACCEPT_LANGUAGE")
|
67
|
+
locale = AcceptLanguage.intersection(string, I18n.default_locale, *I18n.available_locales)
|
68
|
+
|
69
|
+
# If the server cannot serve any matching language,
|
70
|
+
# it can theoretically send back a 406 (Not Acceptable) error code.
|
71
|
+
# But, for a better user experience, this is rarely done and more
|
72
|
+
# common way is to ignore the Accept-Language header in this case.
|
73
|
+
return I18n.default_locale if locale.nil?
|
74
|
+
|
75
|
+
locale
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
56
79
|
|
57
80
|
## Versioning
|
58
81
|
|
@@ -61,7 +84,3 @@ __AcceptLanguage__ uses [Semantic Versioning 2.0.0](https://semver.org/)
|
|
61
84
|
## License
|
62
85
|
|
63
86
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
64
|
-
|
65
|
-
## Code of Conduct
|
66
|
-
|
67
|
-
Everyone interacting in the AcceptLanguage project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cyril/accept_language/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/accept_language.rb
CHANGED
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
# Tiny library for parsing the Accept-Language header.
|
4
4
|
module AcceptLanguage
|
5
|
-
|
6
|
-
|
5
|
+
# @example
|
6
|
+
# AcceptLanguage.intersection('ja, en-gb;q=0.8, en;q=0.7', :ar, :ja) # => :ja
|
7
|
+
def self.intersection(raw_input, *supported_langs, two_letter_truncate: true)
|
8
|
+
Intersection.new(raw_input, *supported_langs, two_letter_truncate: two_letter_truncate).call
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
# @example
|
12
|
+
# AcceptLanguage.parse('ja, en-gb;q=0.8, en;q=0.7') # => { ja: 1.0, "en-gb": 0.8, en: 0.7 }
|
13
|
+
def self.parse(raw_input, two_letter_truncate: false)
|
14
|
+
Parser.call(raw_input, two_letter_truncate: two_letter_truncate)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
|
-
require_relative
|
15
|
-
require_relative 'accept_language/parser'
|
18
|
+
require_relative "accept_language/intersection"
|
@@ -2,51 +2,57 @@
|
|
2
2
|
|
3
3
|
module AcceptLanguage
|
4
4
|
# @example
|
5
|
-
# Intersection.new('
|
5
|
+
# AcceptLanguage::Intersection.new('ja, en-gb;q=0.8, en;q=0.7', :ar, :ja).call # => :ja
|
6
6
|
# @note Compare an Accept-Language header value with your application's
|
7
7
|
# supported languages to find the common languages that could be presented
|
8
8
|
# to a user.
|
9
9
|
# @see https://tools.ietf.org/html/rfc2616#section-14.4
|
10
10
|
class Intersection
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :preferences, :supported_langs
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
15
|
-
@default_supported_language = default_supported_language.to_sym
|
16
|
-
@other_supported_languages = other_supported_languages.map(&:to_sym).to_set
|
13
|
+
def initialize(raw_input, *supported_langs, two_letter_truncate: true)
|
14
|
+
@preferences = Parser.call(raw_input, two_letter_truncate: two_letter_truncate)
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
@default_supported_language = @default_supported_language[0, 2].to_sym
|
25
|
-
|
26
|
-
@other_supported_languages = @other_supported_languages.map do |other_supported_language|
|
27
|
-
other_supported_language[0, 2].to_sym
|
28
|
-
end.to_set
|
16
|
+
@supported_langs = supported_langs.map do |lang|
|
17
|
+
lang = lang.downcase
|
18
|
+
lang = lang[0, 2] if two_letter_truncate
|
19
|
+
lang.to_sym
|
20
|
+
end.uniq
|
29
21
|
end
|
30
22
|
|
31
23
|
def call
|
32
|
-
|
33
|
-
|
24
|
+
qualities_without_zero_in_desc_order.each do |quality|
|
25
|
+
tag = preferences.key(quality)
|
26
|
+
|
27
|
+
if wildcard?(tag)
|
28
|
+
lang = any_tag_not_matched_by_any_other_range
|
29
|
+
return lang unless lang.nil?
|
30
|
+
end
|
34
31
|
|
35
|
-
|
32
|
+
return tag if supported_langs.include?(tag)
|
36
33
|
end
|
34
|
+
|
35
|
+
nil
|
37
36
|
end
|
38
37
|
|
39
38
|
protected
|
40
39
|
|
41
|
-
def
|
42
|
-
|
40
|
+
def any_tag_not_matched_by_any_other_range
|
41
|
+
every_tag_not_matched_by_any_other_range.first
|
42
|
+
end
|
43
|
+
|
44
|
+
def every_tag_not_matched_by_any_other_range
|
45
|
+
supported_langs - preferences.keys
|
46
|
+
end
|
47
|
+
|
48
|
+
def qualities_without_zero_in_desc_order
|
49
|
+
preferences.values.reject(&:zero?).uniq.sort.reverse
|
43
50
|
end
|
44
51
|
|
45
|
-
def wildcard
|
46
|
-
:*
|
52
|
+
def wildcard?(value)
|
53
|
+
value.equal?(:*)
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
51
|
-
require_relative
|
52
|
-
require 'set'
|
58
|
+
require_relative "parser"
|
@@ -2,30 +2,24 @@
|
|
2
2
|
|
3
3
|
module AcceptLanguage
|
4
4
|
# @example
|
5
|
-
# Parser.
|
6
|
-
# @note Parse
|
7
|
-
# language tags.
|
5
|
+
# AcceptLanguage::Parser.call('da, en-gb;q=0.8, en;q=0.7') # => { da: 1.0, "en-gb": 0.8, en: 0.7 }
|
6
|
+
# @note Parse an Accept-Language header value into a hash of tag and quality.
|
8
7
|
# @see https://tools.ietf.org/html/rfc2616#section-14.4
|
9
|
-
|
10
|
-
def
|
11
|
-
|
12
|
-
|
8
|
+
module Parser
|
9
|
+
def self.call(raw_input, two_letter_truncate: false)
|
10
|
+
raw_input.to_s.delete(" ").split(",").inject({}) do |hash, lang|
|
11
|
+
tag, quality = lang.split(/;q=/i)
|
12
|
+
next hash if tag.nil?
|
13
13
|
|
14
|
-
|
15
|
-
preferences.sort { |lang_a, lang_b| lang_b.fetch(1) <=> lang_a.fetch(1) }
|
16
|
-
.map(&:first)
|
17
|
-
end
|
14
|
+
tag = tag.downcase.to_sym
|
18
15
|
|
19
|
-
|
16
|
+
if two_letter_truncate && tag.length > 2
|
17
|
+
tag = tag[0, 2].to_sym
|
18
|
+
next hash if hash.key?(tag)
|
19
|
+
end
|
20
20
|
|
21
|
-
def preferences
|
22
|
-
@string.delete(' ').split(',').inject({}) do |result, language|
|
23
|
-
tag, quality = language.split(/;q=/i)
|
24
21
|
quality = quality.nil? ? 1.0 : quality.to_f
|
25
|
-
|
26
|
-
next result if quality.zero?
|
27
|
-
|
28
|
-
result.merge(tag.to_sym => quality)
|
22
|
+
hash.merge(tag => quality)
|
29
23
|
end
|
30
24
|
end
|
31
25
|
end
|
metadata
CHANGED
@@ -1,122 +1,164 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accept_language
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
56
|
+
name: rubocop-md
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-performance
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-thread_safety
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
69
125
|
- !ruby/object:Gem::Dependency
|
70
126
|
name: simplecov
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
72
128
|
requirements:
|
73
|
-
- - "
|
129
|
+
- - ">="
|
74
130
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
131
|
+
version: '0'
|
76
132
|
type: :development
|
77
133
|
prerelease: false
|
78
134
|
version_requirements: !ruby/object:Gem::Requirement
|
79
135
|
requirements:
|
80
|
-
- - "
|
136
|
+
- - ">="
|
81
137
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
138
|
+
version: '0'
|
83
139
|
- !ruby/object:Gem::Dependency
|
84
140
|
name: yard
|
85
141
|
requirement: !ruby/object:Gem::Requirement
|
86
142
|
requirements:
|
87
|
-
- - "
|
143
|
+
- - ">="
|
88
144
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
145
|
+
version: '0'
|
90
146
|
type: :development
|
91
147
|
prerelease: false
|
92
148
|
version_requirements: !ruby/object:Gem::Requirement
|
93
149
|
requirements:
|
94
|
-
- - "
|
150
|
+
- - ">="
|
95
151
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
152
|
+
version: '0'
|
97
153
|
description: Parses the Accept-Language header from an HTTP request and produces a
|
98
|
-
|
99
|
-
email:
|
100
|
-
- contact@cyril.email
|
154
|
+
hash of languages and qualities.
|
155
|
+
email: contact@cyril.email
|
101
156
|
executables: []
|
102
157
|
extensions: []
|
103
158
|
extra_rdoc_files: []
|
104
159
|
files:
|
105
|
-
-
|
106
|
-
- ".rspec"
|
107
|
-
- ".rubocop.yml"
|
108
|
-
- ".rubocop_todo.yml"
|
109
|
-
- ".travis.yml"
|
110
|
-
- CODE_OF_CONDUCT.md
|
111
|
-
- Gemfile
|
112
|
-
- Gemfile.lock
|
113
|
-
- LICENSE.txt
|
160
|
+
- LICENSE.md
|
114
161
|
- README.md
|
115
|
-
- Rakefile
|
116
|
-
- VERSION.semver
|
117
|
-
- accept_language.gemspec
|
118
|
-
- bin/console
|
119
|
-
- bin/setup
|
120
162
|
- lib/accept_language.rb
|
121
163
|
- lib/accept_language/intersection.rb
|
122
164
|
- lib/accept_language/parser.rb
|
@@ -124,7 +166,7 @@ homepage: https://github.com/cyril/accept_language.rb
|
|
124
166
|
licenses:
|
125
167
|
- MIT
|
126
168
|
metadata: {}
|
127
|
-
post_install_message:
|
169
|
+
post_install_message:
|
128
170
|
rdoc_options: []
|
129
171
|
require_paths:
|
130
172
|
- lib
|
@@ -132,15 +174,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
174
|
requirements:
|
133
175
|
- - ">="
|
134
176
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
177
|
+
version: 2.7.0
|
136
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
179
|
requirements:
|
138
180
|
- - ">="
|
139
181
|
- !ruby/object:Gem::Version
|
140
182
|
version: '0'
|
141
183
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
-
signing_key:
|
184
|
+
rubygems_version: 3.2.15
|
185
|
+
signing_key:
|
144
186
|
specification_version: 4
|
145
187
|
summary: Parser for Accept-Language request HTTP header
|
146
188
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-06-12 01:35:53 +0200 using RuboCop version 0.71.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 1
|
10
|
-
Metrics/AbcSize:
|
11
|
-
Max: 16
|
12
|
-
|
13
|
-
# Offense count: 1
|
14
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
-
# ExcludedMethods: refine
|
16
|
-
Metrics/BlockLength:
|
17
|
-
Max: 72
|
18
|
-
|
19
|
-
# Offense count: 1
|
20
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
21
|
-
Metrics/MethodLength:
|
22
|
-
Max: 11
|
23
|
-
|
24
|
-
# Offense count: 14
|
25
|
-
# Cop supports --auto-correct.
|
26
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
27
|
-
# URISchemes: http, https
|
28
|
-
Metrics/LineLength:
|
29
|
-
Max: 110
|
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at contact@cyril.email. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
accept_language (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.0)
|
10
|
-
diff-lcs (1.3)
|
11
|
-
docile (1.3.1)
|
12
|
-
jaro_winkler (1.5.2)
|
13
|
-
json (2.2.0)
|
14
|
-
parallel (1.17.0)
|
15
|
-
parser (2.6.3.0)
|
16
|
-
ast (~> 2.4.0)
|
17
|
-
rainbow (3.0.0)
|
18
|
-
rake (10.5.0)
|
19
|
-
rspec (3.8.0)
|
20
|
-
rspec-core (~> 3.8.0)
|
21
|
-
rspec-expectations (~> 3.8.0)
|
22
|
-
rspec-mocks (~> 3.8.0)
|
23
|
-
rspec-core (3.8.0)
|
24
|
-
rspec-support (~> 3.8.0)
|
25
|
-
rspec-expectations (3.8.4)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.8.0)
|
28
|
-
rspec-mocks (3.8.0)
|
29
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.8.0)
|
31
|
-
rspec-support (3.8.2)
|
32
|
-
rubocop (0.71.0)
|
33
|
-
jaro_winkler (~> 1.5.1)
|
34
|
-
parallel (~> 1.10)
|
35
|
-
parser (>= 2.6)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
ruby-progressbar (~> 1.7)
|
38
|
-
unicode-display_width (>= 1.4.0, < 1.7)
|
39
|
-
ruby-progressbar (1.10.1)
|
40
|
-
simplecov (0.16.1)
|
41
|
-
docile (~> 1.1)
|
42
|
-
json (>= 1.8, < 3)
|
43
|
-
simplecov-html (~> 0.10.0)
|
44
|
-
simplecov-html (0.10.2)
|
45
|
-
unicode-display_width (1.6.0)
|
46
|
-
yard (0.9.19)
|
47
|
-
|
48
|
-
PLATFORMS
|
49
|
-
ruby
|
50
|
-
|
51
|
-
DEPENDENCIES
|
52
|
-
accept_language!
|
53
|
-
bundler (~> 2.0)
|
54
|
-
rake (~> 10.0)
|
55
|
-
rspec (~> 3.0)
|
56
|
-
rubocop (~> 0.71)
|
57
|
-
simplecov (~> 0.16)
|
58
|
-
yard (~> 0.9)
|
59
|
-
|
60
|
-
BUNDLED WITH
|
61
|
-
2.0.1
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
require 'rubocop/rake_task'
|
9
|
-
|
10
|
-
RuboCop::RakeTask.new
|
11
|
-
|
12
|
-
namespace :test do
|
13
|
-
task :coverage do
|
14
|
-
ENV['COVERAGE'] = 'true'
|
15
|
-
Rake::Task['test'].invoke
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
task(:doc_stats) { ruby '-S yard stats' }
|
20
|
-
task default: %i[spec doc_stats rubocop]
|
data/VERSION.semver
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
data/accept_language.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'accept_language'
|
5
|
-
spec.version = File.read('VERSION.semver').chomp
|
6
|
-
spec.authors = ['Cyril Kato']
|
7
|
-
spec.email = ['contact@cyril.email']
|
8
|
-
|
9
|
-
spec.summary = 'Parser for Accept-Language request HTTP header'
|
10
|
-
spec.description = 'Parses the Accept-Language header from an HTTP ' \
|
11
|
-
'request and produces a list of languages sorted by ' \
|
12
|
-
'quality.'
|
13
|
-
spec.homepage = 'https://github.com/cyril/accept_language.rb'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
18
|
-
end
|
19
|
-
|
20
|
-
spec.bindir = 'exe'
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ['lib']
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
25
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
-
spec.add_development_dependency 'rubocop', '~> 0.71'
|
28
|
-
spec.add_development_dependency 'simplecov', '~> 0.16'
|
29
|
-
spec.add_development_dependency 'yard', '~> 0.9'
|
30
|
-
end
|
data/bin/console
DELETED