catstodon/app/lib/themes.rb

29 lines
480 B
Ruby
Raw Normal View History

2017-09-26 04:24:32 +02:00
# 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)
2017-11-17 06:35:25 +01:00
name = File.basename(File.dirname(path))
if data['pack']
result[name] = data
2017-09-26 04:24:32 +02:00
end
end
@conf = result
end
2017-11-17 06:35:25 +01:00
def get(name)
@conf[name]
end
2017-09-26 04:24:32 +02:00
def names
@conf.keys
end
end