rack-link_headers 1.0.0 → 2.0.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.
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.headers.link "rel", "http://abc.de/"
23
- response.headers.link "rss", "http://test.host/feed.xml"
23
+ response.link "rel", "http://abc.de/"
24
+ response.link "rss", "http://test.host/feed.xml"
24
25
  ```
25
26
  ```
26
- Link: <http://abc.de/> rel="rel", <http://test.host/feed.xml> rel="rss"
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.headers.link "rel", "http://abc.de/"
34
- response.headers.link "rss", "http://test.host/feed.xml"
35
+ response.link "rel", "http://abc.de/"
36
+ response.link "rss", "http://test.host/feed.xml"
35
37
 
36
- response.headers.links
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/utils'
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::Utils::HeaderHash.send :include, Rack::LinkHeaders::HeaderHashHelper
29
+ Rack::Response.send :include, Rack::LinkHeaders::HeaderHashHelper
30
+ Rack::Response::Helpers.send :include, Rack::LinkHeaders::HeaderHashHelper
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module LinkHeaders
3
3
  module VERSION
4
- MAJOR = 1
4
+ MAJOR = 2
5
5
  MINOR = 0
6
6
  PATCH = 0
7
7
  STAGE = nil
@@ -1,40 +1,40 @@
1
1
  require 'minitest/autorun'
2
2
 
3
- require 'rack/utils'
3
+ require 'rack/response'
4
4
  require 'rack-link_headers'
5
5
 
6
6
  class HeaderHashHelperTest < MiniTest::Unit::TestCase
7
7
  def setup
8
- @headers = Rack::Utils::HeaderHash.new
8
+ @response = Rack::Response.new
9
9
  end
10
10
 
11
11
  def test_link_writes_header
12
- @headers.link "search", "http://google.com/path?query=5#frag"
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
- @headers.link "search", "http://google.com/path?query=5#frag"
19
- @headers.link "rss", "http://test.host/feed.rss"
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
- @headers.link "search", "http://google.com/path?query=5#frag"
26
- @headers.link "rss", "http://test.host/feed.rss"
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 @headers.links, [{:rel=>"search", :url=> "http://google.com/path?query=5#frag"}, {:rel=>"rss", :url=>"http://test.host/feed.rss"}]
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
- @headers.link "search", "http://google.com/path?query=5#frag"
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: 1.0.0
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: -2482873367989671441
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: -2482873367989671441
71
+ hash: -121590991522842654
72
72
  requirements: []
73
73
  rubyforge_project:
74
74
  rubygems_version: 1.8.24