webmention-verification 0.1.2 → 1.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: e3c66fdd4efc77973e3ce38a4d65743b1abf45697e038e10bb9ecc3ea2c24104
4
- data.tar.gz: 98a39b62a3c569e259d118aafc81ddac613a8fcb95a0eb790f8b9a706b2df940
3
+ metadata.gz: 2132738467e12670eb219ec7c13dd036ecf6f66c1ac9d140dbc2ae5c923bab8e
4
+ data.tar.gz: 6c7ae3453d6d6f49d636232da018296b79653742e006fae38759d25ab97ff7d8
5
5
  SHA512:
6
- metadata.gz: 3a955eaf59b5dbf95e4340dfbbc209df7e54a22f919c003e3ebc2e0ea8f53b15d2ea3fab3fd2a59e79aaf188848672a295945ae6119d2656451b2b45ad4e3d54
7
- data.tar.gz: 7afa7fd61ed8bb71e8be4abd074e210ed9097d78831aa85a5354e565783bc78b6f2950c4672c6e20390c6358968f6f68fbf5b806d83af937e2c2be02e5fdf024
6
+ metadata.gz: 1c179c019d4ef0f934c80971f8c025389cab04f3e4bd1f53989e596e82b426049ed02e63f7a98cd643c55be76ba31d8c29e3170f26783c308048c27332a07429
7
+ data.tar.gz: bd29c4d92f5906acbca29055c1aa68f4e122dc7766046acbe31b457932baf2aa8e4d8a47cf6dd58207ed7d508224e42f464c3ef2da541be104a113aa0dcc1e29
@@ -1,4 +1,4 @@
1
- # EditorConfig is awesome: http://EditorConfig.org
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
2
  root = true
3
3
 
4
4
  [*]
@@ -0,0 +1,11 @@
1
+ detectors:
2
+ DuplicateMethodCall:
3
+ max_calls: 3
4
+ IrresponsibleModule:
5
+ enabled: false
6
+ UtilityFunction:
7
+ exclude:
8
+ - FixtureHelpers#read_fixture
9
+
10
+ exclude_paths:
11
+ - vendor/
@@ -1,9 +1,9 @@
1
1
  require:
2
+ - rubocop-performance
2
3
  - rubocop-rspec
3
4
 
4
5
  Layout/AlignHash:
5
6
  EnforcedColonStyle: table
6
- EnforcedLastArgumentHashStyle: ignore_implicit
7
7
 
8
8
  Metrics/BlockLength:
9
9
  Exclude:
@@ -12,6 +12,9 @@ Metrics/BlockLength:
12
12
  Metrics/LineLength:
13
13
  Enabled: false
14
14
 
15
+ Naming/RescuedExceptionsVariableName:
16
+ PreferredName: exception
17
+
15
18
  RSpec/NestedGroups:
16
19
  Max: 4
17
20
 
@@ -20,3 +23,6 @@ Style/Documentation:
20
23
 
21
24
  Style/FrozenStringLiteralComment:
22
25
  Enabled: false
26
+
27
+ Style/SymbolArray:
28
+ Enabled: false
@@ -1 +1 @@
1
- 2.4.5
1
+ 2.4.6
@@ -1,19 +1,17 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.5
4
- - 2.5.3
5
- - 2.6.0
3
+ - 2.4.6
4
+ - 2.5.5
5
+ - 2.6.2
6
6
  cache:
7
7
  - bundler
8
8
  before_install:
9
- - gem install bundler -v '~> 1.17'
9
+ - gem update --system
10
+ - gem install bundler
10
11
  before_script:
11
12
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
13
  - chmod +x ./cc-test-reporter
13
14
  - ./cc-test-reporter before-build
14
- script:
15
- - bundle exec rubocop
16
- - bundle exec rake
17
15
  after_script:
