http-accept 1.4.2 → 1.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d796699087069177a88837346428ba7cbc95fb1e
4
- data.tar.gz: 27f7eb10dd18199d9079725bf1dc068b50abdf54
3
+ metadata.gz: b7447d3a4ffac6d5fe7dfe4343e3a5311ae23cbd
4
+ data.tar.gz: 76e13950c937a706f2d5e5ddc46ae45120fa3057
5
5
  SHA512:
6
- metadata.gz: 9f9cb152092c9288ff39b0d50427207450fe39dfb7b425eca018ac4741694af586315fd4991a7233e35158e33b07f2c5cdb2251b201a5b20bd293bc13ccf8455
7
- data.tar.gz: 448a727b5a490c5e3eb877b3a88044f1d2af41ab4d27de991a27d38b2c178ad4ffc093da3ac18f382afd479ee2f036dbfb5c314e4c42727b14a1f4278ec0aa1b
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 < Array
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
- super(names)
54
-
53
+ @names = names
55
54
  @patterns = {}
56
55
 
57
- self.each{|name| self.class.expand(name, @patterns)}
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module HTTP
22
22
  module Accept
23
- VERSION = "1.4.2"
23
+ VERSION = "1.6.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-accept
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams