link_header 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/lib/link_header.rb +8 -3
- data/lib/link_header/version.rb +1 -1
- data/test/test_link_header.rb +13 -0
- metadata +49 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 594d887d655a6daa87f4bfe2b2bfe4c9b708f57d
|
4
|
+
data.tar.gz: 973bd078f4442ed12d0b6db9716f7d3e07e8702b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bacfb5be464da48c4b97b55f2b94a788cb5984b97e1a2058dfe0f8d035580215fac9e5216c87260c9d55ed7294b4ec16e801f459f9bb433865baffedcfae4889
|
7
|
+
data.tar.gz: d238f95e02599bb224f44c36681990065ea93d93ea389f1cae8a6705958f419b5ece482da2cee399cbf4349a340310ad0a3d8b33ac5e3ad1196e6967e459bae4
|
data/lib/link_header.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'link_header/version'
|
2
|
+
require 'strscan'
|
3
3
|
|
4
4
|
#
|
5
5
|
# Represents an HTTP link header of the form described in the draft spec http://tools.ietf.org/id/draft-nottingham-http-link-header-06.txt.
|
@@ -34,6 +34,11 @@ class LinkHeader
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def <<(link)
|
38
|
+
link = link.kind_of?(Link) ? link : Link.new(*link)
|
39
|
+
@links << link
|
40
|
+
end
|
41
|
+
|
37
42
|
#
|
38
43
|
# Convert to a JSON-friendly array
|
39
44
|
#
|
@@ -196,7 +201,7 @@ class LinkHeader
|
|
196
201
|
# LinkHeader::Link.new(["http://example.com/foo", [["rel", "self"]]]).to_html
|
197
202
|
# #=> '<link href="http://example.com/foo" rel="self">'
|
198
203
|
def to_html
|
199
|
-
([%Q(<link href="#{href}")] + attr_pairs.map{|k, v| "#{k}=\"#{v.gsub(/"/, '\"')}\""}).join(' ')
|
204
|
+
([%Q(<link href="#{href}")] + attr_pairs.map{|k, v| "#{k}=\"#{v.gsub(/"/, '\"')}\""}).join(' ') + '>'
|
200
205
|
end
|
201
206
|
end
|
202
207
|
end
|
data/lib/link_header/version.rb
CHANGED
data/test/test_link_header.rb
CHANGED
@@ -13,6 +13,15 @@ LINK_HEADER_A = [
|
|
13
13
|
["http://example.com/", []]
|
14
14
|
]
|
15
15
|
|
16
|
+
LINK_HEADER_H_A = [
|
17
|
+
'<link href="http://example.com/" rel="up" meta="bar">',
|
18
|
+
'<link href="http://example.com/foo" rel="self">',
|
19
|
+
'<link href="http://example.com/">'
|
20
|
+
]
|
21
|
+
|
22
|
+
LINK_HEADER_H = LINK_HEADER_H_A.join("\n")
|
23
|
+
|
24
|
+
|
16
25
|
class TestLinkHeader < Test::Unit::TestCase
|
17
26
|
def test_new_link
|
18
27
|
link = LinkHeader::Link.new(*LINK_HEADER_A[0])
|
@@ -66,4 +75,8 @@ class TestLinkHeader < Test::Unit::TestCase
|
|
66
75
|
link_header = LinkHeader.new(LINK_HEADER_A)
|
67
76
|
assert_equal([["rel", "self"]], link_header.find_link(["rel", "self"]).attr_pairs)
|
68
77
|
end
|
78
|
+
|
79
|
+
def test_link_header_to_html
|
80
|
+
assert_equal(LINK_HEADER_H, LinkHeader.new(LINK_HEADER_A).to_html)
|
81
|
+
end
|
69
82
|
end
|
metadata
CHANGED
@@ -1,47 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_header
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Mike Burrows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
|
-
|
17
|
-
|
18
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
19
17
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
22
20
|
type: :development
|
23
|
-
version_requirements: *id001
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
|
-
name: rake
|
26
21
|
prerelease: false
|
27
|
-
|
28
|
-
requirements:
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
32
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Converts conforming link headers to and from text, LinkHeader objects
|
42
|
+
and corresponding (JSON-friendly) Array representations, also HTML link elements.
|
43
|
+
email:
|
37
44
|
- mjb@asplake.co.uk
|
38
45
|
executables: []
|
39
|
-
|
40
46
|
extensions: []
|
41
|
-
|
42
47
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
48
|
+
files:
|
45
49
|
- .gitignore
|
46
50
|
- Gemfile
|
47
51
|
- History.txt
|
@@ -55,28 +59,30 @@ files:
|
|
55
59
|
- test/test_helper.rb
|
56
60
|
- test/test_link_header.rb
|
57
61
|
homepage: https://github.com/asplake/link_header
|
58
|
-
licenses:
|
62
|
+
licenses:
|
59
63
|
- MIT
|
60
64
|
metadata: {}
|
61
|
-
|
62
65
|
post_install_message:
|
63
66
|
rdoc_options: []
|
64
|
-
|
65
|
-
require_paths:
|
67
|
+
require_paths:
|
66
68
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
73
79
|
requirements: []
|
74
|
-
|
75
80
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.0.
|
81
|
+
rubygems_version: 2.0.3
|
77
82
|
signing_key:
|
78
83
|
specification_version: 4
|
79
|
-
summary: Converts conforming link headers to and from text, LinkHeader objects and
|
80
|
-
|
84
|
+
summary: Converts conforming link headers to and from text, LinkHeader objects and
|
85
|
+
corresponding (JSON-friendly) Array representations, also HTML link elements.
|
86
|
+
test_files:
|
81
87
|
- test/test_helper.rb
|
82
88
|
- test/test_link_header.rb
|