18
16
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
19
17
  notifications:
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0 / 2019-04-25
4
+
5
+ - Use pre-release HTTP gem (see @httprb/http#489) ([bdcfdad](https://github.com/jgarber623/webmention-verification-ruby/commit/bdcfdad)).
6
+ - Refactor verifiers:
7
+ - ([7eef7bd](https://github.com/jgarber623/webmention-verification-ruby/commit/7eef7bd))
8
+ - ([55eb17e](https://github.com/jgarber623/webmention-verification-ruby/commit/55eb17e))
9
+ - ([bcdf3b4](https://github.com/jgarber623/webmention-verification-ruby/commit/bcdf3b4))
10
+ - Refactor `Client#response` exception handling ([29afcb0](https://github.com/jgarber623/webmention-verification-ruby/commit/29afcb0)).
11
+ - Rename `errors` to `exceptions` ([2bca96b](https://github.com/jgarber623/webmention-verification-ruby/commit/2bca96b)).
12
+ - Spec cleanup:
13
+ - ([4b84f16](https://github.com/jgarber623/webmention-verification-ruby/commit/4b84f16))
14
+ - ([4940e9c](https://github.com/jgarber623/webmention-verification-ruby/commit/4940e9c))
15
+
3
16
  ## 0.1.2 / 2019-01-03
4
17
 
5
18
  - Expand supported Ruby versions to include 2.6 ([1d61fea](https://github.com/jgarber623/webmention-verification-ruby/commit/1d61fea)).
@@ -8,9 +8,9 @@ There are a couple ways you can help improve webmention-verification-ruby:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- webmention-verification-ruby is developed using Ruby 2.4.5 and is additionally tested against Ruby 2.5.3 and 2.6.0 using [Travis CI](https://travis-ci.com/jgarber623/webmention-verification-ruby).
11
+ webmention-verification-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.2 using [Travis CI](https://travis-ci.com/jgarber623/webmention-verification-ruby).
12
12
 
13
- Before making changes to webmention-verification-ruby, you'll want to install Ruby 2.4.5. 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.5 using your method of choice, install the project's gems by running:
13
+ Before making changes to webmention-verification-ruby, you'll want to install Ruby 2.4.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.4.6 using your method of choice, install the project's gems by running:
14
14
 
15
15
  ```sh
16
16
  bundle install
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Jason Garber
3
+ Copyright (c) 2018–present Jason Garber
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  Before installing and using webmention-verification-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).
20
20
 
21
- webmention-verification-ruby is developed using Ruby 2.4.5 and is additionally tested against Ruby 2.5.3 and 2.6.0 using [Travis CI](https://travis-ci.com/jgarber623/webmention-verification-ruby).
21
+ webmention-verification-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.2 using [Travis CI](https://travis-ci.com/jgarber623/webmention-verification-ruby).
22
22
 
23
23
  ## Installation
24
24
 
@@ -129,7 +129,7 @@ require 'webmention/verification'
129
129
  response = HTTP.get('https://source.example.com/post/100')
130
130
  target = 'https://target.example.com/post/100'
131
131
 
132
- verifier = Webmention::Verification::HtmlVerifier.new(response, target)
132
+ verifier = Webmention::Verification::Verifiers::HtmlVerifier.new(response, target)
133
133
 
134
134
  verifier.verified? # returns Boolean
135
135
  verifier.results # returns Array
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ require 'reek/rake/task'
2
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
7
+ Reek::Rake::Task.new
4
8
  RSpec::Core::RakeTask.new
9
+ RuboCop::RakeTask.new
5
10
 
6
- task default: :spec
11
+ task default: [:rubocop, :reek, :spec]
@@ -4,10 +4,12 @@ require 'json'
4
4
  require 'nokogiri'
5
5
 
6
6
  require 'webmention/verification/version'
7
- require 'webmention/verification/error'
7
+ require 'webmention/verification/exceptions'
8
+
8
9
  require 'webmention/verification/client'
9
- require 'webmention/verification/verifier'
10
+ require 'webmention/verification/registerable'
10
11
 
12
+ require 'webmention/verification/verifiers'
11
13
  require 'webmention/verification/verifiers/html_verifier'
12
14
  require 'webmention/verification/verifiers/json_verifier'
13
15
  require 'webmention/verification/verifiers/plaintext_verifier'
@@ -8,53 +8,48 @@ module Webmention
8
8
 
9
9
  attr_reader :source, :target
10
10
 
11
- def initialize(source, target, strict: true)
11
+ def initialize(source, target, **options)
12
12
  raise ArgumentError, "source must be a String (given #{source.class.name})" unless source.is_a?(String)
13
13
  raise ArgumentError, "target must be a String (given #{target.class.name})" unless target.is_a?(String)
14
14
 
15
15
  @source = source
16
16
  @target = target
17
- @strict = strict
17
+ @options = options
18
18
 
19
19
  raise ArgumentError, 'source must be an absolute URI (e.g. https://example.com/post/100)' unless source_uri.absolute?
20
20
  raise ArgumentError, 'target must be an absolute URI (e.g. https://example.com/post/100)' unless target_uri.absolute?
21
21
  end
22
22
 
23
23
  def response
24
- @response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(
25
- connect: 10,
26
- read: 10
27
- ).get(source_uri)
28
- rescue HTTP::ConnectionError => error
29
- raise ConnectionError, error
30
- rescue HTTP::TimeoutError => error
31
- raise TimeoutError, error
32
- rescue HTTP::Redirector::TooManyRedirectsError => error
33
- raise TooManyRedirectsError, error
24
+ @response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(connect: 10, read: 10).get(source_uri)
25
+ rescue HTTP::ConnectionError,
26
+ HTTP::TimeoutError,
27
+ HTTP::Redirector::TooManyRedirectsError => exception
28
+ raise Webmention::Verification.const_get(exception.class.name.split('::').last), exception
34
29
  end
35
30
 
36
31
  def source_uri
37
32
  @source_uri ||= Addressable::URI.parse(source)
38
- rescue Addressable::URI::InvalidURIError => error
39
- raise InvalidURIError, error
33
+ rescue Addressable::URI::InvalidURIError => exception
34
+ raise InvalidURIError, exception
40
35
  end
41
36
 
42
37
  def target_uri
43
38
  @target_uri ||= Addressable::URI.parse(target)
44
- rescue Addressable::URI::InvalidURIError => error
45
- raise InvalidURIError, error
39
+ rescue Addressable::URI::InvalidURIError => exception
40
+ raise InvalidURIError, exception
46
41
  end
47
42
 
48
43
  def verified?
49
44
  raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{response.mime_type}" unless verifier_for_mime_type
50
45
 
51
- verifier_for_mime_type.new(response, target, strict: @strict).verified?
46
+ verifier_for_mime_type.new(response, target, @options).verified?
52
47
  end
53
48
 
54
49
  private
55
50
 
56
51
  def verifier_for_mime_type
57
- @verifier_for_mime_type ||= Verifier.subclasses.find { |verifier| verifier.mime_types.include?(response.mime_type) }
52
+ @verifier_for_mime_type ||= Verifiers.registered[response.mime_type]
58
53
  end
59
54
  end
60
55
  end
@@ -0,0 +1,13 @@
1
+ module Webmention
2
+ module Verification
3
+ module Registerable
4
+ def register(klass)
5
+ klass.mime_types.each { |mime_type| registered[mime_type] = klass }
6
+ end
7
+
8
+ def registered
9
+ @registered ||= {}
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,44 @@
1
+ module Webmention
2
+ module Verification
3
+ module Verifiers
4
+ extend Registerable
5
+
6
+ class BaseVerifier
7
+ def initialize(response, target, **options)
8
+ raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)
9
+ raise ArgumentError, "target must be a String (given #{target.class.name})" unless target.is_a?(String)
10
+
11
+ @response = response
12
+ @target = target
13
+ @options = options
14
+
15
+ raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{response.mime_type}" unless self.class.mime_types.include?(response.mime_type)
16
+ end
17
+
18
+ def results
19
+ @results ||= parse_response_body
20
+ end
21
+
22
+ def verified?
23
+ results.any?
24
+ end
25
+
26
+ private
27
+
28
+ def response_body
29
+ @response_body ||= @response.body.to_s
30
+ end
31
+
32
+ def target_regexp
33
+ @target_regexp ||= /^#{target_regexp_str}$/
34
+ end
35
+
36
+ def target_regexp_str
37
+ return @target if @options.fetch(:strict, true)
38
+
39
+ @target.sub(%r{https?://}, 'https?://')
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,47 +1,43 @@
1
1
  module Webmention
2
2
  module Verification
3
- class HtmlVerifier < Verifier
4
- HTML_ATTRIBUTE_MAPPINGS = {
5
- cite: %w[blockquote del ins q],
6
- data: %w[object],
7
- href: %w[a area],
8
- poster: %w[video],
9
- src: %w[audio embed img source track video],
10
- srcset: %w[img source]
11
- }.freeze
12
-
13
- def self.mime_types
14
- ['text/html']
15
- end
3
+ module Verifiers
4
+ class HtmlVerifier < BaseVerifier
5
+ def self.mime_types
6
+ ['text/html']
7
+ end
16
8
 
17
- private
9
+ Verifiers.register(self)
18
10
 
19
- def doc
20
- @doc ||= Nokogiri::HTML(response_body)
21
- end
11
+ HTML_ATTRIBUTE_MAP = {
12
+ cite: %w[blockquote del ins q],
13
+ data: %w[object],
14
+ href: %w[a area],
15
+ poster: %w[video],
16
+ src: %w[audio embed img source track video],
17
+ srcset: %w[img source]
18
+ }.freeze
22
19
 
23
- def parse_response_body
24
- matches = []
20
+ private
25
21
 
26
- HTML_ATTRIBUTE_MAPPINGS.each do |attribute, elements|
27
- elements.each { |element| matches << search_doc(element, attribute) }
22
+ def doc
23
+ @doc ||= Nokogiri::HTML(response_body)
28
24
  end
29
25
 
30
- matches.flatten
31
- end
32
-
33
- def search_doc(element, attribute)
34
- regexp = attribute == :srcset ? srcset_attribute_regexp : target_regexp
26
+ def parse_response_body
27
+ HTML_ATTRIBUTE_MAP.each_with_object([]) { |(*args), matches| matches << search_doc(*args) }.flatten
28
+ end
35
29
 
36
- doc.css("#{element}[#{attribute}]").find_all { |node| node[attribute].match?(regexp) }
37
- end
30
+ def search_doc(attribute, elements)
31
+ regexp = attribute == :srcset ? srcset_attribute_regexp : target_regexp
38
32
 
39
- def srcset_attribute_regexp
40
- @srcset_attribute_regexp ||= /(?:^|\b)#{target_regexp_str}\s/
41
- end
33
+ doc.css(*elements.map { |element| "#{element}[#{attribute}]" }).find_all do |node|
34
+ node[attribute].match?(regexp)
35
+ end
36
+ end
42
37
 
43
- def target_regexp
44
- @target_regexp ||= /^#{target_regexp_str}$/
38
+ def srcset_attribute_regexp
39
+ @srcset_attribute_regexp ||= /(?:^|\b)#{target_regexp_str}\s/
40
+ end
45
41
  end
46
42
  end
47
43
  end
@@ -1,34 +1,50 @@
1
1
  module Webmention
2
2
  module Verification
3
- class JsonVerifier < Verifier
4
- def self.mime_types
5
- ['application/json']
6
- end
3
+ module Verifiers
4
+ class JsonVerifier < BaseVerifier
5
+ def self.mime_types
6
+ ['application/json']
7
+ end
7
8
 
8
- private
9
+ Verifiers.register(self)
9
10
 
10
- def comparator(value)
11
- value.is_a?(String) && value.match?(target_regexp)
12
- end
11
+ private
13
12
 
14
- def locate(object, matches = [])
15
- if object.is_a?(Enumerable)
16
- matches << object if object.any? { |_, value| comparator(value) }
13
+ def parse_response_body
14
+ DeepLocator.new(JSON.parse(response_body), target_regexp).results
15
+ end
17
16
 
18
- (object.respond_to?(:values) ? object.values : object.entries).each do |obj|
19
- locate(obj, matches)
17
+ class DeepLocator
18
+ def initialize(json, pattern)
19
+ @json = json
20
+ @pattern = pattern
20
21
  end
21
- end
22
22
 
23
- matches
24
- end
23
+ def results
24
+ @results ||= build_results(comparator, @json)
25
+ end
25
26
 
26
- def parse_response_body
27
- locate(JSON.parse(response_body))
28
- end
27
+ def self.values_for(object)
28
+ object.is_a?(Hash) ? object.values : object.entries
29
+ end
29
30
 
30
- def target_regexp
31
- @target_regexp ||= /^#{target_regexp_str}$/
31
+ private
32
+
33
+ # :reek:TooManyStatements { max_statements: 6 }
34
+ def build_results(comparator, object, matches = [])
35
+ return matches unless object.is_a?(Enumerable)
36
+
37
+ matches << object if object.any? { |_, value| comparator.call(value) }
38
+
39
+ self.class.values_for(object).each { |value| build_results(comparator, value, matches) }
40
+
41
+ matches
42
+ end
43
+
44
+ def comparator
45
+ @comparator ||= ->(value) { value.is_a?(String) && value.match?(@pattern) }
46
+ end
47
+ end
32
48
  end
33
49
  end
34
50
  end
@@ -1,18 +1,22 @@
1
1
  module Webmention
2
2
  module Verification
3
- class PlaintextVerifier < Verifier
4
- def self.mime_types
5
- ['text/plain']
6
- end
3
+ module Verifiers
4
+ class PlaintextVerifier < BaseVerifier
5
+ def self.mime_types
6
+ ['text/plain']
7
+ end
7
8
 
8
- private
9
+ Verifiers.register(self)
9
10
 
10
- def parse_response_body
11
- response_body.scan(target_regexp)
12
- end
11
+ private
12
+
13
+ def parse_response_body
14
+ response_body.scan(target_regexp)
15
+ end
13
16
 
14
- def target_regexp
15
- @target_regexp ||= /(?:^|\s)#{target_regexp_str}(?:\s|$)/
17
+ def target_regexp
18
+ @target_regexp ||= /(?:^|\s)#{target_regexp_str}(?:\s|$)/
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -1,5 +1,5 @@
1
1
  module Webmention
2
2
  module Verification
3
- VERSION = '0.1.2'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
@@ -20,16 +20,17 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.17'
24
23
  spec.add_development_dependency 'rake', '~> 12.3'
24
+ spec.add_development_dependency 'reek', '~> 5.4'
25
25
  spec.add_development_dependency 'rspec', '~> 3.8'
26
- spec.add_development_dependency 'rubocop', '~> 0.62.0'
27
- spec.add_development_dependency 'rubocop-rspec', '~> 1.31'
26
+ spec.add_development_dependency 'rubocop', '~> 0.67.2'
27
+ spec.add_development_dependency 'rubocop-performance', '~> 1.1'
28
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
28
29
  spec.add_development_dependency 'simplecov', '~> 0.16.1'
29
30
  spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
30
- spec.add_development_dependency 'webmock', '~> 3.4'
31
+ spec.add_development_dependency 'webmock', '~> 3.5'
31
32
 
32
- spec.add_runtime_dependency 'addressable', '~> 2.5'
33
- spec.add_runtime_dependency 'http', '~> 4.0'
34
- spec.add_runtime_dependency 'nokogiri', '~> 1.8'
33
+ spec.add_runtime_dependency 'addressable', '~> 2.6'
34
+ spec.add_runtime_dependency 'http', '~> 5.0.0.pre'
35
+ spec.add_runtime_dependency 'nokogiri', '~> 1.10'
35
36
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmention-verification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.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: 2019-01-03 00:00:00.000000000 Z
11
+ date: 2019-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '12.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '12.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: reek
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '12.3'
33
+ version: '5.4'
34
34
  type: :development
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: '12.3'
40
+ version: '5.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.62.0
61
+ version: 0.67.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.67.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 0.62.0
82
+ version: '1.1'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '1.31'
89
+ version: '1.32'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '1.31'
96
+ version: '1.32'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,56 +128,56 @@ dependencies:
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '3.4'
131
+ version: '3.5'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '3.4'
138
+ version: '3.5'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: addressable
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '2.5'
145
+ version: '2.6'
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '2.5'
152
+ version: '2.6'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: http
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '4.0'
159
+ version: 5.0.0.pre
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '4.0'
166
+ version: 5.0.0.pre
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: nokogiri
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '1.8'
173
+ version: '1.10'
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '1.8'
180
+ version: '1.10'
167
181
  description: Verify a received webmention.
168
182
  email:
169
183
  - jason@sixtwothree.org
@@ -173,6 +187,7 @@ extra_rdoc_files: []
173
187
  files:
174
188
  - ".editorconfig"
175
189
  - ".gitignore"
190
+ - ".reek.yml"
176
191
  - ".rspec"
177
192
  - ".rubocop"
178
193
  - ".rubocop.yml"
@@ -187,8 +202,9 @@ files:
187
202
  - Rakefile
188
203
  - lib/webmention/verification.rb
189
204
  - lib/webmention/verification/client.rb
190
- - lib/webmention/verification/error.rb
191
- - lib/webmention/verification/verifier.rb
205
+ - lib/webmention/verification/exceptions.rb
206
+ - lib/webmention/verification/registerable.rb
207
+ - lib/webmention/verification/verifiers.rb
192
208
  - lib/webmention/verification/verifiers/html_verifier.rb
193
209
  - lib/webmention/verification/verifiers/json_verifier.rb
194
210
  - lib/webmention/verification/verifiers/plaintext_verifier.rb
@@ -216,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
232
  - !ruby/object:Gem::Version
217
233
  version: '0'
218
234
  requirements: []
219
- rubygems_version: 3.0.2
235
+ rubygems_version: 3.0.3
220
236
  signing_key:
221
237
  specification_version: 4
222
238
  summary: Verify a received webmention.
@@ -1,58 +0,0 @@
1
- module Webmention
2
- module Verification
3
- class Verifier
4
- attr_reader :response, :target
5
-
6
- def initialize(response, target, strict: true)
7
- raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)
8
- raise ArgumentError, "target must be a String (given #{target.class.name})" unless target.is_a?(String)
9
-
10
- @response = response
11
- @target = target
12
- @strict = strict
13
-
14
- raise UnsupportedMimeTypeError, "Unsupported MIME Type: #{response.mime_type}" unless self.class.mime_types.include?(response.mime_type)
15
- end
16
-
17
- def results
18
- @results ||= parse_response_body
19
- end
20
-
21
- def verified?
22
- results.any?
23
- end
24
-
25
- class << self
26
- def inherited(base)
27
- subclasses << base
28
-
29
- super(base)
30
- end
31
-
32
- def mime_types
33
- mime_types = []
34
-
35
- subclasses.each { |subclass| mime_types << subclass.mime_types }
36
-
37
- mime_types.flatten.sort
38
- end
39
-
40
- def subclasses
41
- @subclasses ||= []
42
- end
43
- end
44
-
45
- private
46
-
47
- def response_body
48
- @response_body ||= response.body.to_s
49
- end
50
-
51
- def target_regexp_str
52
- return target if @strict
53
-
54
- target.sub(%r{https?://}, 'https?://')
55
- end
56
- end
57
- end
58
- end