Sha256: b168ad8dc1a2ccdaf6c3d71bb9fb701effd8ecb4b1d991a3e34abfed7f867002

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Bolognese
  module Writers
    module CodemetaWriter
      def codemeta
        return nil unless valid?

        hsh = {
          "@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
          "@type" => types["schemaOrg"],
          "@id" => identifier,
          "identifier" => identifier,
          "codeRepository" => url,
          "title" => parse_attributes(titles, content: "title", first: true),
          "agents" => creator,
          "description" => parse_attributes(descriptions, content: "description", first: true),
          "version" => version,
          "tags" => subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) } : nil,
          "datePublished" => get_date(dates, "Issued"),
          "dateModified" => get_date(dates, "Updated"),
          "publisher" => publisher
        }.compact
        JSON.pretty_generate hsh.presence
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bolognese-1.0.21 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.20 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.19 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.16 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.15 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.13 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.12 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.11 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.10 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.9 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0.8 lib/bolognese/writers/codemeta_writer.rb