Sha256: 4b1b758d57ca06633a6c4d0254293b4d0bc4eb7e3ad540842ae8101b04eecbdb

Contents?: true

Size: 690 Bytes

Versions: 4

Compression:

Stored size: 690 Bytes

Contents

# frozen_string_literal: true

module Commonmeta
  module Readers
    module CommonmetaReader
      def read_commonmeta(string: nil, **options)
        if string.present?
          errors = jsonlint(string)
          return { "errors" => errors } if errors.present?
        end

        read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url,
                                                                                   :sandbox, :validate, :ra))
        meta = string.present? ? JSON.parse(string) : {}
        meta["schema_version"] = "https://commonmeta.org/commonmeta_v0.10"
        meta.compact.merge(read_options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
commonmeta-ruby-3.13 lib/commonmeta/readers/commonmeta_reader.rb
commonmeta-ruby-3.12.1 lib/commonmeta/readers/commonmeta_reader.rb
commonmeta-ruby-3.12.0 lib/commonmeta/readers/commonmeta_reader.rb
commonmeta-ruby-3.11.0 lib/commonmeta/readers/commonmeta_reader.rb