Sha256: 128b90399b93d7164a5f07475a00dc08557a13375e0487879f29e859970ed2cd

Contents?: true

Size: 631 Bytes

Versions: 13

Compression:

Stored size: 631 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

13 entries across 13 versions & 1 rubygems

Version Path
govuk_publishing_components-21.36.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.36.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.35.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.34.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.34.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.33.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.32.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.31.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.30.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.29.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.29.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.28.1 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb
govuk_publishing_components-21.28.0 lib/govuk_publishing_components/presenters/machine_readable/dataset_schema.rb