Class: Lutaml::Jsonschema::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/jsonschema/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
# File 'lib/lutaml/jsonschema/configuration.rb', line 11

def initialize
  @title = nil
  @version = nil
  @description = nil
  @base_url = nil
  @theme = "light"
  @output_path = "output"
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def base_url
  @base_url
end

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def description
  @description
end

#output_pathObject

Returns the value of attribute output_path.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def output_path
  @output_path
end

#themeObject

Returns the value of attribute theme.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def theme
  @theme
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def title
  @title
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'lib/lutaml/jsonschema/configuration.rb', line 8

def version
  @version
end

Class Method Details

.load_from_file(path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lutaml/jsonschema/configuration.rb', line 20

def self.load_from_file(path)
  return new unless File.exist?(path)

  data = YAML.safe_load_file(path)
  config = new
  return config unless data.is_a?(Hash)

  config.title = data["title"] if data.key?("title")
  config.version = data["version"] if data.key?("version")
  config.description = data["description"] if data.key?("description")
  config.base_url = data["base_url"] if data.key?("base_url")
  config.theme = data["theme"] if data.key?("theme")
  config.output_path = data["output_path"] if data.key?("output_path")
  config
end

Instance Method Details

#to_metadataObject



36
37
38
39
40
41
42
43
44
# File 'lib/lutaml/jsonschema/configuration.rb', line 36

def 
  Spa::Metadata.new(
    title: title,
    version: version,
    description: description,
    base_url: base_url,
    theme: theme,
  )
end