Sha256: b2292fa8106b2146b41c3f9b145f8e8ea422ee7c1f1ea2d2dc8c0132188c0f4f

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 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.5.json"
        meta.compact.merge(read_options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
commonmeta-ruby-3.9.0 lib/commonmeta/readers/commonmeta_reader.rb