Class: Superset::Services::DashboardLoader::DashboardConfig

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/superset/services/dashboard_loader.rb

Instance Method Summary collapse

Instance Method Details

#configObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/superset/services/dashboard_loader.rb', line 45

def config
    {
      tmp_uniq_dashboard_path: tmp_uniq_dashboard_path,
      dashboards: load_yamls_for('dashboards'),
      databases:  load_yamls_for('databases'),
      datasets:   load_yamls_for('datasets'),
      charts:     load_yamls_for('charts'),
      metadata:   load_yamls_for('metadata.yaml', pattern_sufix: nil),
    }
end

#load_yaml_and_symbolize_keys(path) ⇒ Object



63
64
65
# File 'lib/superset/services/dashboard_loader.rb', line 63

def load_yaml_and_symbolize_keys(path)
  YAML.load_file(path).deep_symbolize_keys
end

#load_yamls_for(object_path, pattern_sufix: '**/*.yaml') ⇒ Object



56
57
58
59
60
61
# File 'lib/superset/services/dashboard_loader.rb', line 56

def load_yamls_for(object_path, pattern_sufix: '**/*.yaml')
  pattern = File.join([tmp_uniq_dashboard_path, '**', object_path, pattern_sufix].compact)
  Dir.glob(pattern).map do |file|
    { filename: file, content: load_yaml_and_symbolize_keys(file) } if File.file?(file)
  end.compact
end