License
Inherits YAML::Serializable < Reference < Object
A simple class interface for managing licenses.
Constants
A tuple of all available licenses.
Constructors
Class methods
Loads all available licenses at compile time and initializes the licenses method.
This method must be ran before attempting to use the licenses method.
An array of all available licenses. This can only be used after running the License.init method
which will load all available licenses at compile time. Attempting to use this method before
loading will raise an exception.
Instance methods
The nickname of the license. This is generally a variation of the license name or SPDX ID.
Renders the license content to the io. If the year or author parameters are not specified, a default will be rendered in place.
io = IO::Memory.new
license = License.load "mit"
license.render io, year: 2023
io.to_s # => "MIT License ..."
Renders the license content and returns a string. If the year or author parameters are not specified, a default will be rendered in place.
license = License.load "mit"
license.render year: 2023 # => "MIT License ..."
Macros
Loads a license by its SPDX identifier at compile time. If the license is not found, the program will not compile.
License.load "0bsd" # => #<License:0x...>
License.load "asdf" # => Error: Unknown license SPDX-ID: asdf
Returns an array of licenses loaded by their SPDX identifiers at compile time. If one of the licenses are not found, the program will not compile.
License.load "0bsd", "agpl-3.0" # => [#<License:0x...>, #<License:0x...>]
License.load "asdf" # => Error: Unknown license SPDX-ID: asdf
Returns a string of the license rendered at compile time. If the license is not found, the program will not compile.
License.render "mpl-2.0", year: 2023 # => "Mozilla Public License Version 2.0 ..."
License.render "asdf", year: 2023 # => Error: Unknown license SPDX-ID: asdf