http_headers-accept 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f95a246d378afbc008c41cc605238934950075cfd6ed674230c0825d6f7f477
4
- data.tar.gz: 271b53bb408212620b83e54bccaa815ab0ef8c3ffe9be3435383ab7ff5506af9
3
+ metadata.gz: c28ca05fb7b45da5f0ebc52844a87b9ad9a01c7c22dd9aa39ef5bb54a84a39fa
4
+ data.tar.gz: cbe42ac16917768c46fc099effe815e858e1469f137267c08f4b8fbae21b09e0
5
5
  SHA512:
6
- metadata.gz: fe774a2472bbd598d3456bbe9c79f18d0e9b5c80dfa32bd0f0e8c70d4cec1345963ca947515f6351ddd17a0c98f6b9c5d35d76575be38b448b6332ac0170d400
7
- data.tar.gz: b2c5f3f2a13b9e7b0903e64d1097a6d9d132abef30e8699ca932ab89c2b80cf59b4c283bff34f26d59710b4c79a4546f66dcbd8487b082d545bc2f8f5493f16d
6
+ metadata.gz: a57dde7ea3370f0c99473bc0d2d93d51942c76e87f87d54c7d5ba00fc63db1ca15ee2f73ca13f14428ef2e547a5e4a015f87ef2ab42447dde948719689dbff76
7
+ data.tar.gz: 3cf92680ff04d73c942ad5d8d5ff2bc8d14d6957459a68cd6932bdd7be1eb489adca052e0d355eaf76ee4c37563d050a9a0ff4a219fee4b378711451053f0327
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_headers-accept (0.2.0)
4
+ http_headers-accept (0.2.1)
5
5
  http_headers-utils (>= 0.2.0, < 1.0.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,74 +1,75 @@
1
- # HttpHeaders::Accept
2
-
3
- [![Build Status: master](https://travis-ci.com/XPBytes/http_headers-accept.svg)](https://travis-ci.com/XPBytes/http_headers-accept)
4
- [![Gem Version](https://badge.fury.io/rb/http_headers-accept.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" HTTP Header
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'http_headers-accept'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install http_headers-accept
24
-
25
- ## Usage
26
-
27
- You can parse the "Accept" 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'
32
-
33
- parsed = HttpHeaders::Accept.new('application/json, text/html; q=0.8')
34
- parsed.first.to_s
35
- # => 'application/json'
36
- parsed.last.q
37
- # => 0.8
38
-
39
-
40
- parsed = HttpHeaders::Accept.new([
41
- '*/*; q=0.1',
42
- 'application/json; foo=bar, text/html; q=0.8'
43
- ])
44
- parsed.first[:foo]
45
- # => bar
46
- parsed.last.to_s
47
- # => '*/*; q=0.1'
48
- ```
49
-
50
- Each parsed entry exposes the following methods:
51
- - `media_type`: the parsed media_type
52
- - `q`: the quality parameter as float, or 1.0
53
- - `[](parameter)`: accessor for the parameter; throws if it does not exist
54
- - `to_s`: encode back to an entry to be used in a `Accept` header
55
-
56
- ## Related
57
-
58
- - [HttpHeaders::Utils](https://github.com/XPBytes/http_headers-utils): :nut_and_bolt: Utility belt for the HttpHeader libraries
59
- - [HttpHeaders::AcceptLanguage](https://github.com/XPBytes/http_headers-accept_language): :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
60
- - [HttpHeaders::ContentType](https://github.com/XPBytes/http_headers-content_type): :nut_and_bolt: Utility to parse and sort the "Content-Type" HTTP Header
61
-
62
-
63
- ## Development
64
-
65
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
66
- also run `bin/console` for an interactive prompt that will allow you to experiment.
67
-
68
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
69
- version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
70
- push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
-
72
- ## Contributing
73
-
74
- Bug reports and pull requests are welcome on GitHub at [XPBytes/http_headers-accept](https://github.com/XPBytes/http_headers-accept).
1
+ # HttpHeaders::Accept
2
+
3
+ [![Build Status: master](https://travis-ci.com/XPBytes/http_headers-accept.svg)](https://travis-ci.com/XPBytes/http_headers-accept)
4
+ [![Gem Version](https://badge.fury.io/rb/http_headers-accept.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" HTTP Header
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'http_headers-accept'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install http_headers-accept
24
+
25
+ ## Usage
26
+
27
+ You can parse the "Accept" 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'
32
+
33
+ parsed = HttpHeaders::Accept.new('application/json, text/html; q=0.8')
34
+ parsed.first.to_s
35
+ # => 'application/json'
36
+ parsed.last.q
37
+ # => 0.8
38
+
39
+
40
+ parsed = HttpHeaders::Accept.new([
41
+ '*/*; q=0.1',
42
+ 'application/json; foo=bar, text/html; q=0.8'
43
+ ])
44
+ parsed.first[:foo]
45
+ # => bar
46
+ parsed.last.to_s
47
+ # => '*/*; q=0.1'
48
+ ```
49
+
50
+ Each parsed entry exposes the following methods:
51
+ - `media_type`: the parsed media_type
52
+ - `q`: the quality parameter as float, or 1.0
53
+ - `[](parameter)`: accessor for the parameter; throws if it does not exist
54
+ - `to_s`: encode back to an entry to be used in a `Accept` header
55
+
56
+ ## Related
57
+
58
+ - [HttpHeaders::Utils](https://github.com/XPBytes/http_headers-utils): :nut_and_bolt: Utility belt for the HttpHeader libraries
59
+ - [HttpHeaders::AcceptLanguage](https://github.com/XPBytes/http_headers-accept_language): :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
60
+ - [HttpHeaders::ContentType](https://github.com/XPBytes/http_headers-content_type): :nut_and_bolt: Utility to parse and sort the "Content-Type" HTTP Header
61
+ - [HttpHeaders::Link](https://github.com/XPBytes/http_headers-link): :nut_and_bolt: Utility to parse and sort the "Link" HTTP Header
62
+
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
67
+ also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+
69
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
70
+ version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
71
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
+
73
+ ## Contributing
74
+
75
+ 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"
4
+ require 'http_headers/accept/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "http_headers-accept"
@@ -0,0 +1,7 @@
1
+ require 'delegate'
2
+
3
+ module HttpHeaders
4
+ class Accept < DelegateClass(Array)
5
+ VERSION = '0.2.1'
6
+ end
7
+ end
@@ -1,10 +1,8 @@
1
+ require 'http_headers/accept/version'
1
2
  require 'http_headers/utils/list'
2
- require 'delegate'
3
3
 
4
4
  module HttpHeaders
5
- class Accept < DelegateClass(Array)
6
- VERSION = "0.2.0"
7
-
5
+ class Accept # < DelegateClass(Array) determined by version
8
6
  def initialize(value)
9
7
  __setobj__ HttpHeaders::Utils::List.new(value, entry_klazz: Accept::Entry)
10
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_headers-accept
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.gemspec
101
101
  - lib/http_headers/accept.rb
102
+ - lib/http_headers/accept/version.rb
102
103
  homepage: https://github.com/XPBytes/http_headers-accept
103
104
  licenses:
104
105
  - MIT