diff --git a/lib/webmention/cli.rb b/lib/webmention/cli.rb index 4063a9d..6eed553 100644 --- a/lib/webmention/cli.rb +++ b/lib/webmention/cli.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -require 'thor' -require 'webmention' +require "thor" +require "webmention" -require_relative 'cli/version' -require_relative 'cli/runner' +require_relative "cli/version" + +require_relative "cli/runner" diff --git a/lib/webmention/cli/runner.rb b/lib/webmention/cli/runner.rb index 7b3def2..c81a354 100644 --- a/lib/webmention/cli/runner.rb +++ b/lib/webmention/cli/runner.rb @@ -5,9 +5,9 @@ module CLI class Runner < Thor include Thor::Actions - package_name 'Webmention' + package_name "Webmention" - map ['-v', '--version'] => :version + map ["-v", "--version"] => :version # :nocov: def self.exit_on_failure? @@ -15,7 +15,7 @@ def self.exit_on_failure? end # :nocov: - desc 'endpoint ', 'Discover the Webmention endpoint for URL' + desc "endpoint ", "Discover the Webmention endpoint for URL" def endpoint(target) url = Webmention::Url.new(target) @@ -24,30 +24,30 @@ def endpoint(target) say url.webmention_endpoint end - desc 'send ', 'Send a webmention from URL to URL' - option :vouch, desc: 'Submit a URL' + desc "send ", "Send a webmention from URL to URL" + option :vouch, desc: "Submit a URL" def send(source, target) response = Webmention.send_webmention(source, target, vouch: options[:vouch]) exit 1 unless response.ok? code = response.code - location = response.headers['Location'] + location = response.headers["Location"] say(code == 201 && location ? location : "#{code} #{response.reason}") exit 1 unless code.between?(200, 299) end - desc 'verify ', 'Verify that URL links to URL' - option :vouch, desc: 'Verify that URL mentions the URL domain' + desc "verify ", "Verify that URL links to URL" + option :vouch, desc: "Verify that URL mentions the URL domain" def verify(source, target) verification = Webmention.verify_webmention(source, target, vouch: options[:vouch]) exit 1 unless verification.verified? end - desc 'version', 'Print version information' + desc "version", "Print version information" def version say "webmention-cli version #{Webmention::CLI::VERSION}" end diff --git a/lib/webmention/cli/version.rb b/lib/webmention/cli/version.rb index f1e7317..f20297f 100644 --- a/lib/webmention/cli/version.rb +++ b/lib/webmention/cli/version.rb @@ -2,6 +2,6 @@ module Webmention module CLI - VERSION = '2.0.0' + VERSION = "2.0.0" end end diff --git a/spec/lib/webmention/cli/runner_endpoint_spec.rb b/spec/lib/webmention/cli/runner_endpoint_spec.rb index 7d12d83..6b22f95 100644 --- a/spec/lib/webmention/cli/runner_endpoint_spec.rb +++ b/spec/lib/webmention/cli/runner_endpoint_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -RSpec.describe Webmention::CLI::Runner, '#endpoint' do +RSpec.describe Webmention::CLI::Runner, "#endpoint" do subject(:cmd) { described_class.new.endpoint(url) } - let(:url) { 'https://jgarber.example/post/100' } + let(:url) { "https://jgarber.example/post/100" } - context 'when no Webmention endpoint found' do + context "when no Webmention endpoint found" do before do stub_request(:get, url).to_return( - body: 'Hello, world!', + body: "Hello, world!", headers: { - 'Content-Type': 'text/html' + "Content-Type": "text/html" } ) end - it 'raises SystemExit' do + it "raises SystemExit" do expect { cmd }.to raise_error(SystemExit) end end - context 'when Webmention endpoint found' do - let(:webmention_endpoint) { 'https://jgarber.example/webmention' } + context "when Webmention endpoint found" do + let(:webmention_endpoint) { "https://jgarber.example/webmention" } before do stub_request(:get, url).to_return( @@ -31,7 +31,7 @@ ) end - it 'prints the Webmention endpoint' do + it "prints the Webmention endpoint" do expect { cmd }.to output("#{webmention_endpoint}\n").to_stdout end end diff --git a/spec/lib/webmention/cli/runner_version_spec.rb b/spec/lib/webmention/cli/runner_version_spec.rb index fa00d38..664d23e 100644 --- a/spec/lib/webmention/cli/runner_version_spec.rb +++ b/spec/lib/webmention/cli/runner_version_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.describe Webmention::CLI::Runner, '#version' do +RSpec.describe Webmention::CLI::Runner, "#version" do subject(:cmd) { described_class.new.version } - it 'prints version information' do + it "prints version information" do expect { cmd }.to output("webmention-cli version #{Webmention::CLI::VERSION}\n").to_stdout end end