Sha256: c9030b0bcc46a45b56f4e03dcc386ce49ceb75779fbb66e252907ece533add32

Contents?: true

Size: 1.2 KB

Versions: 41

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Bolognese
  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

41 entries across 41 versions & 1 rubygems

Version Path
bolognese-1.11.5 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.11.4 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.11.3 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.11.2 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.11.0 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.10.0 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.18 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.17 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.14 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.13 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.12 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.11 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.10 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.9 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.8 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.7 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.6 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.5 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.4 lib/bolognese/writers/codemeta_writer.rb
bolognese-1.9.3 lib/bolognese/writers/codemeta_writer.rb