link-header-parser 3.0.0 → 4.0.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
2
  SHA256:
3
- metadata.gz: 6b2127eef719541b0ed02c6cb37c7271ed1c1bac8358f5808fb50c08d5ccada3
4
- data.tar.gz: 999fdc8ea6ad395fe72e88094ed4e924063844600b25df4df5822b2e85b6c2aa
3
+ metadata.gz: 173d1c05e3a5c2fe7d8e99454249d73ce780cfcc3bb120d7be5145e9b376ea54
4
+ data.tar.gz: a79af8ae39af06d3a4625eab54aa8f51d4574f5789c913d570919c20f877febc
5
5
  SHA512:
6
- metadata.gz: 90a5edd9b4ea7802818d84d858a365f365c6aee0cdcb9ec453feb5620ef7c6b2957da0063a8eaa2847318b69be5e668874a1bf4dc5b01cb36ff75cfd6190a33d
7
- data.tar.gz: 676c81a374430b522d62d2cc569e149e4c18d5eead47db851cadc1fe509ff787d02b3ecdb823a1e70f8244a6f4d3fb8b122a18ca2dd4ea697eff6faa8c9e22a5
6
+ metadata.gz: 48085ca777ca8b2e6d859e2920165d7336cd2b909efbdfcc63aaff1980859d77e8cb6f0455dc61c8b089d143206d435639b49a9aef9a7f151c21ca683e9af07d
7
+ data.tar.gz: 8fbd4c92cced717fc2a41d213209067824288810d14053236e6ca3ee1363c421a89c49be4ac6f34f9cc3736c91108ec58779a2638fca1efcbbf314ae5bbf1c84
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0 / 2022-01-06
4
+
5
+ - Remove Addressable dependency (daedf22)
6
+ - **Breaking change:** Update minimum Ruby version to 2.6 (e2343ed)
7
+ - Migrate to GitHub Actions (509b2c4)
8
+ - Update project Ruby version to 2.6.9 (c39bc66)
9
+
3
10
  ## 3.0.0 / 2021-05-22
4
11
 
5
12
  - Add implicit type conversion methods, alias explicit methods, and update specs (d132535)
