webmention 6.0.0 → 7.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: df8e59b193b673f72a5fecba8c0e381aa28fbb648c6a1b2fdddcb29f9824573e
4
- data.tar.gz: 982c8060b33da7a7ca2e5aa4dd905d6bd49f4a16fd3390b1b6f79ff902b741af
3
+ metadata.gz: 387888cbf5a1a801aad4b0d227ca65a1409368bbfeb531f49fd81419af4bfa90
4
+ data.tar.gz: 2fc1836b5b4384de39d3a69d16d9ad2cc36b4d7aa77a93b14b644dbab59ae751
5
5
  SHA512:
6
- metadata.gz: 4e8dafddec503fba0d36ea31444de7cd6a162dcc1cc76ae88e7587a9f7e2222cfcf8a06b09e071f92aabd4836f9c58438d7bebbf21aed33655b33f2941bbed07
7
- data.tar.gz: 18fe26ed4639d359dd705ae574b02b2bc406a6f74582e6a3fe6f042a061c884e5aefed90280eb3e58a4eefcfca73d4edb8f50553fe2235987dd218e323a3bed3
6
+ metadata.gz: 3ddb3194c1745c61a60820c06146ef0e0eb9fa87ab8c7d1a8eaba4d70d360f553915629534d93ab8785b1e33fab5ed2b526219c3dba1f8f953b72c9fb4ececc2
7
+ data.tar.gz: b32cd9acc63647cc1b8548a4d23a029858f8897f8e34747be18451e040f938943090596903006716d564f1b6e74ac791cf788e36a4696244a70190a83634ddd4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
- ## v6.0.0 / 2022-05-13
3
+ ## 7.0.0 / 2022-11-09
4
+
5
+ - Refactor HTML and JSON parser classes (ec58206 and 6818c05)
6
+ - Update indieweb-endpoints dependency constraint (4cd742f)
7
+ - Relax nokogiri dependency constraint (e86f3bc)
8
+ - **Breaking change:** Update development Ruby to 2.7.6 and minimum Ruby to 2.7 (5bee7dd)
9
+
10
+ ## 6.0.0 / 2022-05-13
4
11
 
5
12
  ### New Features
6
13
 
@@ -8,6 +15,7 @@
8
15
  - `Webmention.send_webmention(source, target)`
9
16
  - `Webmention.send_webmentions(source, *targets)`
10
17
  - `Webmention.mentioned_urls(url)`
18
+ - `Webmention.verify_webmention(source, target)`
11
19
  - New JSON and plaintext parsers
