Sha256: 1b344caf8b1a474c284939a5e9a60f6c2080e8e1a759a73e1167a8a070cb5c06

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 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" => type,
          "@id" => identifier,
          "identifier" => identifier,
          "codeRepository" => b_url,
          "title" => title,
          "agents" => creator,
          "description" => parse_attributes(description, content: "text", first: true),
          "version" => b_version,
          "tags" => keywords.to_s.split(", ").presence,
          "datePublished" => date_published,
          "dateModified" => date_modified,
          "publisher" => publisher
        }.compact
        JSON.pretty_generate hsh.presence
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bolognese-1.0.1 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.0 lib/bolognese/writers/codemeta_writer.rb