Module: Sevgi::Graphics::Mixtures::RDF

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

Overview

DSL helpers for RDF and license metadata.

Instance Method Summary collapse

Instance Method Details

#License(**kwargs) { ... } ⇒ Sevgi::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:



13
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 13

def License(**kwargs, &block) =  { RDFWork(**kwargs, &block) }

#License_CC0(**kwargs) { ... } ⇒ Sevgi::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:



67
68
69
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 67

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

#License_CC_BY_NC(**kwargs) { ... } ⇒ Sevgi::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:



31
32
33
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 31

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) { ... } ⇒ Sevgi::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:



58
59
60
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 58

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) { ... } ⇒ Sevgi::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:



40
41
42
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 40

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) { ... } ⇒ Sevgi::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:



49
50
51
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 49

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) { ... } ⇒ Sevgi::Graphics::Element

Use SPDX license codes in underscored form: https://spdx.org/licenses/

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:



22
23
24
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 22

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

#License_LAL(**kwargs) { ... } ⇒ Sevgi::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:



76
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 76

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

#RDF(**_kwargs) { ... } ⇒ Sevgi::Graphics::Element

Builds an RDF root element.

Parameters:

  • _kwargs (Hash)

    currently unused options

Yields:

  • evaluates the RDF drawing DSL

Yield Returns:

  • (Object)

    ignored block result

Returns:

Raises:

  • (Sevgi::ArgumentError)

    when no block is given



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 84

def RDF(**_kwargs, &block)
  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) { ... } ⇒ Sevgi::Graphics::Element

rubocop:disable Metrics/MethodLength Builds a Creative Commons RDF Work element.

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

Yields:

  • evaluates additional RDF work metadata

Yield Returns:

  • (Object)

    ignored block result

Returns:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 110

def RDFWork(**kwargs, &block)
  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")
      Element(:"dc:title", kwargs[:title]) if kwargs[:title]
      Element(:"dc:description", kwargs[:description]) if kwargs[:description]
      Element(:"dc:creator", kwargs[:creator]) if kwargs[:creator]
      Element(:"dc:publisher", kwargs[:publisher]) if kwargs[:publisher]
      Element(:"dc:date", kwargs[:date]) if kwargs[:date]
      Element(:"dc:language", kwargs[:language]) if kwargs[:language]
      Element(:"cc:license", "rdf:resource": kwargs[:license]) if kwargs[:license]

      Within(&block) if block
    end
  end
end