12
20
  - [Vouch](https://indieweb.org/Vouch) URL support (9829269)
13
21
  - Webmention verification support (5fe5f58 and 100644)
@@ -31,17 +39,17 @@
31
39
  - Migrate test suite to RSpec (79ac684)
32
40
  - Migrate to GitHub Actions (f5a3d7a)
33
41
 
34
- ## v5.0.0 / 2020-12-13
42
+ ## 5.0.0 / 2020-12-13
35
43
 
36
44
  - Update absolutely and indieweb-endpoints gems to v5.0 (89f4ea8)
37
45
 
38
- ## v4.0.0 / 2020-08-23
46
+ ## 4.0.0 / 2020-08-23
39
47
 
40
48
  - **Breaking change:** Update minimum supported Ruby version to 2.5 (b2bc62f)
41
49
  - Update indieweb-endpoints to 4.0 (e61588f)
42
50
  - Update project Ruby version to 2.5.8 (2a626a6)
43
51
 
44
- ## v3.0.0 / 2020-05-19
52
+ ## 3.0.0 / 2020-05-19
45
53
 
46
54
  - Reject "internal" URLs when sending webmentions (#24) (ccc82c8)
47
55
  - Select only HTTP/HTTPS URLs when sending webmentions (#22) (39e5852)
data/CONTRIBUTING.md CHANGED
@@ -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.6.10 and is additionally tested against Ruby 2.7, 3.0, and 3.1 using [GitHub Actions](https://github.com/indieweb/webmention-client-ruby/actions).
11
+ webmention-client-ruby is developed using Ruby 2.7.6 and is additionally tested against Ruby 3.0 and 3.1 using [GitHub Actions](https://github.com/indieweb/webmention-client-ruby/actions).
12
12
 
13
- Before making changes to webmention-client-ruby, you'll want to install Ruby 2.6.10. 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.10 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.7.6. 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.7.6 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
@@ -17,9 +17,9 @@
17
17
 
18
18
  ## Getting Started
19
19
 
20
- Before installing and using webmention-client-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).
20
+ Before installing and using webmention-client-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.7 (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).
21
21
 
22
- webmention-client-ruby is developed using Ruby 2.6.10 and is additionally tested against Ruby 2.7, 3.0, and 3.1 using [GitHub Actions](https://github.com/indieweb/webmention-client-ruby/actions).
22
+ webmention-client-ruby is developed using Ruby 2.7.6 and is additionally tested against Ruby 3.0 and 3.1 using [GitHub Actions](https://github.com/indieweb/webmention-client-ruby/actions).
23
23
 
24
24
  ## Installation
25
25
 
@@ -104,7 +104,7 @@ module Webmention
104
104
  # targets = ['https://aaronpk.example/notes/1', 'https://adactio.example/notes/1']
105
105
  # client.send_webmentions(targets)
106
106
  #
107
- # @param *targets [Array<String, HTTP::URI, #to_s>]
107
+ # @param targets [Array<String, HTTP::URI, #to_s>]
108
108
  # An array of absolute URLs representing multiple target documents.
109
109
  #
110
110
  # @return [Array<Webmention::Response, Webmention::ErrorResponse>]
@@ -5,6 +5,8 @@ module Webmention
5
5
  class Parser
6
6
  URI_REGEXP = URI::DEFAULT_PARSER.make_regexp(%w[http https]).freeze
7
7
 
8
+ public_constant :URI_REGEXP
9
+
8
10
  class << self
9
11
  # @return [Array<String>]
10
12
  attr_reader :mime_types
@@ -30,9 +30,8 @@ module Webmention
30
30
  # @return [Array<String>] An array of absolute URLs.
31
31
  def results
32
32
  @results ||=
33
- UrlExtractor.extract(*url_attributes)
34
- .map { |url| response_uri.join(url).to_s }
35
- .grep(Parser::URI_REGEXP)
33
+ extract_urls_from(*url_attributes).map { |url| response_uri.join(url).to_s }
34
+ .grep(Parser::URI_REGEXP)
36
35
  end
37
36
 
38
37
  private
@@ -42,6 +41,19 @@ module Webmention
42
41
  Nokogiri.HTML5(response_body)
43
42
  end
44
43
 
44
+ # @param attributes [Array<Nokogiri::XML::Attr>]
45
+ #
46
+ # @return [Array<String>]
47
+ def extract_urls_from(*attributes)
48
+ attributes.flat_map do |attribute|
49
+ if attribute.name == 'srcset'
50
+ attribute.value.split(',').map { |value| value.strip.match(/^\S+/).to_s }
51
+ else
52
+ attribute.value
53
+ end
54
+ end
55
+ end
56
+
45
57
  # @return [Nokogiri::XML::Element]
46
58
  def root_node
47
59
  doc.at_css(*ROOT_NODE_SELECTORS_ARRAY)
@@ -56,24 +68,6 @@ module Webmention
56
68
  def url_nodes
57
69
  root_node.css(*CSS_SELECTORS_ARRAY)
58
70
  end
59
-
60
- module UrlExtractor
61
- # @param *attributes [Array<Nokogiri::XML::Attr>]
62
- #
63
- # @return [Array<String>]
64
- def self.extract(*attributes)
65
- attributes.flat_map { |attribute| values_from(attribute) }
66
- end
67
-
68
- # @param attribute [Nokogiri::XML::Attr]
69
- #
70
- # @return [String, Array<String>]
71
- def self.values_from(attribute)
72
- return attribute.value unless attribute.name == 'srcset'
73
-
74
- attribute.value.split(',').map { |value| value.strip.match(/^\S+/).to_s }
75
- end
76
- end
77
71
  end
78
72
  end
79
73
  end
@@ -10,30 +10,18 @@ module Webmention
10
10
 
11
11
  # @return [Array<String>] An array of absolute URLs.
12
12
  def results
13
- @results ||= UrlExtractor.extract(doc)
13
+ @results ||= extract_urls_from(JSON.parse(response_body))
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- # @return [Array, Hash]
19
- def doc
20
- @doc ||= JSON.parse(response_body)
21
- end
22
-
23
- module UrlExtractor
24
- # @param *objs [Array<Hash, Array, String, Integer, Boolean, nil>]
25
- #
26
- # @return [Array<String>]
27
- def self.extract(*objs)
28
- objs.flat_map { |obj| values_from(obj) }
29
- end
30
-
31
- # @param obj [Hash, Array, String, Integer, Boolean, nil]
32
- #
33
- # @return [Array<String>, String, nil]
34
- def self.values_from(obj)
35
- return obj.flat_map { |value| extract(value) }.compact if obj.is_a?(Array)
36
- return extract(obj.values) if obj.is_a?(Hash)
18
+ # @param objs [Array<Hash, Array, String, Integer, Boolean, nil>]
19
+ #
20
+ # @return [Array<String>]
21
+ def extract_urls_from(*objs)
22
+ objs.flat_map do |obj|
23
+ return obj.flat_map { |value| extract_urls_from(value) }.compact if obj.is_a?(Array)
24
+ return extract_urls_from(obj.values) if obj.is_a?(Hash)
37
25
 
38
26
  obj if obj.is_a?(String) && obj.match?(Parser::URI_REGEXP)
39
27
  end
@@ -10,7 +10,7 @@ module Webmention
10
10
 
11
11
  # @return [Array<String>] An array of absolute URLs.
12
12
  def results
13
- @results ||= URI.extract(response_body, %w[http https])
13
+ @results ||= URI::DEFAULT_PARSER.extract(response_body, %w[http https])
14
14
  end
15
15
  end
16
16
  end
@@ -57,7 +57,7 @@ module Webmention
57
57
  # An absolute URL representing a source document.
58
58
  # @option options [String] :target
59
59
  # An absolute URL representing a target document.
60
- # @param vouch [String]
60
+ # @option options [String] :vouch
61
61
  # An absolute URL representing a document vouching for the source document.
62
62
  # See https://indieweb.org/Vouch for additional details.
63
63
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Webmention
4
- VERSION = '6.0.0'
4
+ VERSION = '7.0.0'
5
5
  end
data/lib/webmention.rb CHANGED
@@ -76,7 +76,7 @@ module Webmention
76
76
  #
77
77
  # @param source [String, HTTP::URI, #to_s]
78
78
  # An absolute URL representing a source document.
79
- # @param *targets [Array<String, HTTP::URI, #to_s>]
79
+ # @param targets [Array<String, HTTP::URI, #to_s>]
80
80
  # An array of absolute URLs representing multiple target documents.
81
81
  # @param vouch [String, HTTP::URI, #to_s]
82
82
  # An absolute URL representing a document vouching for the source document.
data/webmention.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative 'lib/webmention/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.required_ruby_version = '>= 2.6', '< 4'
6
+ spec.required_ruby_version = '>= 2.7', '< 4'
7
7
 
8
8
  spec.name = 'webmention'
9
9
  spec.version = Webmention::VERSION
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['jason@sixtwothree.org']
12
12
 
13
13
  spec.summary = 'Webmention notification client'
14
- spec.description = 'A Ruby gem for sending Webmention notifications.'
14
+ spec.description = 'A Ruby gem for sending and verifying Webmention notifications.'
15
15
  spec.homepage = 'https://github.com/indieweb/webmention-client-ruby'
16
16
  spec.license = 'Apache-2.0'
17
17
 
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  }
29
29
 
30
30
  spec.add_runtime_dependency 'http', '~> 5.0'
31
- spec.add_runtime_dependency 'indieweb-endpoints', '~> 7.1'
32
- spec.add_runtime_dependency 'nokogiri', '~> 1.13'
31
+ spec.add_runtime_dependency 'indieweb-endpoints', '~> 8.0'
32
+ spec.add_runtime_dependency 'nokogiri', '>= 1.13'
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmention
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2022-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -30,29 +30,29 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.1'
33
+ version: '8.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '7.1'
40
+ version: '8.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.13'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.13'
55
- description: A Ruby gem for sending Webmention notifications.
55
+ description: A Ruby gem for sending and verifying Webmention notifications.
56
56
  email:
57
57
  - jason@sixtwothree.org
58
58
  executables: []
@@ -82,7 +82,7 @@ licenses:
82
82
  - Apache-2.0
83
83
  metadata:
84
84
  bug_tracker_uri: https://github.com/indieweb/webmention-client-ruby/issues
85
- changelog_uri: https://github.com/indieweb/webmention-client-ruby/blob/v6.0.0/CHANGELOG.md
85
+ changelog_uri: https://github.com/indieweb/webmention-client-ruby/blob/v7.0.0/CHANGELOG.md
86
86
  rubygems_mfa_required: 'true'
87
87
  post_install_message:
88
88
  rdoc_options: []
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: '2.6'
95
+ version: '2.7'
96
96
  - - "<"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '4'
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.3.12
105
+ rubygems_version: 3.3.16
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Webmention notification client