Sha256: 43acb51f86bc87964699a45f71e0c0ccace9ba3d29c6122659e0678524f11b5a

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Briard
  module Writers
    module CodemetaWriter
      def codemeta
        return nil unless valid? || show_errors
        
        hsh = {
          "@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
          "@type" => types.present? ? types["schemaOrg"] : nil,
          "@id" => normalize_doi(doi),
          "identifier" => to_schema_org_identifiers(identifiers),
          "codeRepository" => url,
          "name" => parse_attributes(titles, content: "title", first: true),
          "authors" => creators,
          "description" => parse_attributes(descriptions, content: "description", first: true),
          "version" => version_info,
          "tags" => subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) } : nil,
          "datePublished" => get_date(dates, "Issued") || publication_year,
          "dateModified" => get_date(dates, "Updated"),
          "publisher" => publisher,
          "license" => Array.wrap(rights_list).map { |l| l["rightsUri"] }.compact.unwrap,
        }.compact
        JSON.pretty_generate hsh.presence
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
briard-2.4.2 lib/briard/writers/codemeta_writer.rb
briard-2.4.1 lib/briard/writers/codemeta_writer.rb
briard-2.4 lib/briard/writers/codemeta_writer.rb
briard-2.3.1 lib/briard/writers/codemeta_writer.rb
briard-2.3 lib/briard/writers/codemeta_writer.rb
briard-2.2.7 lib/briard/writers/codemeta_writer.rb
briard-2.2.6 lib/briard/writers/codemeta_writer.rb
briard-2.2.4 lib/briard/writers/codemeta_writer.rb
briard-2.2.3 lib/briard/writers/codemeta_writer.rb
briard-2.2.1 lib/briard/writers/codemeta_writer.rb
briard-2.2 lib/briard/writers/codemeta_writer.rb
briard-2.1 lib/briard/writers/codemeta_writer.rb
briard-2.0.2 lib/briard/writers/codemeta_writer.rb
briard-2.0.1 lib/briard/writers/codemeta_writer.rb
briard-2.0 lib/briard/writers/codemeta_writer.rb