Module: Sumi::Graphics::Mixtures::RDF

Defined in:
graphics/lib/sumi/graphics/mixtures/rdf.rb

Overview

DSL helpers for RDF and license metadata.

Examples:

Add Creative Commons metadata

Sumi::Graphics.SVG :inkscape do
  License_CC0 title: "Example", creator: "A. Creator"
end

Instance Method Summary collapse

Instance Method Details

#License(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds RDF license metadata inside a metadata element.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



52
53
54
55
56
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 52

def License(**kwargs, &block)
  Work.validate!(kwargs, label: "license")

   { RDFWork(**kwargs, &block) }
end

#License_CC0(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons Zero metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



131
132
133
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 131

def License_CC0(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/publicdomain/zero/1.0/", &block)
end

#License_CC_BY(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



65
66
67
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 65

def License_CC_BY(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by/4.0/", &block)
end

#License_CC_BY_NC(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY-NC license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



87
88
89
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 87

def License_CC_BY_NC(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by-nc/4.0/", &block)
end

#License_CC_BY_NC_ND(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY-NC-ND license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



120
121
122
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 120

def License_CC_BY_NC_ND(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by-nc-nd/4.0/", &block)
end

#License_CC_BY_NC_SA(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY-NC-SA license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



98
99
100
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 98

def License_CC_BY_NC_SA(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by-nc-sa/4.0/", &block)
end

#License_CC_BY_ND(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY-ND license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



109
110
111
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 109

def License_CC_BY_ND(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by-nd/4.0/", &block)
end

#License_CC_BY_SA(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Creative Commons BY-SA license metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



76
77
78
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 76

def License_CC_BY_SA(**kwargs, &block)
  License(**kwargs, license: "https://creativecommons.org/licenses/by-sa/4.0/", &block)
end

#License_LAL(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Adds Free Art License metadata.

Parameters:

  • kwargs (Hash) —

    RDF work options

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:

See Also:



142
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 142

def License_LAL(**kwargs, &block) = License(**kwargs, license: "https://artlibre.org/licence/lal/en/", &block)

#RDF(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Builds an RDF root element.

Parameters:

  • kwargs (Hash) —

    options. RDF currently accepts none

Yields:

  • evaluates the RDF drawing DSL

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:



151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 151

def RDF(**kwargs, &block)
  ArgumentError.("Unknown RDF options: #{kwargs.keys.join(", ")}") unless kwargs.empty?
  ArgumentError.("Block required") unless block

  Element(
    :"rdf:RDF",
    "xmlns:rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "xmlns:dc": "http://purl.org/dc/elements/1.1/",
    "xmlns:cc": "http://creativecommons.org/ns#"
  ) do
    Within(&block)
  end
end

#RDFWork(**kwargs) { ... } ⇒ Sumi::Graphics::Element

Builds a Creative Commons RDF Work element.

Option RDF element
title dc:title
description dc:description
creator dc:creator
publisher dc:publisher
date dc:date
language dc:language
license cc:license resource
rights dc:rights

Parameters:

  • kwargs (Hash) —

    RDF work options

Options Hash (**kwargs):

  • :title (String) —

    work title

  • :description (String) —

    work description

  • :creator (String) —

    creator

  • :publisher (String) —

    publisher

  • :date (String) —

    date

  • :language (String) —

    language

  • :license (String) —

    license URL

  • :rights (String) —

    rights statement

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object) —

    ignored block result

Returns:

Raises:



190
191
192
193
194
195
196
197
198
199
200
201
# File 'graphics/lib/sumi/graphics/mixtures/rdf.rb', line 190

def RDFWork(**kwargs, &block)
  Work.validate!(kwargs, label: "RDF work")

  RDF do
    Element(:"cc:Work", "rdf:about": "") do
      Element(:"dc:format", "image/svg+xml")
      Element(:"dc:type", "rdf:resource": "http://purl.org/dc/dcmitype/StillImage")
      Work.populate(self, kwargs)
      Within(&block) if block
    end
  end
end