data/CONTRIBUTING.md CHANGED
@@ -8,9 +8,9 @@ There are a couple ways you can help improve link-header-parser-ruby:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- link-header-parser-ruby is developed using Ruby 2.5.9 and is additionally tested against Ruby 2.6, 2.7, and 3.0 using [CircleCI](https://app.circleci.com/pipelines/github/jgarber623/link-header-parser-ruby).
11
+ link-header-parser-ruby is developed using Ruby 2.6.9 and is additionally tested against Ruby 2.7, 3.0, and 3.1 using [GitHub Actions](https://github.com/jgarber623/link-header-parser-ruby/actions).
12
12
 
13
- Before making changes to link-header-parser-ruby, you'll want to install Ruby 2.5.9. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.5.9 using your method of choice, install the project's gems by running:
13
+ Before making changes to link-header-parser-ruby, you'll want to install Ruby 2.6.9. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.6.9 using your method of choice, install the project's gems by running:
14
14
 
15
15
  ```sh
16
16
  bundle install
data/README.md CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  [![Gem](https://img.shields.io/gem/v/link-header-parser.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/link-header-parser)
6
6
  [![Downloads](https://img.shields.io/gem/dt/link-header-parser.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/link-header-parser)
7
- [![Build](https://img.shields.io/circleci/build/github/jgarber623/link-header-parser-ruby?logo=circleci&style=for-the-badge)](https://app.circleci.com/pipelines/github/jgarber623/link-header-parser-ruby)
7
+ [![Build](https://img.shields.io/github/workflow/status/jgarber623/link-header-parser-ruby/CI?logo=github&style=for-the-badge)](https://github.com/jgarber623/link-header-parser-ruby/actions/workflows/ci.yml)
8
8
  [![Maintainability](https://img.shields.io/codeclimate/maintainability/jgarber623/link-header-parser-ruby.svg?logo=code-climate&style=for-the-badge)](https://codeclimate.com/github/jgarber623/link-header-parser-ruby)
9
9
  [![Coverage](https://img.shields.io/codeclimate/c/jgarber623/link-header-parser-ruby.svg?logo=code-climate&style=for-the-badge)](https://codeclimate.com/github/jgarber623/link-header-parser-ruby/code)
10
10
 
11
11
  ## Getting Started
12
12
 
13
- Before installing and using link-header-parser-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.5 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
13
+ Before installing and using link-header-parser-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.6 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
14
14
 
15
- link-header-parser-ruby is developed using Ruby 2.5.9 and is additionally tested against Ruby 2.6, 2.7, and 3.0 using [CircleCI](https://app.circleci.com/pipelines/github/jgarber623/link-header-parser-ruby).
15
+ link-header-parser-ruby is developed using Ruby 2.6.9 and is additionally tested against Ruby 2.7, 3.0, and 3.1 using [GitHub Actions](https://github.com/jgarber623/link-header-parser-ruby/actions).
16
16
 
17
17
  ## Installation
18
18
 
@@ -1,12 +1,12 @@
1
- require 'forwardable'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'addressable/uri'
3
+ require 'forwardable'
4
4
 
5
- require 'link_header_parser/version'
5
+ require_relative 'link_header_parser/version'
6
6
 
7
- require 'link_header_parser/link_header'
8
- require 'link_header_parser/link_header_parameter'
9
- require 'link_header_parser/link_headers_collection'
7
+ require_relative 'link_header_parser/link_header'
8
+ require_relative 'link_header_parser/link_header_parameter'
9
+ require_relative 'link_header_parser/link_headers_collection'
10
10
 
11
11
  module LinkHeaderParser
12
12
  # Parse an array of HTTP Link headers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LinkHeaderParser
2
4
  class LinkHeader
3
5
  FIELD_VALUE_REGEXP_PATTERN = /^\s*<\s*(?<target_string>[^>]+)\s*>\s*(?<parameters>;\s*.*)$/.freeze
@@ -28,11 +30,14 @@ module LinkHeaderParser
28
30
  #
29
31
  # @return [String]
30
32
  def context_uri
31
- @context_uri ||= Addressable::URI.join(target_uri, context_string).normalize.to_s
33
+ @context_uri ||= URI.join(target_uri, context_string).normalize.to_s
32
34
  end
33
35
 
36
+ # @return [String]
34
37
  def inspect
35
- format(%(#<#{self.class.name}:%#0x target_uri: #{target_uri.inspect}, relation_types: #{relation_types.inspect}>), object_id)
38
+ "#<#{self.class.name}:#{format('%#0x', object_id)} " \
39
+ "target_uri: #{target_uri.inspect}, " \
40
+ "relation_types: #{relation_types.inspect}>"
36
41
  end
37
42
 
38
43
  # The parsed parameters for this Link header extracted from field_value
@@ -40,7 +45,9 @@ module LinkHeaderParser
40
45
  #
41
46
  # @return [Array<LinkHeaderParser::LinkHeaderParameter>]
42
47
  def link_parameters
43
- @link_parameters ||= field_value_match_data[:parameters].scan(PARAMETERS_REGEXP_PATTERN).flatten.map { |parameter| LinkHeaderParameter.new(parameter) }
48
+ @link_parameters ||= field_value_match_data[:parameters].scan(PARAMETERS_REGEXP_PATTERN)
49
+ .flatten
50
+ .map { |parameter| LinkHeaderParameter.new(parameter) }
44
51
  end
45
52
 
46
53
  # The relations_string value returned as an Array
@@ -72,7 +79,7 @@ module LinkHeaderParser
72
79
  #
73
80
  # @return [String]
74
81
  def target_uri
75
- @target_uri ||= Addressable::URI.join(base, target_string).normalize.to_s
82
+ @target_uri ||= URI.join(base, target_string).normalize.to_s
76
83
  end
77
84
 
78
85
  # @return [Hash{Symbol => String, Array, Hash{Symbol => Array}}]
@@ -99,7 +106,10 @@ module LinkHeaderParser
99
106
  end
100
107
 
101
108
  def grouped_link_parameters
102
- @grouped_link_parameters ||= link_parameters.map(&:to_a).group_by(&:shift).transform_keys(&:to_sym).transform_values(&:flatten)
109
+ @grouped_link_parameters ||= link_parameters.map(&:to_a)
110
+ .group_by(&:shift)
111
+ .transform_keys(&:to_sym)
112
+ .transform_values(&:flatten)
103
113
  end
104
114
  end
105
115
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LinkHeaderParser
2
4
  class LinkHeaderParameter
3
5
  PARAMETER_REGEXP_PATTERN = /^(?<name>.+?)(?:="?(?<value>.*?)"?)?$/.freeze
@@ -9,8 +11,11 @@ module LinkHeaderParser
9
11
  @parameter = parameter.to_str
10
12
  end
11
13
 
14
+ # @return [String]
12
15
  def inspect
13
- format(%(#<#{self.class.name}:%#0x name: #{name.inspect}, value: #{value.inspect}>), object_id)
16
+ "#<#{self.class.name}:#{format('%#0x', object_id)} " \
17
+ "name: #{name.inspect}, " \
18
+ "value: #{value.inspect}>"
14
19
  end
15
20
 
16
21
  # @see https://tools.ietf.org/html/rfc8288#appendix-B.3 (Appendix B.3.2.9)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LinkHeaderParser
2
4
  class LinkHeadersCollection
3
5
  extend Forwardable
@@ -19,13 +21,16 @@ module LinkHeaderParser
19
21
 
20
22
  # @return [Hash{Symbol => Array<LinkHeaderParser::LinkHeader>}]
21
23
  def group_by_relation_type
22
- relation_types.map do |relation_type|
23
- [relation_type, find_all { |member| member.relation_types.include?(relation_type) }]
24
- end.to_h.transform_keys(&:to_sym)
24
+ relation_types.to_h do |relation_type|
25
+ [relation_type.to_sym, select_by_relation_type(relation_type)]
26
+ end
25
27
  end
26
28
 
29
+ # @return [String]
27
30
  def inspect
28
- format(%(#<#{self.class.name}:%#0x headers: #{headers.inspect}, relation_types: #{relation_types.inspect}>), object_id)
31
+ "#<#{self.class.name}:#{format('%#0x', object_id)} " \
32
+ "headers: #{headers.inspect}, " \
33
+ "relation_types: #{relation_types.inspect}>"
29
34
  end
30
35
 
31
36
  # @return [Array<String>]
@@ -44,5 +49,9 @@ module LinkHeaderParser
44
49
  def members
45
50
  @members ||= []
46
51
  end
52
+
53
+ def select_by_relation_type(relation_type)
54
+ select { |member| member.relation_types.include?(relation_type) }
55
+ end
47
56
  end
48
57
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LinkHeaderParser
2
- VERSION = '3.0.0'.freeze
4
+ VERSION = '4.0.0'
3
5
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/link_header_parser/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4')
6
+ spec.required_ruby_version = '>= 2.6', '< 4'
5
7
 
6
8
  spec.name = 'link-header-parser'
7
9
  spec.version = LinkHeaderParser::VERSION
@@ -19,8 +21,9 @@ Gem::Specification.new do |spec|
19
21
 
20
22
  spec.require_paths = ['lib']
21
23
 
22
- spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
23
- spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
24
-
25
- spec.add_runtime_dependency 'addressable', '~> 2.7'
24
+ spec.metadata = {
25
+ 'bug_tracker_uri' => "#{spec.homepage}/issues",
26
+ 'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md",
27
+ 'rubygems_mfa_required' => 'true'
28
+ }
26
29
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link-header-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: addressable
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.7'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.7'
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Parse HTTP Link headers.
28
14
  email:
29
15
  - jason@sixtwothree.org
@@ -46,8 +32,9 @@ licenses:
46
32
  - MIT
47
33
  metadata:
48
34
  bug_tracker_uri: https://github.com/jgarber623/link-header-parser-ruby/issues
49
- changelog_uri: https://github.com/jgarber623/link-header-parser-ruby/blob/v3.0.0/CHANGELOG.md
50
- post_install_message:
35
+ changelog_uri: https://github.com/jgarber623/link-header-parser-ruby/blob/v4.0.0/CHANGELOG.md
36
+ rubygems_mfa_required: 'true'
37
+ post_install_message:
51
38
  rdoc_options: []
52
39
  require_paths:
53
40
  - lib
@@ -55,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
42
  requirements:
56
43
  - - ">="
57
44
  - !ruby/object:Gem::Version
58
- version: '2.5'
45
+ version: '2.6'
59
46
  - - "<"
60
47
  - !ruby/object:Gem::Version
61
48
  version: '4'
@@ -65,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
52
  - !ruby/object:Gem::Version
66
53
  version: '0'
67
54
  requirements: []
68
- rubygems_version: 3.2.16
69
- signing_key:
55
+ rubygems_version: 3.2.33
56
+ signing_key:
70
57
  specification_version: 4
71
58
  summary: Parse HTTP Link headers.
72
59
  test_files: []