File: genjson.rb

package info (click to toggle)
tdiary-theme 5.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,204 kB
  • sloc: javascript: 1,268; ruby: 85; makefile: 5
file content (20 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# genjson.rb: generate theme list as json format
#
# Copyright (C) 2014 by TADA Tadashi <t@tdtds.jp>
# You can modify / distribute under GPL
#

require 'json'

themes = {}
Dir.glob('*/README').sort.each do |readme|
	theme, = readme.split(/\//)
	attrs = {}
	open(readme, &:read).split(/\n\n/m)[0].each_line do |l|
		key, val = l.chomp.split(/:\s*/, 2)
		attrs[key.downcase] = val
	end
	themes[theme] = attrs
end
print(JSON.pretty_generate({}.tap{|h| h['themes'] = themes}))