about summary refs log tree commit diff
path: root/app/lib/themes.rb
blob: 2dd188297ea9f889e6761ad74fed818c6f689d25 (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
# 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)
      if data['pack'] && data['name']
        result[data['name']] = data
      end
    end
    @conf = result
  end

  def names
    @conf.keys
  end
end