http-accept 1.4.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/http/accept/languages.rb +23 -4
- data/lib/http/accept/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7447d3a4ffac6d5fe7dfe4343e3a5311ae23cbd
|
4
|
+
data.tar.gz: 76e13950c937a706f2d5e5ddc46ae45120fa3057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a606a9271cc042d8b39be14e46b1bb7de7dbf4c07e40b3c12493e81995b9f42852c5b1962ecafc0f181ea38fa9eb8f6a84764e8de34507f462062b0c25bd4d5
|
7
|
+
data.tar.gz: b9a4904c398b22526717c8463d1d6d9cc79e43cf11681bb9cc73901d8909ba3ef45610b4e9879c0913597cd58f0388d88e91b3167b9113136181a377ce207a25
|
@@ -36,7 +36,7 @@ module HTTP
|
|
36
36
|
LANGUAGE_RANGE = /(?<locale>#{LOCALE})(\s*;\s*q=(?<q>#{QVALUE}))?/
|
37
37
|
|
38
38
|
# Provides an efficient data-structure for matching the Accept-Languages header to set of available locales according to https://tools.ietf.org/html/rfc7231#section-5.3.5 and https://tools.ietf.org/html/rfc4647#section-2.3
|
39
|
-
class Locales
|
39
|
+
class Locales
|
40
40
|
def self.expand(locale, into)
|
41
41
|
parts = locale.split('-')
|
42
42
|
|
@@ -50,21 +50,28 @@ module HTTP
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def initialize(names)
|
53
|
-
|
54
|
-
|
53
|
+
@names = names
|
55
54
|
@patterns = {}
|
56
55
|
|
57
|
-
|
56
|
+
@names.each{|name| self.class.expand(name, @patterns)}
|
58
57
|
|
59
58
|
self.freeze
|
60
59
|
end
|
61
60
|
|
62
61
|
def freeze
|
62
|
+
@names.freeze
|
63
63
|
@patterns.freeze
|
64
64
|
|
65
65
|
super
|
66
66
|
end
|
67
67
|
|
68
|
+
def each(&block)
|
69
|
+
return to_enum unless block_given?
|
70
|
+
|
71
|
+
@names.each(&block)
|
72
|
+
end
|
73
|
+
|
74
|
+
attr :names
|
68
75
|
attr :patterns
|
69
76
|
|
70
77
|
# Returns the intersection of others retaining order.
|
@@ -75,6 +82,18 @@ module HTTP
|
|
75
82
|
def include? locale_name
|
76
83
|
@patterns.include? locale_name
|
77
84
|
end
|
85
|
+
|
86
|
+
def join(*args)
|
87
|
+
@names.join(*args)
|
88
|
+
end
|
89
|
+
|
90
|
+
def + others
|
91
|
+
self.class.new(@names + others.to_a)
|
92
|
+
end
|
93
|
+
|
94
|
+
def to_a
|
95
|
+
@names
|
96
|
+
end
|
78
97
|
end
|
79
98
|
|
80
99
|
LanguageRange = Struct.new(:locale, :q) do
|
data/lib/http/accept/version.rb
CHANGED