indieweb-endpoints 9.0.0 → 10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 370058542f4dab2038574dc7fc35970351000f89c0cb9e26eb9f516d1e65fb1e
4
- data.tar.gz: 397f0722f44609cfb10dfb6aa8c927007b37f182714eb1aa4fe0143044da5caf
3
+ metadata.gz: 764739f3fcfca374be14b10f42cfccd20999e0093ec2826399c94e0b91f40b55
4
+ data.tar.gz: f335bee04586d8de22137db8b2fb0910916c727a8e20da9694ddcf64bf2f75d4
5
5
  SHA512:
6
- metadata.gz: 4fe7c09096ecd71e46acf6dd793bb9c808332c657e3c85a077169fe5031493a3d103b060141ab30bae8ec4c3ff5eeb18c17e4223f68d6f5bc3f10bb03929818e
7
- data.tar.gz: 4f6f3a2c4d5ad81280d2e4071b4aa817cd52dffeafb7b046624028d1235fff48e255c9f4d86846e2a8188733e218b304bead056b3b05e9647ac410b9247db560
6
+ metadata.gz: be93d73d8413292eee19bb40443da2cd29f6cdab989a18e66e27a7521e2c68550b8a7b161a79087228c1e24751513e8ca779eedf53b361096fa8aea58ba6f8d9
7
+ data.tar.gz: 5d634b748429d8e5161a09920481462fcc97c670e5d275e9ff6a9c4c14157216a7ba674f35c37755607891d63247e3f6467573afddffafca8eeb9360dc7b98c0
data/CONTRIBUTING.md CHANGED
@@ -8,9 +8,12 @@ There are a couple ways you can help improve indieweb-endpoints-ruby:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- indieweb-endpoints-ruby is developed using Ruby 3.3.0 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/indieweb/indieweb-endpoints-ruby/actions).
11
+ indieweb-endpoints-ruby is developed using Ruby 3.4 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/indieweb/indieweb-endpoints-ruby/actions).
12
12
 
