rack-link_headers 2.2.2 → 2.3.0

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
- SHA1:
3
- metadata.gz: 2f4baa356961756558edc69851a37ac16cf9df7b
4
- data.tar.gz: 4cfab05061e95516bdce385abfe55531ab8dc1f8
2
+ SHA256:
3
+ metadata.gz: 923b708b4765a8eb504d6d4337de4bcc21abd40a0509c0c7851e649b23777fe2
4
+ data.tar.gz: c4634d4822bf971fe5ed4c9af90e9756942b3d47c05024444e94c7d68ce951bb
5
5
  SHA512:
6
- metadata.gz: 0ae818138891af51bdc4f6c974b7dede16f02f717cf09e14fed821152cf67002e78718359eb9aaad4a1e510238ac796061c0d63ec822f553208b48ed3b77f462
7
- data.tar.gz: 6f8274ed8d481c4bea392b17a3ffccb64f2405f3930244804c1cecd07b578815b253fd5e813935d41260993d0a01583fdff61bba18bf3f88312d3db69a9f4652
6
+ metadata.gz: a0deb2f9e6382622c350932f7f42cecec4a7ecba8b82182aac914fffe1d74538b99d25195932eba609ed8e39389ff1fc23baf57970a9224253bc82d6675b1dff
7
+ data.tar.gz: 5e1ee525a5f8a6595c152bee35b4b6ae4be63e970a393e29d66b005bf7fe9c27bd3287c310c220e60b53d748656b965061d41e5c26f627a4497a530133b3e118
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Rack::LinkHeaders [![Build Status](https://travis-ci.org/jgraichen/rack-link_headers.png?branch=master)](https://travis-ci.org/jgraichen/rack-link_headers)
1
+ # Rack::LinkHeaders
2
+
3
+ [![Build Status](https://github.com/jgraichen/rack-link_headers/workflows/Build/badge.svg?event=push)](https://github.com/jgraichen/rack-link_headers/actions?query=workflow%3ABuild)
2
4
 
3
5
  Easy Link header management for rack responses.
4
6
 
@@ -19,8 +21,8 @@ Or install it yourself as:
19
21
  ## Usage
20
22
 
21
23
  ```ruby
22
- response.link "http://abc.de/", :rel => :search
23
- response.link "http://test.host/feed.xml", :rel => :rss, :type => "application/rss+xml"
24
+ response.link "http://abc.de/", rel: :search
25
+ response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
24
26
  ```
25
27
  ```
26
28
  response.headers["Link"]
@@ -31,11 +33,16 @@ Manual set Link header will be overridden. All links can be
31
33
  accessed via `links`:
32
34
 
33
35
  ```ruby
34
- response.link "http://abc.de/", :rel => :search
35
- response.link "http://test.host/feed.xml", :rel => :rss, :type => "application/rss+xml"
36
+ response.link "http://abc.de/", rel: :search
37
+ response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
36
38
 
37
39
  response.links
38
- # => [{:url=>"http://abc.de/", :params=>{:ref=>:search}}, {:url=>"http://test.host/feed.xml", :params=>{:rel=>:rss, :type=>"application/rss+xml"}}]
40
+ # => [
41
+ # {:url=>"http://abc.de/",
42
+ # :params=>{:ref=>:search}},
43
+ # {:url=>"http://test.host/feed.xml",
44
+ # :params=>{:rel=>:rss, :type=>"application/rss+xml"}}
45
+ # ]
39
46
  ```
40
47
 
41
48
  ## Contributing
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/link_headers/helper'
2
4
 
3
5
  module Rack
@@ -1,4 +1,6 @@
1
- require 'rack/response'
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack'
2
4
 
3
5
  module Rack
4
6
  module LinkHeaders
@@ -14,9 +16,9 @@ module Rack
14
16
  # sanitize anything. Manual added Link headers will be
15
17
  # overridden.
16
18
  def link(url, params = {})
17
- links << {:url => url.to_s, :params => params}
19
+ links << {url: url.to_s, params: params}
18
20
 
19
- self["Link"] = links.to_a.map do |link|
21
+ self['Link'] = links.to_a.map do |link|
20
22
  "<#{link[:url]}>" + link[:params].keys.sort.map do |k|
21
23
  "; #{k}=\"#{link[:params][k]}\""
22
24
  end.join
@@ -24,15 +26,19 @@ module Rack
24
26
  end
25
27
 
26
28
  def links
27
- @__links ||= []
29
+ @links ||= []
28
30
  end
29
31
  end
30
32
  end
31
33
  end
32
34
  end
33
35
 
34
- Rack::Response.send :include, Rack::LinkHeaders::Helper
35
- Rack::Response::Helpers.send :include, Rack::LinkHeaders::Helper
36
+ Rack::Response.include Rack::LinkHeaders::Helper
37
+ Rack::Response::Helpers.include Rack::LinkHeaders::Helper
36
38
 
37
- ActionDispatch::Response.send :include, Rack::LinkHeaders::Helper if defined?(ActionDispatch::Response)
38
- ActionController::TestResponse.send :include, Rack::LinkHeaders::Helper if defined?(ActionController::TestResponse)
39
+ if defined?(ActionDispatch::Response)
40
+ ActionDispatch::Response.include Rack::LinkHeaders::Helper
41
+ end
42
+ if defined?(ActionController::TestResponse)
43
+ ActionController::TestResponse.include Rack::LinkHeaders::Helper
44
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rack
2
4
  module LinkHeaders
3
5
  module VERSION
4
6
  MAJOR = 2
5
- MINOR = 2
6
- PATCH = 2
7
+ MINOR = 3
8
+ PATCH = 0
7
9
  STAGE = nil
8
10
 
9
11
  def self.to_s
@@ -1,26 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
5
6
  require 'rack/link_headers/version'
6
7
 
7
- Gem::Specification.new do |gem|
8
- gem.name = 'rack-link_headers'
9
- gem.version = Rack::LinkHeaders::VERSION
10
- gem.authors = ["Jan Graichen"]
11
- gem.email = ["jg@altimos.de"]
12
- gem.description = %q{Easy Link header management for rack responses.}
13
- gem.summary = %q{Easy Link header management for rack responses.}
14
- gem.homepage = ""
15
- gem.license = 'MIT'
16
-
17
- gem.files = `git ls-files`.split($/)
18
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
- gem.require_paths = ["lib"]
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'rack-link_headers'
10
+ spec.version = Rack::LinkHeaders::VERSION
11
+ spec.authors = ['Jan Graichen']
12
+ spec.email = ['jgraichen@altimos.de']
13
+ spec.summary = 'Easy Link header management for rack responses.'
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
21
16
 
22
- gem.add_runtime_dependency 'rack'
17
+ spec.files = Dir['**/*'].grep(%r{^(
18
+ (bin|lib|test|spec|features)/|
19
+ (.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)
20
+ )}x)
21
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ['lib']
23
24
 
24
- gem.add_development_dependency 'minitest'
25
- gem.add_development_dependency 'rake'
25
+ spec.add_runtime_dependency 'rack'
26
26
  end
@@ -1,14 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
 
3
- if ENV["GEM"].to_s.include?('ad')
5
+ ACTIONPACK = !ENV['ACTIONPACK'].to_s.empty?
6
+
7
+ if ACTIONPACK
8
+ # For testing ActionDispatch::Response
4
9
  require 'action_dispatch'
5
10
  end
6
- if ENV["GEM"].to_s.include?('ac')
7
- require 'action_controller'
8
- require 'action_controller/test_case'
9
- end
10
11
 
11
- require 'rack/response'
12
12
  require 'rack-link_headers'
13
13
 
14
14
  class HelperTest < MiniTest::Unit::TestCase
@@ -17,45 +17,39 @@ class HelperTest < MiniTest::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_link_writes_header
20
- @response.link "http://google.com/path?query=5#frag", :rel => :search
20
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
21
21
 
22
- assert_equal "<http://google.com/path?query=5#frag>; rel=\"search\"", @response.headers["Link"]
22
+ assert_equal '<http://google.com/path?query=5#frag>; rel="search"', @response.headers['Link']
23
23
  end
24
24
 
25
25
  def test_multiple_link_writes_header
26
- @response.link "http://google.com/path?query=5#frag", :rel => :search
27
- @response.link "http://test.host/feed.rss", :rel => :rss, :type => "application/rss+xml"
26
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
27
+ @response.link 'http://test.host/feed.rss', rel: :rss, type: 'application/rss+xml'
28
28
 
29
- assert_equal "<http://google.com/path?query=5#frag>; rel=\"search\", <http://test.host/feed.rss>; rel=\"rss\"; type=\"application/rss+xml\"", @response.headers["Link"]
29
+ assert_equal '<http://google.com/path?query=5#frag>; rel="search", <http://test.host/feed.rss>; rel="rss"; type="application/rss+xml"', @response.headers['Link']
30
30
  end
31
31
 
32
32
  def test_links
33
- @response.link "http://google.com/path?query=5#frag", :rel => :search
34
- @response.link "http://test.host/feed.rss", :rel => :rss, :type => "application/rss+xml"
33
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
34
+ @response.link 'http://test.host/feed.rss', rel: :rss, type: 'application/rss+xml'
35
35
 
36
- assert_equal @response.links, [{:url => "http://google.com/path?query=5#frag", :params => {:rel => :search}},
37
- {:url => "http://test.host/feed.rss", :params => {:rel => :rss, :type => "application/rss+xml"}}]
36
+ assert_equal @response.links, [{url: 'http://google.com/path?query=5#frag', params: {rel: :search}},
37
+ {url: 'http://test.host/feed.rss', params: {rel: :rss, type: 'application/rss+xml'}}]
38
38
  end
39
39
 
40
40
  def test_overrides_manual_headers
41
- @response.headers["Link"] = "http://abc.de/"
41
+ @response.headers['Link'] = 'http://abc.de/'
42
42
 
43
- assert_equal "http://abc.de/", @response.headers["Link"]
43
+ assert_equal 'http://abc.de/', @response.headers['Link']
44
44
 
45
- @response.link "http://google.com/path?query=5#frag", :rel => :search
45
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
46
46
 
47
- assert_equal "<http://google.com/path?query=5#frag>; rel=\"search\"", @response.headers["Link"]
47
+ assert_equal '<http://google.com/path?query=5#frag>; rel="search"', @response.headers['Link']
48
48
  end
49
49
 
50
- if ENV["GEM"].to_s.include?('ad')
50
+ if ACTIONPACK
51
51
  def test_dyn_inject_action_dispatch_response
52
52
  assert ActionDispatch::Response.new.respond_to? :link
53
53
  end
54
54
  end
55
-
56
- if ENV["GEM"].to_s.include?('ac')
57
- def test_dyn_inject_action_controller_test_response
58
- assert ActionController::TestResponse.new.respond_to? :link
59
- end
60
- end
61
55
  end
metadata CHANGED
@@ -1,72 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-link_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-24 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description: Easy Link header management for rack responses.
27
+ description:
56
28
  email:
57
- - jg@altimos.de
29
+ - jgraichen@altimos.de
58
30
  executables: []
59
31
  extensions: []
60
32
  extra_rdoc_files: []
61
33
  files:
62
- - .gitignore
63
- - .travis.yml
64
- - Gemfile
65
34
  - LICENSE.txt
66
35
  - README.md
67
- - Rakefile
68
- - gemfiles/Gemfile.rails-3-2
69
- - gemfiles/Gemfile.rails-head
70
36
  - lib/rack-link_headers.rb
71
37
  - lib/rack/link_headers/helper.rb
72
38
  - lib/rack/link_headers/version.rb
@@ -82,17 +48,16 @@ require_paths:
82
48
  - lib
83
49
  required_ruby_version: !ruby/object:Gem::Requirement
84
50
  requirements:
85
- - - '>='
51
+ - - ">="
86
52
  - !ruby/object:Gem::Version
87
53
  version: '0'
88
54
  required_rubygems_version: !ruby/object:Gem::Requirement
89
55
  requirements:
90
- - - '>='
56
+ - - ">="
91
57
  - !ruby/object:Gem::Version
92
58
  version: '0'
93
59
  requirements: []
94
- rubyforge_project:
95
- rubygems_version: 2.0.3
60
+ rubygems_version: 3.1.2
96
61
  signing_key:
97
62
  specification_version: 4
98
63
  summary: Easy Link header management for rack responses.
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- *.iml
4
- .bundle
5
- .config
6
- .yardoc
7
- .rbx
8
- .idea
9
- .rvmrc
10
- .rbx
11
- Gemfile.lock
12
- InstalledFiles
13
- _yardoc
14
- coverage
15
- doc/
16
- lib/bundler/man
17
- pkg
18
- rdoc
19
- spec/reports
20
- test/tmp
21
- test/version_tmp
22
- tmp
23
-
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 1.9.3
5
- env:
6
- - GEM=ac
7
- - GEM=ap
8
- gemfile:
9
- - gemfiles/Gemfile.rails-3-2
10
- - gemfiles/Gemfile.rails-head
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rack-link-headers.gemspec
4
- gemspec
5
-
6
- group :development do
7
- gem 'actionpack', :require => false
8
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs.push "test"
6
- t.test_files = FileList['test/*_test.rb']
7
- t.verbose = true
8
- end
9
-
10
- task :default => :test
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in acfs.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'actionpack', '~> 3.2.0'
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in acfs.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'actionpack', github: 'rails/rails'