Class: Gitlab::StaticSiteEditor::Config::FileConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/static_site_editor/config/file_config.rb,
lib/gitlab/static_site_editor/config/file_config/entry/mount.rb,
lib/gitlab/static_site_editor/config/file_config/entry/global.rb,
lib/gitlab/static_site_editor/config/file_config/entry/mounts.rb,
lib/gitlab/static_site_editor/config/file_config/entry/image_upload_path.rb,
lib/gitlab/static_site_editor/config/file_config/entry/static_site_generator.rb

Overview

Base GitLab Static Site Editor Configuration facade

Defined Under Namespace

Modules: Entry

Constant Summary collapse

ConfigError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(yaml) ⇒ FileConfig

Returns a new instance of FileConfig.


12
13
14
15
16
17
18
# File 'lib/gitlab/static_site_editor/config/file_config.rb', line 12

def initialize(yaml)
  content_hash = content_hash(yaml)
  @global = Entry::Global.new(content_hash)
  @global.compose!
rescue Gitlab::Config::Loader::FormatError => e
  raise FileConfig::ConfigError, e.message
end

Instance Method Details

#errorsObject


24
25
26
# File 'lib/gitlab/static_site_editor/config/file_config.rb', line 24

def errors
  @global.errors
end

#to_hash_with_defaultsObject


28
29
30
31
32
# File 'lib/gitlab/static_site_editor/config/file_config.rb', line 28

def to_hash_with_defaults
  # NOTE: The current approach of simply mapping all the descendents' keys and values ('config')
  #       into a flat hash may need to be enhanced as we add more complex, non-scalar entries.
  @global.descendants.to_h { |descendant| [descendant.key, descendant.config] }
end

#valid?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/gitlab/static_site_editor/config/file_config.rb', line 20

def valid?
  @global.valid?
end