rack-link_headers 2.2.2 → 2.4.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: 671eeb60f4abb81feaee2bbe86a0ab04bf2608d47b27aa6c0bc2560d8171c327
4
+ data.tar.gz: ad43357571a86ed6732079cad2785f62b18c6f9f970f72c5b73332c8f9114d92
5
5
  SHA512:
6
- metadata.gz: 0ae818138891af51bdc4f6c974b7dede16f02f717cf09e14fed821152cf67002e78718359eb9aaad4a1e510238ac796061c0d63ec822f553208b48ed3b77f462
7
- data.tar.gz: 6f8274ed8d481c4bea392b17a3ffccb64f2405f3930244804c1cecd07b578815b253fd5e813935d41260993d0a01583fdff61bba18bf3f88312d3db69a9f4652
6
+ metadata.gz: 336743659f0eb6c603d2ab6da5f9d27f9057eb1f82ce2180549954b5339ada7836630bbfe349178a5fcf92aa65cbc90f00798f25bcc7383b86069b56b9e75cfd
7
+ data.tar.gz: edb4cea104f72b958f73dad53405cf3049572a0eb518e7d070f1fe78f5f49326ac77a0a22c5c9a4b41ba3999472fcd1f617fab86d86862b447349d57a376f7e6
data/README.md CHANGED
@@ -1,4 +1,7 @@
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
+ [![Gem Version](https://img.shields.io/gem/v/rack-link_headers?logo=ruby)](https://rubygems.org/gems/rack-link_headers)
4
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jgraichen/rack-link_headers/test.yml?logo=github)](https://github.com/jgraichen/rack-link_headers/actions/workflows/test.yml)
2
5
 
3
6
  Easy Link header management for rack responses.
4
7
 
@@ -6,23 +9,30 @@ Easy Link header management for rack responses.
6
9
 
7
10
  Add this line to your application's Gemfile:
8
11
 
9
- gem 'rack-link_headers'
12
+ ```ruby
13
+ gem 'rack-link_headers', '~> 2.4'
14
+ ```
10
15
 
11
16
  And then execute:
12
17
 
13
- $ bundle
18
+ ```console
19
+ bundle
20
+ ```
14
21
 
15
22
  Or install it yourself as:
16
23
 
17
- $ gem install rack-link_headers
24
+ ```console
25
+ gem install rack-link_headers
26
+ ```
18
27
 
19
28
  ## Usage
20
29
 
21
30
  ```ruby
22
- response.link "http://abc.de/", :rel => :search
23
- response.link "http://test.host/feed.xml", :rel => :rss, :type => "application/rss+xml"
24
- ```
31
+ response.link "http://abc.de/", rel: :search
32
+ response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
25
33
  ```
34
+
35
+ ```ruby
26
36
  response.headers["Link"]
27
37
  # => <http://abc.de/>; rel="rel", <http://test.host/feed.xml>; rel="rss"; type="application/rss+xml"
28
38
  ```
@@ -31,11 +41,16 @@ Manual set Link header will be overridden. All links can be
31
41
  accessed via `links`:
32
42
 
33
43
  ```ruby
34
- response.link "http://abc.de/", :rel => :search
35
- response.link "http://test.host/feed.xml", :rel => :rss, :type => "application/rss+xml"
44
+ response.link "http://abc.de/", rel: :search
45
+ response.link "http://test.host/feed.xml", rel: :rss, type: "application/rss+xml"
36
46
 
37
47
  response.links
38
- # => [{:url=>"http://abc.de/", :params=>{:ref=>:search}}, {:url=>"http://test.host/feed.xml", :params=>{:rel=>:rss, :type=>"application/rss+xml"}}]
48
+ # => [
49
+ # {:url=>"http://abc.de/",
50
+ # :params=>{:ref=>:search}},
51
+ # {:url=>"http://test.host/feed.xml",
52
+ # :params=>{:rel=>:rss, :type=>"application/rss+xml"}}
53
+ # ]
39
54
  ```
40
55
 
41
56
  ## Contributing
@@ -52,4 +67,4 @@ response.links
52
67
 
53
68
  [MIT License](http://www.opensource.org/licenses/mit-license.php)
54
69
 
55
- Copyright (c) 2013, Jan Graichen
70
+ Copyright © 2023, Jan Graichen
@@ -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,13 +1,15 @@
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 = 4
8
+ PATCH = 0
7
9
  STAGE = nil
8
10
 
9
11
  def self.to_s
10
- [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join '.'
12
+ [MAJOR, MINOR, PATCH, STAGE].compact.join '.'
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rack/link_headers/helper'
2
4
 
3
5
  module Rack
@@ -1,26 +1,29 @@
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'
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'
16
+
17
+ spec.required_ruby_version = '>= 2.7.0'
18
+ spec.metadata['rubygems_mfa_required'] = 'true'
16
19
 
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"]
20
+ spec.files = Dir['**/*'].grep(%r{^(
21
+ (bin|lib|test|spec|features)/|
22
+ (.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)
23
+ )}x)
21
24
 
22
- gem.add_runtime_dependency 'rack'
25
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
26
+ spec.require_paths = ['lib']
23
27
 
24
- gem.add_development_dependency 'minitest'
25
- gem.add_development_dependency 'rake'
28
+ spec.add_runtime_dependency 'rack'
26
29
  end
data/test/helper_test.rb CHANGED
@@ -1,61 +1,58 @@
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
- class HelperTest < MiniTest::Unit::TestCase
14
+ class HelperTest < Minitest::Test
15
15
  def setup
16
16
  @response = Rack::Response.new
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"',
30
+ @response.headers['Link']
30
31
  end
31
32
 
32
33
  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"
34
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
35
+ @response.link 'http://test.host/feed.rss', rel: :rss, type: 'application/rss+xml'
35
36
 
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"}}]
37
+ assert_equal @response.links, [
38
+ {url: 'http://google.com/path?query=5#frag', params: {rel: :search}},
39
+ {url: 'http://test.host/feed.rss', params: {rel: :rss, type: 'application/rss+xml'}},
40
+ ]
38
41
  end
39
42
 
40
43
  def test_overrides_manual_headers
41
- @response.headers["Link"] = "http://abc.de/"
44
+ @response.headers['Link'] = 'http://abc.de/'
42
45
 
43
- assert_equal "http://abc.de/", @response.headers["Link"]
46
+ assert_equal 'http://abc.de/', @response.headers['Link']
44
47
 
45
- @response.link "http://google.com/path?query=5#frag", :rel => :search
48
+ @response.link 'http://google.com/path?query=5#frag', rel: :search
46
49
 
47
- assert_equal "<http://google.com/path?query=5#frag>; rel=\"search\"", @response.headers["Link"]
50
+ assert_equal '<http://google.com/path?query=5#frag>; rel="search"', @response.headers['Link']
48
51
  end
49
52
 
50
- if ENV["GEM"].to_s.include?('ad')
53
+ if ACTIONPACK
51
54
  def test_dyn_inject_action_dispatch_response
52
55
  assert ActionDispatch::Response.new.respond_to? :link
53
56
  end
54
57
  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
58
  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.4.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: 2023-08-10 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
@@ -75,26 +41,25 @@ files:
75
41
  homepage: ''
76
42
  licenses:
77
43
  - MIT
78
- metadata: {}
44
+ metadata:
45
+ rubygems_mfa_required: 'true'
79
46
  post_install_message:
80
47
  rdoc_options: []
81
48
  require_paths:
82
49
  - lib
83
50
  required_ruby_version: !ruby/object:Gem::Requirement
84
51
  requirements:
85
- - - '>='
52
+ - - ">="
86
53
  - !ruby/object:Gem::Version
87
- version: '0'
54
+ version: 2.7.0
88
55
  required_rubygems_version: !ruby/object:Gem::Requirement
89
56
  requirements:
90
- - - '>='
57
+ - - ">="
91
58
  - !ruby/object:Gem::Version
92
59
  version: '0'
93
60
  requirements: []
94
- rubyforge_project:
95
- rubygems_version: 2.0.3
61
+ rubygems_version: 3.4.10
96
62
  signing_key:
97
63
  specification_version: 4
98
64
  summary: Easy Link header management for rack responses.
99
- test_files:
100
- - test/helper_test.rb
65
+ test_files: []
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
-
data/.travis.yml DELETED
@@ -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'