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, &block) ⇒ Sevgi::Graphics::Element

Adds RDF license metadata inside a metadata element.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



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

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

#License_CC0(**kwargs, &block) ⇒ Sevgi::Graphics::Element

Adds Creative Commons Zero metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



53
54
55
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 53

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

#License_CC_BY_NC(**kwargs, &block) ⇒ Sevgi::Graphics::Element

Adds Creative Commons BY-NC license metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



25
26
27
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 25

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, &block) ⇒ Sevgi::Graphics::Element

Adds Creative Commons BY-NC-ND license metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



46
47
48
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 46

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, &block) ⇒ Sevgi::Graphics::Element

Adds Creative Commons BY-NC-SA license metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



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

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, &block) ⇒ Sevgi::Graphics::Element

Adds Creative Commons BY-ND license metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



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

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, &block) ⇒ 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

Returns:



18
19
20
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 18

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

#License_LAL(**kwargs, &block) ⇒ Sevgi::Graphics::Element

Adds Free Art License metadata.

Parameters:

  • kwargs (Hash)

    RDF work options

Returns:



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

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

#RDF(**_kwargs, &block) ⇒ Sevgi::Graphics::Element

Builds an RDF root element.

Parameters:

  • _kwargs (Hash)

    currently unused options

Returns:

Raises:

  • (Sevgi::ArgumentError)

    when no block is given



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 66

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, &block) ⇒ 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

Returns:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/sevgi/graphics/mixtures/rdf.rb', line 90

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