13
- Before making changes to indieweb-endpoints-ruby, you'll want to install Ruby 3.3.0. Using 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) is recommended. Once you've installed Ruby 3.3.0 using your method of choice, install the project's gems by running:
13
+ > [!TIP]
14
+ > This project is configured with a [Dev Container](https://containers.dev) which includes everything you'd need to contribute to indieweb-endpoints-ruby. If you use a supported code editor or IDE, you're encouraged to use the existing Dev Container setup.
15
+
16
+ Before making changes to indieweb-endpoints-ruby, you'll want to install Ruby 3.4. Using 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) is recommended. Once you've installed Ruby 3.4 using your method of choice, install the project's gems by running:
14
17
 
15
18
  ```sh
16
19
  bundle install
@@ -19,17 +22,17 @@ bundle install
19
22
  ## Making Changes
20
23
 
21
24
  1. Fork and clone the project's repo.
22
- 1. Install development dependencies as outlined above.
23
- 1. Create a feature branch for the code changes you're looking to make: `git checkout -b my-new-feature`.
24
- 1. _Write some code!_
25
- 1. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `bundle exec rspec`.
26
- 1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`. _(See [this excellent article](https://chris.beams.io/posts/git-commit/) for tips on writing useful Git commit messages.)_
27
- 1. Push the branch to your fork: `git push -u origin my-new-feature`.
28
- 1. Create a new [Pull Request][pulls] and we'll review your changes.
25
+ 2. Install development dependencies as outlined above.
26
+ 3. Create a feature branch for the code changes you're looking to make: `git checkout -b my-new-feature`.
27
+ 4. _Write some code!_
28
+ 5. If your changes would benefit from testing, add the necessary tests and verify everything passes by running `bundle exec rspec`.
29
+ 6. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`. _(See [this excellent article](https://cbea.ms/git-commit/) for tips on writing useful Git commit messages.)_
30
+ 7. Push the branch to your fork: `git push -u origin my-new-feature`.
31
+ 8. Create a new [Pull Request][pulls] and we'll review your changes.
29
32
 
30
33
  ## Code Style
31
34
 
32
- Code formatting conventions are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. We recommended installing the EditorConfig plugin for your editor of choice.
35
+ Code formatting conventions are defined in the `.editorconfig` file which uses the [EditorConfig](https://editorconfig.org) syntax. There are [plugins for a variety of editors](https://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. We recommended installing the EditorConfig plugin for your editor of choice.
33
36
 
34
37
  Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
35
38
 
data/README.md CHANGED
@@ -10,13 +10,13 @@
10
10
 
11
11
  - Compliant with [Section 4.1](https://www.w3.org/TR/indieauth/#discovery-by-clients) and [Section 4.2.2](https://www.w3.org/TR/indieauth/#redirect-url) of [the W3C's IndieAuth Working Group Note](https://www.w3.org/TR/indieauth/), [Section 5.3](https://www.w3.org/TR/micropub/#endpoint-discovery) of [the W3C's Micropub Recommendation](https://www.w3.org/TR/micropub/), and [Section 3.1.2](https://www.w3.org/TR/webmention/#sender-discovers-receiver-webmention-endpoint) of [the W3C's Webmention Recommendation](https://www.w3.org/TR/webmention/).
12
12
  - Passes all Endpoint Discovery tests on [webmention.rocks](https://webmention.rocks).
13
- - Supports Ruby 3.0 and newer.
13
+ - Supports Ruby 2.7 and newer.
14
14
 
15
15
  ## Getting Started
16
16
 
17
- Before installing and using indieweb-endpoints-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 3.0 (or newer) installed. Using 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) is recommended.
17
+ Before installing and using indieweb-endpoints-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.7 (or newer) installed. Using 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) is recommended.
18
18
 
19
- indieweb-endpoints-ruby is developed using Ruby 3.3.0 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/indieweb/indieweb-endpoints-ruby/actions).
19
+ indieweb-endpoints-ruby is developed using Ruby 3.4 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/indieweb/indieweb-endpoints-ruby/actions).
20
20
 
21
21
  ## Installation
22
22
 
@@ -41,7 +41,7 @@ IndieWeb::Endpoints.get("https://aaronparecki.com")
41
41
  #=> { authorization_endpoint: "https://aaronparecki.com/auth", "indieauth-metadata": "https://aaronparecki.com/.well-known/oauth-authorization-server", micropub: "https://aaronparecki.com/micropub", microsub: "https://aperture.p3k.io/microsub/1", redirect_uri: nil, token_endpoint: "https://aaronparecki.com/auth/token", webmention: "https://webmention.io/aaronpk/webmention" }
42
42
  ```
43
43
 
44
- This example will search `https://aaronparecki.com` for valid IndieAuth, Micropub, and Webmention endpoints and return a `Hash` of results. Each key in the returned `Hash` will have a value of either a `String` representing a URL or `nil`. The `redirect_uri` key's value will be either an `Array` or `nil` since a given URL may register multiple callback URLs.
44
+ This example will search [Aaron's website](https://aaronparecki.com) for valid IndieAuth, Micropub, and Webmention endpoints and return a `Hash` of results. Each key in the returned `Hash` will have a value of either a `String` representing a URL or `nil`. The `redirect_uri` key's value will be either an `Array` or `nil` since a given URL may register multiple callback URLs.
45
45
 
46
46
  ### Advanced Usage
47
47
 
@@ -62,18 +62,10 @@ client.endpoints
62
62
 
63
63
  ### Exception Handling
64
64
 
65
- There are several exceptions that may be raised by indieweb-endpoints-ruby's underlying dependencies. These errors are raised as subclasses of `IndieWeb::Endpoints::Error` (which itself is a subclass of `StandardError`).
66
-
67
- From [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
65
+ indieweb-endpoints-ruby may raise the following exceptions which are subclasses of `IndieWeb::Endpoints::Error` (which itself is a subclass of `StandardError`).
68
66
 
69
67
  - `IndieWeb::Endpoints::InvalidURIError`
70
-
71
- From [httprb/http](https://github.com/httprb/http):
72
-
73
68
  - `IndieWeb::Endpoints::HttpError`
74
-
75
- From the Ruby Standard Library's [`OpenSSL::SSL::SSLError`](https://ruby-doc.org/3.3.0/exts/openssl/OpenSSL/SSL/SSLError.html):
76
-
77
69
  - `IndieWeb::Endpoints::SSLError`
78
70
 
79
71
  ## Contributing
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/indieweb/endpoints/version"
4
-
5
3
  Gem::Specification.new do |spec|
6
- spec.required_ruby_version = ">= 3.0"
4
+ spec.required_ruby_version = ">= 2.7"
7
5
 
8
6
  spec.name = "indieweb-endpoints"
9
- spec.version = IndieWeb::Endpoints::VERSION
7
+ spec.version = "10.0.0"
10
8
  spec.authors = ["Jason Garber"]
11
9
  spec.email = ["jason@sixtwothree.org"]
12
10
 
@@ -16,19 +14,21 @@ Gem::Specification.new do |spec|
16
14
  spec.license = "MIT"
17
15
 
18
16
  spec.files = Dir["lib/**/*"].reject { |f| File.directory?(f) }
19
- spec.files += %w[LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md]
20
- spec.files += %w[indieweb-endpoints.gemspec]
17
+ spec.files += ["LICENSE", "CHANGELOG.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "README.md"]
18
+ spec.files += ["indieweb-endpoints.gemspec"]
21
19
 
22
20
  spec.require_paths = ["lib"]
23
21
 
24
22
  spec.metadata = {
25
23
  "bug_tracker_uri" => "#{spec.homepage}/issues",
26
24
  "changelog_uri" => "#{spec.homepage}/releases/tag/v#{spec.version}",
25
+ "documentation_uri" => "https://rubydoc.info/gems/#{spec.name}/#{spec.version}",
26
+ "homepage_uri" => spec.homepage,
27
27
  "rubygems_mfa_required" => "true",
28
- "source_code_uri" => "#{spec.homepage}/tree/v#{spec.version}"
28
+ "source_code_uri" => "#{spec.homepage}/tree/v#{spec.version}",
29
29
  }
30
30
 
31
- spec.add_runtime_dependency "http", "~> 5.2"
32
- spec.add_runtime_dependency "link-header-parser", "~> 5.1"
33
- spec.add_runtime_dependency "nokogiri", ">= 1.16"
31
+ spec.add_dependency "http", "~> 5.2"
32
+ spec.add_dependency "link-header-parser", "~> 6.1"
33
+ spec.add_dependency "nokogiri-html-ext", "~> 1.4"
34
34
  end
@@ -3,48 +3,49 @@
3
3
  module IndieWeb
4
4
  module Endpoints
5
5
  class Client
6
- HTTP_HEADERS_OPTS = {
7
- accept: "*/*",
8
- user_agent: "IndieWeb Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)"
9
- }.freeze
10
-
11
- private_constant :HTTP_HEADERS_OPTS
12
-
13
6
  # Create a new client with a URL to parse for IndieWeb endpoints.
14
7
  #
15
8
  # @example
16
9
  # client = IndieWeb::Endpoints::Client.new("https://aaronparecki.com")
17
10
  #
18
11
  # @param url [String, HTTP::URI, #to_s] an absolute URL
19
- # @raise [IndieWeb::Endpoints::InvalidURIError]
12
+ #
13
+ # @raise [InvalidURIError]
20
14
  def initialize(url)
21
- @uri = HTTP::URI.parse(url.to_s)
15
+ @uri = HTTP::URI.parse(url)
22
16
  rescue Addressable::URI::InvalidURIError => e
23
17
  raise InvalidURIError, e
24
18
  end
25
19
 
20
+ # :nocov:
26
21
  # @return [String]
27
22
  def inspect
28
- %(#<#{self.class.name}:#{format("%#0x", object_id)} uri: "#{uri}">)
23
+ format "#<%<class>s:%<id>#018x @uri=%<uri>s",
24
+ class: self.class,
25
+ id: object_id << 1,
26
+ uri: uri.inspect
29
27
  end
28
+ # :nocov:
30
29
 
31
30
  # A Hash of the discovered IndieWeb endpoints from the provided URL.
32
31
  #
33
32
  # @return [Hash{Symbol => String, Array, nil}]
34
33
  def endpoints
35
- @endpoints ||= Parser.new(response).results
34
+ @endpoints ||= Parser.new(response).to_h
36
35
  end
37
36
 
38
- # The +HTTP::Response+ object returned by the provided URL.
37
+ # The +HTTP::Response+ object.
39
38
  #
40
39
  # @return [HTTP::Response]
41
- # @raise [IndieWeb::Endpoints::HttpError, IndieWeb::Endpoints::SSLError]
40
+ #
41
+ # @raise [HttpError, SSLError]
42
42
  def response
43
- @response ||= HTTP
44
- .follow(max_hops: 20)
45
- .headers(HTTP_HEADERS_OPTS)
46
- .timeout(connect: 5, read: 5)
47
- .get(uri)
43
+ @response ||=
44
+ HTTP
45
+ .follow(max_hops: 20)
46
+ .headers(accept: "*/*", user_agent: user_agent)
47
+ .timeout(connect: 5, read: 5)
48
+ .get(uri)
48
49
  rescue HTTP::Error => e
49
50
  raise HttpError, e
50
51
  rescue OpenSSL::SSL::SSLError => e
@@ -55,6 +56,11 @@ module IndieWeb
55
56
 
56
57
  # @return [HTTP::URI]
57
58
  attr_reader :uri
59
+
60
+ # @return [String]
61
+ def user_agent
62
+ "Mozilla/5.0 (compatible; IndieWebEndpointsDiscovery/1.0; +https://rubygems.org/gems/indieweb-endpoints)"
63
+ end
58
64
  end
59
65
  end
60
66
  end
@@ -9,16 +9,38 @@ module IndieWeb
9
9
  @response = response
10
10
  end
11
11
 
12
- # @return [Hash{Symbol => String, Array<String>, nil}]
13
- def results
12
+ # @param identifier [String]
13
+ # @param node_names [Array<String>]
14
+ #
15
+ # @return [Array<String>]
16
+ #
17
+ # @raise [InvalidURIError]
18
+ def matches(identifier, node_names: ["link"])
19
+ results = (matches_from_headers(identifier) + matches_from_body(identifier, node_names)).compact
20
+
21
+ results.uniq!
22
+ results.sort!
23
+
24
+ results
25
+ end
26
+
27
+ # @param (see #matches)
28
+ #
29
+ # @return [String]
30
+ def match(identifier, **kwargs)
31
+ matches(identifier, **kwargs).first
32
+ end
33
+
34
+ # @return [Hash{Symbol => String, Array, nil}]
35
+ def to_h
14
36
  {
15
- authorization_endpoint: result_for(:authorization_endpoint),
16
- "indieauth-metadata": result_for(:"indieauth-metadata"),
17
- micropub: result_for(:micropub),
18
- microsub: result_for(:microsub),
19
- redirect_uri: results_for(:redirect_uri),
20
- token_endpoint: result_for(:token_endpoint),
21
- webmention: result_for(:webmention, %w[link a])
37
+ authorization_endpoint: match("authorization_endpoint"),
38
+ "indieauth-metadata": match("indieauth-metadata"),
39
+ micropub: match("micropub"),
40
+ microsub: match("microsub"),
41
+ redirect_uri: (redirect_uri = matches("redirect_uri")).any? ? redirect_uri : nil,
42
+ token_endpoint: match("token_endpoint"),
43
+ webmention: match("webmention", node_names: ["link", "a"]),
22
44
  }
23
45
  end
24
46
 
@@ -27,38 +49,39 @@ module IndieWeb
27
49
  # @return [HTTP::Response]
28
50
  attr_reader :response
29
51
 
30
- # @return [IndieWeb::Endpoints::ResponseBodyParser]
31
- def response_body_parser
32
- @response_body_parser ||= ResponseBodyParser.new(response)
33
- end
34
-
35
- # @return [IndieWeb::Endpoints::ResponseHeadersParser]
36
- def response_headers_parser
37
- @response_headers_parser ||= ResponseHeadersParser.new(response)
52
+ # @return [Nokogiri::HTML5::Document]
53
+ def body
54
+ @body ||= Nokogiri::HTML5(response.body, response.uri).resolve_relative_urls!
38
55
  end
39
56
 
40
- # @param identifier [Symbol]
41
- # @param nodes [Array<String>]
42
- # @return [String, nil]
43
- def result_for(identifier, nodes = ["link"])
44
- results_for(identifier, nodes)&.first
57
+ # @return [Hash{Symbol => Array<LinkHeaderParser::LinkHeader>}]
58
+ def headers
59
+ @headers ||= LinkHeaderParser.parse(response.headers.get("link"), base: response.uri).group_by_relation_type
45
60
  end
46
61
 
47
- # @param identifier [Symbol]
48
- # @param nodes [Array<String>]
49
- # @return [Array<String>, nil]
50
- # @raise [IndieWeb::Endpoints::InvalidURIError]
51
- def results_for(identifier, nodes = ["link"])
52
- results_from_request = [
53
- response_headers_parser.results_for(identifier),
54
- response_body_parser.results_for(identifier, nodes)
55
- ].flatten.compact
62
+ # Reject URLs with fragment identifiers per the IndieAuth specification.
63
+ #
64
+ # @param identifier [String, #to_s]
65
+ # @param node_names [Array<String, #to_s>]
66
+ #
67
+ # @return [Array<String>]
68
+ def matches_from_body(identifier, node_names)
69
+ return [] unless response.mime_type == "text/html"
56
70
 
57
- return if results_from_request.none?
71
+ body
72
+ .css(*node_names.map { |node| %(#{node}[rel~="#{identifier}"][href]:not([href*="#"]) / @href) })
73
+ .map(&:value)
74
+ end
58
75
 
59
- results_from_request.map { |endpoint| response.uri.join(endpoint).to_s }.uniq.sort
60
- rescue Addressable::URI::InvalidURIError => e
61
- raise InvalidURIError, e
76
+ # Reject URLs with fragment identifiers per the IndieAuth specification.
77
+ #
78
+ # @param identifier [String, #to_sym]
79
+ #
80
+ # @return [Array<String>]
81
+ def matches_from_headers(identifier)
82
+ Array(headers[identifier.to_sym]).filter_map do |header|
83
+ header.target_uri unless HTTP::URI.parse(header.target_uri).fragment
84
+ end
62
85
  end
63
86
  end
64
87
  end
@@ -2,14 +2,10 @@
2
2
 
3
3
  require "http"
4
4
  require "link-header-parser"
5
- require "nokogiri"
6
-
7
- require_relative "endpoints/version"
5
+ require "nokogiri/html-ext"
8
6
 
9
7
  require_relative "endpoints/client"
10
8
  require_relative "endpoints/parser"
11
- require_relative "endpoints/response_body_parser"
12
- require_relative "endpoints/response_headers_parser"
13
9
 
14
10
  module IndieWeb
15
11
  module Endpoints
@@ -23,13 +19,14 @@ module IndieWeb
23
19
 
24
20
  # Discover a URL's IndieAuth, Micropub, Microsub, and Webmention endpoints.
25
21
  #
26
- # Convenience method for {IndieWeb::Endpoints::Client#endpoints}.
22
+ # Convenience method for {Client#endpoints}.
27
23
  #
28
24
  # @example
29
25
  # IndieWeb::Endpoints.get("https://aaronparecki.com")
30
26
  #
31
- # @param (see IndieWeb::Endpoints::Client#endpoints)
32
- # @return (see IndieWeb::Endpoints::Client#endpoints)
27
+ # @param (see Client#initialize)
28
+ #
29
+ # @return (see Client#endpoints)
33
30
  def self.get(url)
34
31
  Client.new(url).endpoints
35
32
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indieweb-endpoints
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0
4
+ version: 10.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-03-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: http
@@ -30,28 +29,28 @@ dependencies:
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '5.1'
32
+ version: '6.1'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '5.1'
39
+ version: '6.1'
41
40
  - !ruby/object:Gem::Dependency
42
- name: nokogiri
41
+ name: nokogiri-html-ext
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - ">="
44
+ - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '1.16'
46
+ version: '1.4'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - ">="
51
+ - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '1.16'
53
+ version: '1.4'
55
54
  description: Discover a URL’s IndieAuth, Micropub, Microsub, and Webmention endpoints.
56
55
  email:
57
56
  - jason@sixtwothree.org
@@ -68,18 +67,16 @@ files:
68
67
  - lib/indieweb/endpoints.rb
69
68
  - lib/indieweb/endpoints/client.rb
70
69
  - lib/indieweb/endpoints/parser.rb
71
- - lib/indieweb/endpoints/response_body_parser.rb
72
- - lib/indieweb/endpoints/response_headers_parser.rb
73
- - lib/indieweb/endpoints/version.rb
74
70
  homepage: https://github.com/indieweb/indieweb-endpoints-ruby
75
71
  licenses:
76
72
  - MIT
77
73
  metadata:
78
74
  bug_tracker_uri: https://github.com/indieweb/indieweb-endpoints-ruby/issues
79
- changelog_uri: https://github.com/indieweb/indieweb-endpoints-ruby/releases/tag/v9.0.0
75
+ changelog_uri: https://github.com/indieweb/indieweb-endpoints-ruby/releases/tag/v10.0.0
76
+ documentation_uri: https://rubydoc.info/gems/indieweb-endpoints/10.0.0
77
+ homepage_uri: https://github.com/indieweb/indieweb-endpoints-ruby
80
78
  rubygems_mfa_required: 'true'
81
- source_code_uri: https://github.com/indieweb/indieweb-endpoints-ruby/tree/v9.0.0
82
- post_install_message:
79
+ source_code_uri: https://github.com/indieweb/indieweb-endpoints-ruby/tree/v10.0.0
83
80
  rdoc_options: []
84
81
  require_paths:
85
82
  - lib
@@ -87,15 +84,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
84
  requirements:
88
85
  - - ">="
89
86
  - !ruby/object:Gem::Version
90
- version: '3.0'
87
+ version: '2.7'
91
88
  required_rubygems_version: !ruby/object:Gem::Requirement
92
89
  requirements:
93
90
  - - ">="
94
91
  - !ruby/object:Gem::Version
95
92
  version: '0'
96
93
  requirements: []
97
- rubygems_version: 3.5.3
98
- signing_key:
94
+ rubygems_version: 3.6.7
99
95
  specification_version: 4
100
96
  summary: Discover a URL’s IndieAuth, Micropub, Microsub, and Webmention endpoints.
101
97
  test_files: []
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module IndieWeb
4
- module Endpoints
5
- # @api private
6
- class ResponseBodyParser
7
- # @param response [HTTP::Response]
8
- def initialize(response)
9
- @body = response.body.to_s
10
- @mime_type = response.mime_type
11
- @uri = response.uri
12
- end
13
-
14
- # @param identifier [Symbol]
15
- # @param nodes [Array<String>]
16
- # @return [Array<string>, nil]
17
- def results_for(identifier, nodes = ["link"])
18
- return unless mime_type == "text/html"
19
-
20
- # Reject endpoints that contain a fragment identifier
21
- selectors = nodes.map { |node| %(#{node}[rel~="#{identifier}"][href]:not([href*="#"])) }.join(",")
22
-
23
- parsed_body.css(selectors).map { |element| element["href"] }
24
- end
25
-
26
- private
27
-
28
- # @return [String]
29
- attr_reader :body
30
-
31
- # @return [String]
32
- attr_reader :mime_type
33
-
34
- # @return [HTTP::URI]
35
- attr_reader :uri
36
-
37
- # @return [Nokogiri::HTML5::Document]
38
- def parsed_body
39
- @parsed_body ||= Nokogiri::HTML5(body)
40
- end
41
- end
42
- end
43
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module IndieWeb
4
- module Endpoints
5
- # @api private
6
- class ResponseHeadersParser
7
- # @param response [HTTP::Response]
8
- def initialize(response)
9
- @headers = response.headers.get("link")
10
- @uri = response.uri
11
- end
12
-
13
- # @param identifier [Symbol]
14
- # @return [Array<String>, nil]
15
- def results_for(identifier)
16
- # Reject endpoints that contain a fragment identifier
17
- parsed_headers[identifier]&.filter_map do |header|
18
- header.target_uri unless HTTP::URI.parse(header.target_uri).fragment
19
- end
20
- end
21
-
22
- private
23
-
24
- # @return [Array<String>]
25
- attr_reader :headers
26
-
27
- # @return [HTTP::URI]
28
- attr_reader :uri
29
-
30
- # @return [Hash{Symbol => Array<LinkHeaderParser::LinkHeader>}]
31
- def parsed_headers
32
- @parsed_headers ||= LinkHeaderParser.parse(headers, base: uri).group_by_relation_type
33
- end
34
- end
35
- end
36
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module IndieWeb
4
- module Endpoints
5
- VERSION = "9.0.0"
6
- end
7
- end