webmention 1.0.2 → 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: 4c757e8796a5d3c616772cf36055776e3b4b8d4d8767a22ddbec3866a2073936
4
- data.tar.gz: d748c185ee8d1f8535101b24e8e0b271ef48b52539b2b2dfe9128c9478b9916a
3
+ metadata.gz: fe7be9c5256690feeefb414862b49e7ede87e1aabd63c0f7cb54004fdc9a3412
4
+ data.tar.gz: '078f32d632920db98684c12f3e4fb48048b32801846174848b878c04678a588d'
5
5
  SHA512:
6
- metadata.gz: b1ae7e46c6c7587b0ba9ce065e5d28910a1c5b95039b4203052bd29a413b90587b88b4e04fe798f508462205549a62a2c3ee4dbfe914154ad5286a680ff20347
7
- data.tar.gz: 4e3392411bdb28f2bad6af894ca9a88d2cfa8d29d5d2076793682cc815fe290a763b04e9bddc79d31a6d6a3a6461e7ac6a603d6dc8ab97b671616733b6ac4e59
6
+ metadata.gz: a9e717f3b4ba98a7cc8e022731fba654dece6c3d55584f0f23a84968e13de0c2df17f642e75852d8ef5d831348d9df954c0d9107b47e9280db73812a642ffaf5
7
+ data.tar.gz: 1af3ed848cfe7e78d7b493da12a3e2e2c9e8269b48d79cfb43c8c73483c45569c6689e6484c4c1d789fc14b6f40194b4a1a4bbe39c6a19eecdbe12e180613e88
@@ -1,18 +1,20 @@
1
1
  require:
2
2
  - rubocop-performance
3
3
 
4
- Layout/AlignHash:
4
+ AllCops:
5
+ NewCops: enable
6
+
7
+ Layout/HashAlignment:
5
8
  EnforcedColonStyle: table
6
9
  EnforcedHashRocketStyle: table
7
10
 
11
+ Layout/LineLength:
12
+ Enabled: false
13
+
8
14
  Metrics/BlockLength:
9
15
  Exclude:
10
- - webmention.gemspec
11
16
  - test/**/*
12
17
 
13
- Metrics/LineLength:
14
- Enabled: false
15
-
16
18
  Naming/RescuedExceptionsVariableName:
17
19
  PreferredName: exception
18
20
 
@@ -22,9 +24,5 @@ Style/Documentation:
22
24
  Style/FrozenStringLiteralComment:
23
25
  Enabled: false
24
26
 
25
- Style/SingleLineMethods:
26
- Exclude:
27
- - test/**/*
28
-
29
27
  Style/SymbolArray:
30
28
  Enabled: false
@@ -1 +1 @@
1
- 2.4.7
1
+ 2.5.8
data/.simplecov CHANGED
@@ -3,8 +3,10 @@ require 'simplecov-console'
3
3
  SimpleCov.start do
4
4
  add_filter '/test/'
5
5
 
6
- formatter SimpleCov::Formatter::MultiFormatter.new([
7
- SimpleCov::Formatter::Console,
8
- SimpleCov::Formatter::HTMLFormatter
9
- ])
6
+ formatter SimpleCov::Formatter::MultiFormatter.new(
7
+ [
8
+ SimpleCov::Formatter::Console,
9
+ SimpleCov::Formatter::HTMLFormatter
10
+ ]
11
+ )
10
12
  end
@@ -1,13 +1,10 @@
1
+ dist: bionic
1
2
  language: ruby
2
3
  rvm:
3
- - 2.4
4
4
  - 2.5
5
5
  - 2.6
6
- cache:
7
- - bundler
8
- before_install:
9
- - gem update --system
10
- - gem update bundler
6
+ - 2.7
7
+ cache: bundler
11
8
  before_script:
