about summary refs log tree commit diff
path: root/app/lib/themes.rb
blob: f7ec22fd2b8e6b632ce517f7731887e6d61e1863 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'singleton'
require 'yaml'

class Themes
  include Singleton

  def initialize
    result = Hash.new
    Dir.glob(Rails.root.join('app', 'javascript', 'themes', '*', 'theme.yml')) do |path|
      data = YAML.load_file(path)
      name = File.basename(File.dirname(path))
      if data['pack']
        result[name] = data
      end
    end
    @conf = result
  end

  def get(name)
    @conf[name]
  end

  def names
    @conf.keys
  end
end