Class: Webmention::CLI::Runner
- Inherits:
-
Thor
- Object
- Thor
- Webmention::CLI::Runner
- Includes:
- Thor::Actions
- Defined in:
- lib/webmention/cli/runner.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
:nocov:.
Instance Method Summary collapse
- #endpoint(target) ⇒ Object
- #send(source, target) ⇒ Object
- #verify(source, target) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
:nocov:
13 14 15 |
# File 'lib/webmention/cli/runner.rb', line 13 def self.exit_on_failure? true end |
Instance Method Details
#endpoint(target) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/webmention/cli/runner.rb', line 19 def endpoint(target) url = Webmention::Url.new(target) exit 1 unless url.webmention_endpoint? say url.webmention_endpoint end |
#send(source, target) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/webmention/cli/runner.rb', line 29 def send(source, target) response = Webmention.send_webmention(source, target, vouch: [:vouch]) exit 1 unless response.ok? code = response.code location = response.headers["Location"] say(code == 201 && location ? location : "#{code} #{response.reason}") exit 1 unless code.between?(200, 299) end |
#verify(source, target) ⇒ Object
44 45 46 47 48 |
# File 'lib/webmention/cli/runner.rb', line 44 def verify(source, target) verification = Webmention.verify_webmention(source, target, vouch: [:vouch]) exit 1 unless verification.verified? end |
#version ⇒ Object
51 52 53 |
# File 'lib/webmention/cli/runner.rb', line 51 def version say "webmention-cli version #{Webmention::CLI::VERSION}" end |