Sha256: 5d75867de5262621b31ef063c44dc11e10f7a33b8deb3bb42ca9200698689cdc

Contents?: true

Size: 668 Bytes

Versions: 7

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class AsciinemaOnebox
      include Engine
      include StandardEmbed

      always_https
      matches_regexp(/^https?:\/\/asciinema\.org\/a\/[\p{Alnum}_\-]+$/)

      def to_html
        "<script type='text/javascript' src='https://asciinema.org/a/#{match[:asciinema_id]}.js' id='asciicast-#{match[:asciinema_id]}' async></script>"
      end

      def placeholder_html
        "<img src='https://asciinema.org/a/#{match[:asciinema_id]}.png'>"
      end

      private

      def match
        @match ||= @url.match(/asciinema\.org\/a\/(?<asciinema_id>[\p{Alnum}_\-]+)$/)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onebox-2.2.19 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.18 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.17 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.16 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.15 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.14 lib/onebox/engine/asciinema_onebox.rb
onebox-2.2.13 lib/onebox/engine/asciinema_onebox.rb