12
9
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
10
  - chmod +x ./cc-test-reporter
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## v4.0.0 / 2020-08-23
4
+
5
+ - **Breaking change:** Update minimum supported Ruby version to 2.5 (b2bc62f)
6
+ - Update indieweb-endpoints to 4.0 (e61588f)
7
+ - Update project Ruby version to 2.5.8 (2a626a6)
8
+
9
+ ## v3.0.0 / 2020-05-19
10
+
11
+ - Reject "internal" URLs when sending webmentions (#24) (ccc82c8)
12
+ - Select only HTTP/HTTPS URLs when sending webmentions (#22) (39e5852)
13
+
14
+ ## 2.2.0 / 2020-05-18
15
+
16
+ - Update absolutely and indieweb-endpoints gems (350d2ed)
17
+ - Add pry-byebug and `bin/console` script (d2c5e03)
18
+ - Move development dependencies to Gemfile per current Bundler conventions (3a2fc21)
19
+ - Update development Ruby version to 2.4.10 (4c7d1f7)
20
+
21
+ ## 2.1.0 / 2020-04-06
22
+
23
+ - Refactor `BaseParser` class and remove `Registerable` module (b706229)
24
+ - Refactor `HttpRequest` and `NodeParser` classes into Service Objects (f29c073 and 7456bf1)
25
+
26
+ ## 2.0.0 / 2020-01-25
27
+
28
+ - Add Ruby 2.7 to list of supported Ruby versions (c67ed14)
29
+ - Update absolutely, addressable, http, and indieweb-endpoints version constaints (986d326 and 6ba054f)
30
+ - Update development dependencies (74ac982)
31
+ - Update project Ruby version to 2.4.9 and update documentation (fd61ddf)
32
+
3
33
  ## 1.0.2 / 2019-08-31
4
34
 
5
35
  - Update Addressable and WebMock gems (0b98981)
@@ -8,9 +8,9 @@ There are a couple ways you can help improve webmention-client-ruby:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- webmention-client-ruby is developed using Ruby 2.4.7 and is additionally tested against Ruby 2.5 and 2.6 using [Travis CI](https://travis-ci.org/indieweb/webmention-client-ruby).
11
+ webmention-client-ruby is developed using Ruby 2.5.8 and is additionally tested against Ruby 2.6 and 2.7 using [Travis CI](https://travis-ci.org/indieweb/webmention-client-ruby).
12
12
 
13
- Before making changes to webmention-client-ruby, you'll want to install Ruby 2.4.7. 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.4.7 using your method of choice, install the project's gems by running:
13
+ Before making changes to webmention-client-ruby, you'll want to install Ruby 2.5.8. 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.8 using your method of choice, install the project's gems by running:
14
14
 
15
15
  ```sh
16
16
  bundle install
data/Gemfile CHANGED
@@ -2,3 +2,14 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify gem's dependencies in webmention.gemspec
4
4
  gemspec
5
+
6
+ gem 'minitest', '~> 5.14'
7
+ gem 'minitest-reporters', '~> 1.4'
8
+ gem 'pry-byebug', '~> 3.9'
9
+ gem 'rake', '~> 13.0'
10
+ gem 'reek', '~> 6.0'
11
+ gem 'rubocop', '~> 0.89.1'
12
+ gem 'rubocop-performance', '~> 1.7'
13
+ gem 'simplecov', '~> 0.19.0'
14
+ gem 'simplecov-console', '~> 0.7.2'
15
+ gem 'webmock', '~> 3.8'
data/README.md CHANGED
@@ -16,9 +16,9 @@
16
16
 
17
17
  ## Getting Started
18
18
 
19
- Before installing and using webmention-client-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.4 (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).
19
+ Before installing and using webmention-client-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).
20
20
 
21
- webmention-client-ruby is developed using Ruby 2.4.7 and is additionally tested against Ruby 2.5 and 2.6 using [Travis CI](https://travis-ci.org/indieweb/webmention-client-ruby).
21
+ webmention-client-ruby is developed using Ruby 2.5.8 and is additionally tested against Ruby 2.6 and 2.7 using [Travis CI](https://travis-ci.org/indieweb/webmention-client-ruby).
22
22
 
23
23
  ## Installation
24
24
 
@@ -8,20 +8,31 @@ require 'webmention/version'
8
8
  require 'webmention/exceptions'
9
9
 
10
10
  require 'webmention/client'
11
- require 'webmention/http_request'
12
- require 'webmention/registerable'
13
11
 
14
12
  require 'webmention/parsers'
13
+ require 'webmention/parsers/base_parser'
15
14
  require 'webmention/parsers/html_parser'
16
15
 
16
+ require 'webmention/services/http_request_service'
17
+
17
18
  module Webmention
18
- class << self
19
- def client(source)
20
- Client.new(source)
21
- end
19
+ # Create a new Webmention::Client
20
+ # Convenience method for Webmention::Client.new
21
+ #
22
+ # client = Webmention.client('https://source.example.com/post/100')
23
+ #
24
+ # @param source [String] An absolute URL representing the source document
25
+ # @return [Webmention::Client]
26
+ def self.client(source)
27
+ Client.new(source)
28
+ end
22
29
 
23
- def send_mention(source, target)
24
- client(source).send_mention(target)
25
- end
30
+ # Send a webmention from the source URL to the target URL
31
+ #
32
+ # @param source [String] An absolute URL representing the source document
33
+ # @param target [String] An absolute URL representing the target document
34
+ # @return [HTTP::Response, nil]
35
+ def self.send_mention(source, target)
36
+ client(source).send_mention(target)
26
37
  end
27
38
  end
@@ -1,5 +1,10 @@
1
1
  module Webmention
2
2
  class Client
3
+ # Create a new Webmention::Client
4
+ #
5
+ # client = Webmention::Client.new('https://source.example.com/post/100')
6
+ #
7
+ # @param source [String] An absolute URL representing the source document
3
8
  def initialize(source)
4
9
  raise ArgumentError, "source must be a String (given #{source.class.name})" unless source.is_a?(String)
5
10
 
@@ -8,22 +13,34 @@ module Webmention
8
13
  raise ArgumentError, 'source must be an absolute URL (e.g. https://example.com)' unless source_uri.absolute?
9
14
  end
10
15
 
16
+ # Send webmentions to all mentioned URLs in this client's source document
17
+ #
18
+ # @return [Hash{String => HTTP::Response, nil}]
11
19
  def send_all_mentions
12
20
  mentioned_urls.each_with_object({}) { |url, hash| hash[url] = send_mention(url) }
13
21
  end
14
22
 
23
+ # Extract mentioned URLs from this client's source document
24
+ #
25
+ # @return [Array<String>]
26
+ # @raise [Webmention::UnsupportedMimeTypeError]
15
27
  def mentioned_urls
16
28
  raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{source_response.mime_type}" unless parser_for_mime_type
17
29
 
18
30
  @mentioned_urls ||= parser_for_mime_type.new(source_response).results
19
31
  end
20
32
 
33
+ # Send a webmention from this client's source URL to the target URL
34
+ #
35
+ # @param target [String] An absolute URL representing the target document
36
+ # @return [HTTP::Response, nil]
37
+ # @raise [Webmention::ArgumentError, Webmention::ConnectionError, Webmention::InvalidURIError, Webmention::TimeoutError, Webmention::TooManyRedirectsError]
21
38
  def send_mention(target)
22
- endpoint = IndieWeb::Endpoints.get(target).webmention
39
+ endpoint = IndieWeb::Endpoints.get(target)[:webmention]
23
40
 
24
41
  return unless endpoint
25
42
 
26
- HttpRequest.post(Addressable::URI.parse(endpoint), source: @source, target: target)
43
+ Services::HttpRequestService.post(Addressable::URI.parse(endpoint), source: @source, target: target)
27
44
  rescue IndieWeb::Endpoints::IndieWebEndpointsError => exception
28
45
  raise Webmention.const_get(exception.class.name.split('::').last), exception
29
46
  end
@@ -35,7 +52,7 @@ module Webmention
35
52
  end
36
53
 
37
54
  def source_response
38
- @source_response ||= HttpRequest.get(source_uri)
55
+ @source_response ||= Services::HttpRequestService.get(source_uri)
39
56
  end
40
57
 
41
58
  def source_uri
@@ -1,29 +1,11 @@
1
1
  module Webmention
2
2
  module Parsers
3
- extend Registerable
4
-
5
- class BaseParser
6
- def initialize(response)
7
- raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)
8
-
9
- @response = response
10
-
11
- raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{response.mime_type}" unless self.class.mime_types.include?(response.mime_type)
12
- end
13
-
14
- def results
15
- @results ||= parse_response_body
16
- end
17
-
18
- private
19
-
20
- def response_body
21
- @response_body ||= @response.body.to_s
22
- end
3
+ def self.register(klass)
4
+ klass.mime_types.each { |mime_type| registered[mime_type] = klass }
5
+ end
23
6
 
24
- def response_url
25
- @response_url ||= @response.uri.to_s
26
- end
7
+ def self.registered
8
+ @registered ||= {}
27
9
  end
28
10
  end
29
11
  end
@@ -0,0 +1,27 @@
1
+ module Webmention
2
+ module Parsers
3
+ class BaseParser
4
+ class << self
5
+ attr_reader :mime_types
6
+ end
7
+
8
+ def initialize(response)
9
+ raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)
10
+
11
+ @response = response
12
+
13
+ raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{response.mime_type}" unless self.class.mime_types.include?(response.mime_type)
14
+ end
15
+
16
+ private
17
+
18
+ def response_body
19
+ @response_body ||= @response.body.to_s
20
+ end
21
+
22
+ def response_url
23
+ @response_url ||= @response.uri.to_s
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,23 +1,26 @@
1
1
  module Webmention
2
2
  module Parsers
3
3
  class HtmlParser < BaseParser
4
- def self.mime_types
5
- ['text/html']
6
- end
4
+ @mime_types = ['text/html']
7
5
 
8
6
  Parsers.register(self)
9
7
 
10
- HTML_ATTRIBUTE_MAP = {
11
- cite: %w[blockquote del ins q],
12
- data: %w[object],
13
- href: %w[a area],
14
- poster: %w[video],
15
- src: %w[audio embed img source track video],
16
- srcset: %w[img source]
8
+ HTML_ATTRIBUTES_MAP = {
9
+ 'cite' => %w[blockquote del ins q],
10
+ 'data' => %w[object],
11
+ 'href' => %w[a area],
12
+ 'poster' => %w[video],
13
+ 'src' => %w[audio embed img source track video],
14
+ 'srcset' => %w[img source]
17
15
  }.freeze
18
16
 
19
- CSS_SELECTORS_MAP = HTML_ATTRIBUTE_MAP.each_with_object({}) do |(attribute, elements), hash|
20
- hash[attribute] = elements.map { |element| "#{element}[#{attribute}]" }
17
+ CSS_SELECTORS_ARRAY = HTML_ATTRIBUTES_MAP.flat_map { |attribute, names| names.map { |name| "#{name}[#{attribute}]" } }.freeze
18
+
19
+ # Parse an HTML string for URLs
20
+ #
21
+ # @return [Array<String>] Unique external URLs whose scheme matches http/https
22
+ def results
23
+ @results ||= resolved_urls.uniq.select { |url| url.match?(%r{https?://}) }.reject { |url| url.match(/^#{response_url}(?:#.*)?$/) }
21
24
  end
22
25
 
23
26
  private
@@ -26,46 +29,35 @@ module Webmention
26
29
  @doc ||= Nokogiri::HTML(response_body)
27
30
  end
28
31
 
29
- # Parse an HTML string for URLs
30
- #
31
- # @return [Array] the URLs
32
- def parse_response_body
33
- CSS_SELECTORS_MAP
34
- .each_with_object([]) { |(*args), array| array << search_node(*args) }
35
- .flatten
36
- .map { |url| Absolutely.to_abs(base: response_url, relative: url) }
37
- .uniq
32
+ def resolved_urls
33
+ UrlAttributesParser.parse(*url_attributes).map { |url| Absolutely.to_abs(base: response_url, relative: url) }
38
34
  end
39
35
 
40
36
  def root_node
41
- @root_node ||= doc.css('.h-entry .e-content').first || doc.css('.h-entry').first || doc.css('body')
37
+ doc.at_css('.h-entry .e-content', '.h-entry') || doc.css('body')
38
+ end
39
+
40
+ def url_attributes
41
+ url_nodes.flat_map(&:attribute_nodes).select { |attribute| HTML_ATTRIBUTES_MAP.key?(attribute.name) }
42
42
  end
43
43
 
44
- def search_node(attribute, selectors)
45
- NodeParser.nodes_from(root_node, selectors).map { |node| NodeParser.values_from(node, attribute) }.reject(&:empty?)
44
+ def url_nodes
45
+ root_node.css(*CSS_SELECTORS_ARRAY)
46
46
  end
47
47
 
48
- module NodeParser
49
- class << self
50
- # Search a node for matching elements
51
- #
52
- # @param node [Nokogiri::XML::Element]
53
- # @param selectors [Array]
54
- # @return [Nokogiri::XML::NodeSet]
55
- def nodes_from(node, selectors)
56
- node.css(*selectors)
57
- end
48
+ module UrlAttributesParser
49
+ # @param attributes [Array<Nokogiri::XML::Attr>]
50
+ # @return [Array<String>]
51
+ def self.parse(*attributes)
52
+ attributes.flat_map { |attribute| value_from(attribute) }
53
+ end
58
54
 
59
- # Derive attribute values from a single node
60
- #
61
- # @param node [Nokogiri::XML::Element]
62
- # @param attribute [Symbol]
63
- # @return [Array] the HTML attribute values
64
- def values_from(node, attribute)
65
- return Array(node[attribute]) unless attribute == :srcset
55
+ # @param attribute [Nokogiri::XML::Attr]
56
+ # @return [String, Array<String>]
57
+ def self.value_from(attribute)
58
+ return attribute.value unless attribute.name == 'srcset'
66
59
 
67
- node[attribute].split(',').map { |value| value.strip.match(/^\S+/).to_s }
68
- end
60
+ attribute.value.split(',').map { |value| value.strip.match(/^\S+/).to_s }
69
61
  end
70
62
  end
71
63
  end
@@ -0,0 +1,47 @@
1
+ module Webmention
2
+ module Services
3
+ module HttpRequestService
4
+ # Defaults derived from Webmention specification examples
5
+ # https://www.w3.org/TR/webmention/#limits-on-get-requests
6
+ # rubocop:disable Layout/HashAlignment
7
+ HTTP_CLIENT_OPTS = {
8
+ follow: {
9
+ max_hops: 20
10
+ },
11
+ headers: {
12
+ accept: '*/*',
13
+ user_agent: 'Webmention Client (https://rubygems.org/gems/webmention)'
14
+ },
15
+ timeout_options: {
16
+ connect_timeout: 5,
17
+ read_timeout: 5
18
+ }
19
+ }.freeze
20
+ # rubocop:enable Layout/HashAlignment
21
+
22
+ class << self
23
+ def get(uri)
24
+ request(:get, uri)
25
+ end
26
+
27
+ def post(uri, **options)
28
+ request(:post, uri, form: options)
29
+ end
30
+
31
+ private
32
+
33
+ def client
34
+ @client ||= HTTP::Client.new(HTTP_CLIENT_OPTS)
35
+ end
36
+
37
+ def request(method, uri, **options)
38
+ client.request(method, uri, options)
39
+ rescue HTTP::ConnectionError,
40
+ HTTP::TimeoutError,
41
+ HTTP::Redirector::TooManyRedirectsError => exception
42
+ raise Webmention.const_get(exception.class.name.split('::').last), exception
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module Webmention
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,10 +1,7 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
-
4
- require 'webmention/version'
1
+ require_relative 'lib/webmention/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
- spec.required_ruby_version = ['>= 2.4', '< 2.7']
4
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 2.8')
8
5
 
9
6
  spec.name = 'webmention'
10
7
  spec.version = Webmention::VERSION
@@ -16,28 +13,18 @@ Gem::Specification.new do |spec|
16
13
  spec.homepage = 'https://github.com/indieweb/webmention-client-ruby'
17
14
  spec.license = 'Apache-2.0'
18
15
 
19
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test)/}) }
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test)/}) }
18
+ end
20
19
 
21
20
  spec.require_paths = ['lib']
22
21
 
23
- spec.metadata = {
24
- 'bug_tracker_uri' => "#{spec.homepage}/issues",
25
- 'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
26
- }
27
-
28
- spec.add_development_dependency 'minitest', '~> 5.11'
29
- spec.add_development_dependency 'minitest-reporters', '~> 1.3'
30
- spec.add_development_dependency 'rake', '~> 12.3'
31
- spec.add_development_dependency 'reek', '~> 5.4'
32
- spec.add_development_dependency 'rubocop', '~> 0.74.0'
33
- spec.add_development_dependency 'rubocop-performance', '~> 1.4'
34
- spec.add_development_dependency 'simplecov', '~> 0.17.0'
35
- spec.add_development_dependency 'simplecov-console', '~> 0.5.0'
36
- spec.add_development_dependency 'webmock', '~> 3.7'
22
+ spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
23
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
37
24
 
38
- spec.add_runtime_dependency 'absolutely', '~> 3.0'
25
+ spec.add_runtime_dependency 'absolutely', '~> 4.0'
39
26
  spec.add_runtime_dependency 'addressable', '~> 2.7'
40
- spec.add_runtime_dependency 'http', '~> 5.0.0.pre'
41
- spec.add_runtime_dependency 'indieweb-endpoints', '~> 1.0'
27
+ spec.add_runtime_dependency 'http', '~> 4.4'
28
+ spec.add_runtime_dependency 'indieweb-endpoints', '~> 4.0'
42
29
  spec.add_runtime_dependency 'nokogiri', '~> 1.10'
43
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmention
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Parecki
@@ -9,148 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-31 00:00:00.000000000 Z
12
+ date: 2020-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: minitest
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '5.11'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '5.11'
28
- - !ruby/object:Gem::Dependency
29
- name: minitest-reporters
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '1.3'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.3'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '12.3'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '12.3'
56
- - !ruby/object:Gem::Dependency
57
- name: reek
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '5.4'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '5.4'
70
- - !ruby/object:Gem::Dependency
71
- name: rubocop
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: 0.74.0
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: 0.74.0
84
- - !ruby/object:Gem::Dependency
85
- name: rubocop-performance
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '1.4'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '1.4'
98
- - !ruby/object:Gem::Dependency
99
- name: simplecov
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: 0.17.0
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: 0.17.0
112
- - !ruby/object:Gem::Dependency
113
- name: simplecov-console
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: 0.5.0
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: 0.5.0
126
- - !ruby/object:Gem::Dependency
127
- name: webmock
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - "~>"
131
- - !ruby/object:Gem::Version
132
- version: '3.7'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - "~>"
138
- - !ruby/object:Gem::Version
139
- version: '3.7'
140
14
  - !ruby/object:Gem::Dependency
141
15
  name: absolutely
142
16
  requirement: !ruby/object:Gem::Requirement
143
17
  requirements:
144
18
  - - "~>"
145
19
  - !ruby/object:Gem::Version
146
- version: '3.0'
20
+ version: '4.0'
147
21
  type: :runtime
148
22
  prerelease: false
149
23
  version_requirements: !ruby/object:Gem::Requirement
150
24
  requirements:
151
25
  - - "~>"
152
26
  - !ruby/object:Gem::Version
153
- version: '3.0'
27
+ version: '4.0'
154
28
  - !ruby/object:Gem::Dependency
155
29
  name: addressable
156
30
  requirement: !ruby/object:Gem::Requirement
@@ -171,28 +45,28 @@ dependencies:
171
45
  requirements:
172
46
  - - "~>"
173
47
  - !ruby/object:Gem::Version
174
- version: 5.0.0.pre
48
+ version: '4.4'
175
49
  type: :runtime
176
50
  prerelease: false
177
51
  version_requirements: !ruby/object:Gem::Requirement
178
52
  requirements:
179
53
  - - "~>"
180
54
  - !ruby/object:Gem::Version
181
- version: 5.0.0.pre
55
+ version: '4.4'
182
56
  - !ruby/object:Gem::Dependency
183
57
  name: indieweb-endpoints
184
58
  requirement: !ruby/object:Gem::Requirement
185
59
  requirements:
186
60
  - - "~>"
187
61
  - !ruby/object:Gem::Version
188
- version: '1.0'
62
+ version: '4.0'
189
63
  type: :runtime
190
64
  prerelease: false
191
65
  version_requirements: !ruby/object:Gem::Requirement
192
66
  requirements:
193
67
  - - "~>"
194
68
  - !ruby/object:Gem::Version
195
- version: '1.0'
69
+ version: '4.0'
196
70
  - !ruby/object:Gem::Dependency
197
71
  name: nokogiri
198
72
  requirement: !ruby/object:Gem::Requirement
@@ -231,10 +105,10 @@ files:
231
105
  - lib/webmention.rb
232
106
  - lib/webmention/client.rb
233
107
  - lib/webmention/exceptions.rb
234
- - lib/webmention/http_request.rb
235
108
  - lib/webmention/parsers.rb
109
+ - lib/webmention/parsers/base_parser.rb
236
110
  - lib/webmention/parsers/html_parser.rb
237
- - lib/webmention/registerable.rb
111
+ - lib/webmention/services/http_request_service.rb
238
112
  - lib/webmention/version.rb
239
113
  - webmention.gemspec
240
114
  homepage: https://github.com/indieweb/webmention-client-ruby
@@ -242,7 +116,7 @@ licenses:
242
116
  - Apache-2.0
243
117
  metadata:
244
118
  bug_tracker_uri: https://github.com/indieweb/webmention-client-ruby/issues
245
- changelog_uri: https://github.com/indieweb/webmention-client-ruby/blob/v1.0.2/CHANGELOG.md
119
+ changelog_uri: https://github.com/indieweb/webmention-client-ruby/blob/v4.0.0/CHANGELOG.md
246
120
  post_install_message:
247
121
  rdoc_options: []
248
122
  require_paths:
@@ -251,17 +125,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
251
125
  requirements:
252
126
  - - ">="
253
127
  - !ruby/object:Gem::Version
254
- version: '2.4'
128
+ version: '2.5'
255
129
  - - "<"
256
130
  - !ruby/object:Gem::Version
257
- version: '2.7'
131
+ version: '2.8'
258
132
  required_rubygems_version: !ruby/object:Gem::Requirement
259
133
  requirements:
260
134
  - - ">="
261
135
  - !ruby/object:Gem::Version
262
136
  version: '0'
263
137
  requirements: []
264
- rubygems_version: 3.0.6
138
+ rubygems_version: 3.1.2
265
139
  signing_key:
266
140
  specification_version: 4
267
141
  summary: Webmention notification client
@@ -1,41 +0,0 @@
1
- module Webmention
2
- class HttpRequest
3
- # Defaults derived from Webmention specification examples
4
- # https://www.w3.org/TR/webmention/#limits-on-get-requests
5
- # rubocop:disable Layout/AlignHash
6
- HTTP_CLIENT_OPTS = {
7
- follow: {
8
- max_hops: 20
9
- },
10
- headers: {
11
- accept: '*/*',
12
- user_agent: 'Webmention Client (https://rubygems.org/gems/webmention)'
13
- },
14
- timeout_options: {
15
- connect_timeout: 5,
16
- read_timeout: 5
17
- }
18
- }.freeze
19
- # rubocop:enable Layout/AlignHash
20
-
21
- class << self
22
- def get(uri)
23
- request(:get, uri)
24
- end
25
-
26
- def post(uri, **options)
27
- request(:post, uri, form: options)
28
- end
29
-
30
- private
31
-
32
- def request(method, uri, **options)
33
- HTTP::Client.new(HTTP_CLIENT_OPTS).request(method, uri, options)
34
- rescue HTTP::ConnectionError,
35
- HTTP::TimeoutError,
36
- HTTP::Redirector::TooManyRedirectsError => exception
37
- raise Webmention.const_get(exception.class.name.split('::').last), exception
38
- end
39
- end
40
- end
41
- end
@@ -1,11 +0,0 @@
1
- module Webmention
2
- module Registerable
3
- def register(klass)
4
- klass.mime_types.each { |mime_type| registered[mime_type] = klass }
5
- end
6
-
7
- def registered
8
- @registered ||= {}
9
- end
10
- end
11
- end