Sha256: d93f82c7140857d257f3077dabc1bc2344edf9226fc41010df441bdcebd9b3b9

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

require 'xml/mapping_extensions'

module Datacite
  module Mapping

    # Rights information for the {Resource}
    class Rights
      include XML::Mapping

      # Initializes a new {Rights} object
      #
      # @param uri [URI, nil] a URI for the license. Optional.
      # @param value [String] the rights statement. Cannot be empty or nil.
      def initialize(uri: nil, value:)
        self.uri = uri
        self.value = value
      end

      def value=(v)
        fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty?
        @value = v.strip
      end

      # @!attribute [rw] uri
      #   @return [URI, nil] a URI for the license. Optional.
      uri_node :uri, '@rightsURI', default_value: nil

      # @!attribute [rw] value
      #   @return [String] the rights statement. Cannot be empty or nil.
      text_node :value, 'text()'
    end

    class Rights
      CC_ZERO = Rights.new(
        uri: URI('https://creativecommons.org/publicdomain/zero/1.0/'),
        value: 'CC0 1.0 Universal (CC0 1.0) Public Domain Dedication'
      )

      CC_BY = Rights.new(
        uri: URI('https://creativecommons.org/licenses/by/4.0/'),
        value: 'Creative Commons Attribution 4.0 International (CC-BY)'
      )
    end

  end

  # class License
  #   # Convenience instance for the [CC-BY](https://creativecommons.org/licenses/by/4.0/legalcode) license
  #   CC_BY = License.new(
  #       name: 'Creative Commons Attribution 4.0 International (CC-BY)',
  #       uri: URI('https://creativecommons.org/licenses/by/4.0/')
  #   )
  #
  #   # Convenience instance for the [CC0](https://creativecommons.org/publicdomain/zero/1.0/legalcode)
  #   # public domain declaration
  #   CC_ZERO = License.new(
  #       name: 'CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
  #       uri: URI('https://creativecommons.org/publicdomain/zero/1.0/')
  #   )
  # end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datacite-mapping-0.1.17 lib/datacite/mapping/rights.rb