http_headers-accept_language 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da5da728fa3c44c5969938a8974488b885e07a0d1b46dce5ec117cab74ddd136
4
- data.tar.gz: 4a635fc81239c6e6aa5d1363cce006eb1c1c7ff08d983cf5da5d1cc198d9086b
3
+ metadata.gz: 0ebbfe93a601fdf946138124adc1470197707f10cf77c9c8795e514a3a52f7a1
4
+ data.tar.gz: a3c87d59b5a95e28da456ebf26b1195a453aadfb8e825ad8f6b50a82c4bf271b
5
5
  SHA512:
6
- metadata.gz: dc3d5748db64c7e74746f28b36b8c3113e20b201e94fb0c670f6ef42e7ab70dfd4c2a7cf5987294fa990d0a2d17c2a7e06e3a7bb698de2d7587851be7abf32ad
7
- data.tar.gz: f726785bc095011cefbe2f944b0c72bb46a0a601ec0ee2cb2e7bbaa2c2a79096356ba369572ba36408f219727e316bb2304735555d35f5984567480e1d61ce63
6
+ metadata.gz: 26d0e5986b8db74aeff6bb59a1331d7df5876519454fc381fcd856eecd0a2f980f73c5344ed87d98fa781c5d440ccdced1bb96072aaeda4ea8933500c53503d8
7
+ data.tar.gz: bcef004d6d4e73af6690f4f9aa18460da9a8a77aa17cc37c4d15b01b0cfa6d203d6225db895c0b81fb58ad3e2cf42ddcd230d6d6e12fd9398396974f7e29c261
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_headers-accept_language (0.2.0)
4
+ http_headers-accept_language (0.2.1)
5
5
  http_headers-utils (>= 0.2.0, < 1.0.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,71 +1,78 @@
1
- # HttpHeaders::AcceptLanguage
2
-
3
- [![Build Status: master](https://travis-ci.com/XPBytes/http_headers-accept_language.svg)](https://travis-ci.com/XPBytes/http_headers-accept)
4
- [![Gem Version](https://badge.fury.io/rb/http_headers-accept_language.svg)](https://badge.fury.io/rb/http_headers-accept)
5
- [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
6
-
7
- :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'http_headers-accept_language'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install http_headers-accept_language
24
-
25
- ## Usage
26
-
27
- You can parse the "Accept-Language" header. As per the RFCs, you should really have one (delimited) value but the current
28
- implementation accepts an array of values.
29
-
30
- ```ruby
31
- require 'http_headers/accept_language'
32
-
33
- parsed = HttpHeaders::AcceptLanguage.new('nl-NL, nl, en-US; q=0.4, en; q=0.1')
34
- parsed.first.region
35
- # => 'NL'
36
- parsed.last.q
37
- # => 0.1
38
-
39
-
40
- parsed = HttpHeaders::AcceptLanguage.new([
41
- 'eo; q=0.1',
42
- 'es-ES; foo=bar, es-MX; q=0.9'
43
- ])
44
- parsed.first[:foo]
45
- # => bar
46
- parsed.last.to_s
47
- # => 'eo; q=0.1'
48
- parsed[1].locale
49
- # => 'es-MX'
50
- ```
51
-
52
- Each parsed entry has the following methods:
53
- - `locale`: the parsed locale
54
- - `language`: the language part of the `locale`
55
- - `region`: the region part of the `locale`
56
- - `q`: the quality parameter as float, or 1.0
57
- - `[](parameter)`: accessor for the parameter; throws if it does not exist
58
- - `to_s`: encode back to an entry to be used in a `Accept-Language` header
59
-
60
- ## Development
61
-
62
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
63
- also run `bin/console` for an interactive prompt that will allow you to experiment.
64
-
65
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
66
- version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
67
- push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
-
69
- ## Contributing
70
-
71
- Bug reports and pull requests are welcome on GitHub at [XPBytes/http_headers-accept](https://github.com/XPBytes/http_headers-accept).
1
+ # HttpHeaders::AcceptLanguage
2
+
3
+ [![Build Status: master](https://travis-ci.com/XPBytes/http_headers-accept_language.svg)](https://travis-ci.com/XPBytes/http_headers-accept)
4
+ [![Gem Version](https://badge.fury.io/rb/http_headers-accept_language.svg)](https://badge.fury.io/rb/http_headers-accept)
5
+ [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
6
+
7
+ :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'http_headers-accept_language'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install http_headers-accept_language
24
+
25
+ ## Usage
26
+
27
+ You can parse the "Accept-Language" header. As per the RFCs, you should really have one (delimited) value but the current
28
+ implementation accepts an array of values.
29
+
30
+ ```ruby
31
+ require 'http_headers/accept_language'
32
+
33
+ parsed = HttpHeaders::AcceptLanguage.new('nl-NL, nl, en-US; q=0.4, en; q=0.1')
34
+ parsed.first.region
35
+ # => 'NL'
36
+ parsed.last.q
37
+ # => 0.1
38
+
39
+
40
+ parsed = HttpHeaders::AcceptLanguage.new([
41
+ 'eo; q=0.1',
42
+ 'es-ES; foo=bar, es-MX; q=0.9'
43
+ ])
44
+ parsed.first[:foo]
45
+ # => bar
46
+ parsed.last.to_s
47
+ # => 'eo; q=0.1'
48
+ parsed[1].locale
49
+ # => 'es-MX'
50
+ ```
51
+
52
+ Each parsed entry has the following methods:
53
+ - `locale`: the parsed locale
54
+ - `language`: the language part of the `locale`
55
+ - `region`: the region part of the `locale`
56
+ - `q`: the quality parameter as float, or 1.0
57
+ - `[](parameter)`: accessor for the parameter; throws if it does not exist
58
+ - `to_s`: encode back to an entry to be used in a `Accept-Language` header
59
+
60
+ ## Related
61
+
62
+ - [HttpHeaders::Utils](https://github.com/XPBytes/http_headers-utils): :nut_and_bolt: Utility belt for the HttpHeader libraries
63
+ - [HttpHeaders::Accept](https://github.com/XPBytes/http_headers-accept): :nut_and_bolt: Utility to parse and sort the "Accept" HTTP Header
64
+ - [HttpHeaders::ContentType](https://github.com/XPBytes/http_headers-content_type): :nut_and_bolt: Utility to parse and sort the "Content-Type" HTTP Header
65
+ - [HttpHeaders::Link](https://github.com/XPBytes/http_headers-link): :nut_and_bolt: Utility to parse and sort the "Link" HTTP Header
66
+
67
+ ## Development
68
+
69
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
70
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+
72
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
73
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
74
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
75
+
76
+ ## Contributing
77
+
78
+ Bug reports and pull requests are welcome on GitHub at [XPBytes/http_headers-accept](https://github.com/XPBytes/http_headers-accept).
@@ -1,7 +1,7 @@
1
1
 
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "http_headers/accept_language"
4
+ require "http_headers/accept_language/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "http_headers-accept_language"
@@ -1,10 +1,8 @@
1
+ require 'http_headers/accept_language/version'
1
2
  require 'http_headers/utils'
2
- require 'delegate'
3
3
 
4
4
  module HttpHeaders
5
- class AcceptLanguage < DelegateClass(Array)
6
- VERSION = '0.2.0'
7
-
5
+ class AcceptLanguage # < DelegateClass(Array) determined by version
8
6
  def initialize(value)
9
7
  __setobj__ HttpHeaders::Utils::List.new(value, entry_klazz: Entry)
10
8
  end
@@ -0,0 +1,7 @@
1
+ require 'delegate'
2
+
3
+ module HttpHeaders
4
+ class AcceptLanguage < DelegateClass(Array)
5
+ VERSION = '0.2.1'
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_headers-accept_language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld
@@ -99,6 +99,7 @@ files:
99
99
  - bin/setup
100
100
  - http_headers-accept_language.gemspec
101
101
  - lib/http_headers/accept_language.rb
102
+ - lib/http_headers/accept_language/version.rb
102
103
  homepage: https://github.com/XPBytes/http_headers-accept_language
103
104
  licenses:
104
105
  - MIT