diff --git a/lib/asciidoctor/fdroid-link-inline-macro/extension.rb b/lib/asciidoctor/fdroid-link-inline-macro/extension.rb index 0874244..ab86c9c 100644 --- a/lib/asciidoctor/fdroid-link-inline-macro/extension.rb +++ b/lib/asciidoctor/fdroid-link-inline-macro/extension.rb @@ -16,10 +16,8 @@ class FDroidLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor app_id = target app_metadata_uri = %(https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/#{app_id}.yml) - if attrs['caption'].nil? - metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) } - attrs['caption'] = metadata['AutoName'] - end + metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) } + attrs['caption'] ||= metadata['AutoName'] url = %(https://f-droid.org/#{attrs['lang']}/packages/#{app_id}) doc.register :links, url diff --git a/lib/asciidoctor/flathub-link-inline-macro/extension.rb b/lib/asciidoctor/flathub-link-inline-macro/extension.rb index 7e5d9f0..dc5cd51 100644 --- a/lib/asciidoctor/flathub-link-inline-macro/extension.rb +++ b/lib/asciidoctor/flathub-link-inline-macro/extension.rb @@ -23,10 +23,8 @@ class FlathubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor 'User-Agent' => ::Asciidoctor::FoodogsquaredCustomExtensions::USER_AGENT } - if attrs['caption'].nil? - metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) } - attrs['caption'] = metadata['name'] - end + metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) } + attrs['caption'] ||= metadata['name'] url = %(https://flathub.org/apps/#{app_id}) doc.register :links, url diff --git a/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb b/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb index c15cfc5..55d52c8 100644 --- a/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb +++ b/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb @@ -23,17 +23,15 @@ class MusicBrainzLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor uri = %(#{root_endpoint}/#{attrs['type']}/#{target}) - if attrs['caption'].nil? - metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) } - attrs['caption'] ||= case attrs['type'] - when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series' - metadata['name'] - when 'recording', 'release-group', 'release', 'cdstub', 'work' - metadata['title'] - when 'url' - metadata['resource'] - end - end + metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) } + attrs['caption'] ||= case attrs['type'] + when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series' + metadata['name'] + when 'recording', 'release-group', 'release', 'cdstub', 'work' + metadata['title'] + when 'url' + metadata['resource'] + end target = %(https://musicbrainz.org/#{attrs['type']}/#{target}) doc.register :links, target