Sha256: 563d110c42167fb736d235c06a3a1416a43d6b73c4937e0759dd8cb4e1590d59

Contents?: true

Size: 629 Bytes

Versions: 16

Compression:

Stored size: 629 Bytes

Contents

module GovukPublishingComponents
  module Presenters
    class DatasetSchema
      attr_reader :page

      def initialize(page)
        @page = page
      end

      def structured_data
        # http://schema.org/Dataset
        data = CreativeWorkSchema.new(@page).structured_data
          .merge(description)
          .merge(name)
        data["@type"] = "Dataset"
        data
      end

    private

      def description
        {
          "description" => (page.body || page.description).slice(0..4999)
        }
      end

      def name
        {
          "name" => page.title
        }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
govuk_publishing_components-21.27.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.27.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.26.2 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.26.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.26.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.25.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.24.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.23.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.23.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.22.2 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.22.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.22.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.21.3 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.21.2 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.21.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.21.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb