Sha256: ecfed89f79ed9f0161a7b28dd1f6f0f68dfa918642952e11cabdf9af1cf97402

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

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["type"],
          "@id" => identifier,
          "identifier" => identifier,
          "codeRepository" => url,
          "title" => title,
          "agents" => creator,
          "description" => parse_attributes(description, content: "text", first: true),
          "version" => version,
          "tags" => keywords.to_s.split(", ").presence,
          "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

1 entries across 1 versions & 1 rubygems

Version Path
bolognese-1.0.3 lib/bolognese/writers/codemeta_writer.rb