2017-09-26 02:24:32 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'singleton'
|
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
class Themes
|
|
|
|
include Singleton
|
|
|
|
|
|
|
|
def initialize
|
2017-11-21 06:13:37 +00:00
|
|
|
|
|
|
|
core = YAML.load_file(Rails.root.join('app', 'javascript', 'core', 'theme.yml'))
|
|
|
|
core['pack'] = Hash.new unless core['pack']
|
|
|
|
|
2017-09-26 02:24:32 +00:00
|
|
|
result = Hash.new
|
|
|
|
Dir.glob(Rails.root.join('app', 'javascript', 'themes', '*', 'theme.yml')) do |path|
|
|
|
|
data = YAML.load_file(path)
|
2017-11-17 05:35:25 +00:00
|
|
|
name = File.basename(File.dirname(path))
|
|
|
|
if data['pack']
|
2017-11-21 06:13:37 +00:00
|
|
|
data['name'] = name
|
2017-11-17 05:35:25 +00:00
|
|
|
result[name] = data
|
2017-09-26 02:24:32 +00:00
|
|
|
end
|
|
|
|
end
|
2017-11-21 06:13:37 +00:00
|
|
|
|
|
|
|
@core = core
|
2017-09-26 02:24:32 +00:00
|
|
|
@conf = result
|
2017-11-21 06:13:37 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def core
|
|
|
|
@core
|
2017-09-26 02:24:32 +00:00
|
|
|
end
|
|
|
|
|
2017-11-17 05:35:25 +00:00
|
|
|
def get(name)
|
|
|
|
@conf[name]
|
|
|
|
end
|
|
|
|
|
2017-09-26 02:24:32 +00:00
|
|
|
def names
|
|
|
|
@conf.keys
|
|
|
|
end
|
|
|
|
end
|