rack-link_headers 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -6
- data/lib/rack/link_headers/header_hash_helper.rb +3 -2
- data/lib/rack/link_headers/version.rb +1 -1
- data/test/header_hash_helper_test.rb +14 -14
- metadata +3 -3
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Rack::LinkHeaders
|
2
|
+
[![Build Status](https://travis-ci.org/jgraichen/rack-link_headers.png?branch=master)](https://travis-ci.org/jgraichen/rack-link_headers)
|
2
3
|
|
3
4
|
Easy Link header management for rack responses.
|
4
5
|
|
@@ -19,21 +20,22 @@ Or install it yourself as:
|
|
19
20
|
## Usage
|
20
21
|
|
21
22
|
```ruby
|
22
|
-
response.
|
23
|
-
response.
|
23
|
+
response.link "rel", "http://abc.de/"
|
24
|
+
response.link "rss", "http://test.host/feed.xml"
|
24
25
|
```
|
25
26
|
```
|
26
|
-
|
27
|
+
response.headers["Link"]
|
28
|
+
# => <http://abc.de/> rel="rel", <http://test.host/feed.xml> rel="rss"
|
27
29
|
```
|
28
30
|
|
29
31
|
Manual set Link header will be overridden. All links can be
|
30
32
|
accessed via `links`:
|
31
33
|
|
32
34
|
```ruby
|
33
|
-
response.
|
34
|
-
response.
|
35
|
+
response.link "rel", "http://abc.de/"
|
36
|
+
response.link "rss", "http://test.host/feed.xml"
|
35
37
|
|
36
|
-
response.
|
38
|
+
response.links
|
37
39
|
# => [{:rel=>"rel", :url=>"http://abc.de/"}, {:rel=>"rss", :url=>"http://test.host/feed.xml"}]
|
38
40
|
```
|
39
41
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'rack/
|
1
|
+
require 'rack/response'
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
module LinkHeaders
|
@@ -26,4 +26,5 @@ module Rack
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
Rack::
|
29
|
+
Rack::Response.send :include, Rack::LinkHeaders::HeaderHashHelper
|
30
|
+
Rack::Response::Helpers.send :include, Rack::LinkHeaders::HeaderHashHelper
|
@@ -1,40 +1,40 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
|
3
|
-
require 'rack/
|
3
|
+
require 'rack/response'
|
4
4
|
require 'rack-link_headers'
|
5
5
|
|
6
6
|
class HeaderHashHelperTest < MiniTest::Unit::TestCase
|
7
7
|
def setup
|
8
|
-
@
|
8
|
+
@response = Rack::Response.new
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_link_writes_header
|
12
|
-
@
|
12
|
+
@response.link "search", "http://google.com/path?query=5#frag"
|
13
13
|
|
14
|
-
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\"", @headers["Link"]
|
14
|
+
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\"", @response.headers["Link"]
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_multiple_link_writes_header
|
18
|
-
@
|
19
|
-
@
|
18
|
+
@response.link "search", "http://google.com/path?query=5#frag"
|
19
|
+
@response.link "rss", "http://test.host/feed.rss"
|
20
20
|
|
21
|
-
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\", <http://test.host/feed.rss> rel=\"rss\"", @headers["Link"]
|
21
|
+
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\", <http://test.host/feed.rss> rel=\"rss\"", @response.headers["Link"]
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_links
|
25
|
-
@
|
26
|
-
@
|
25
|
+
@response.link "search", "http://google.com/path?query=5#frag"
|
26
|
+
@response.link "rss", "http://test.host/feed.rss"
|
27
27
|
|
28
|
-
assert_equal @
|
28
|
+
assert_equal @response.links, [{:rel=>"search", :url=> "http://google.com/path?query=5#frag"}, {:rel=>"rss", :url=>"http://test.host/feed.rss"}]
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_overrides_manual_headers
|
32
|
-
@headers["Link"] = "http://abc.de/"
|
32
|
+
@response.headers["Link"] = "http://abc.de/"
|
33
33
|
|
34
|
-
assert_equal "http://abc.de/", @headers["Link"]
|
34
|
+
assert_equal "http://abc.de/", @response.headers["Link"]
|
35
35
|
|
36
|
-
@
|
36
|
+
@response.link "search", "http://google.com/path?query=5#frag"
|
37
37
|
|
38
|
-
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\"", @headers["Link"]
|
38
|
+
assert_equal "<http://google.com/path?query=5#frag> rel=\"search\"", @response.headers["Link"]
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-link_headers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
segments:
|
61
61
|
- 0
|
62
|
-
hash: -
|
62
|
+
hash: -121590991522842654
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
segments:
|
70
70
|
- 0
|
71
|
-
hash: -
|
71
|
+
hash: -121590991522842654
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
74
|
rubygems_version: 1.8.24
|