1234567891011121314151617181920212223242526272829303132333435 |
- require 'json'
- require 'fileutils'
- $res_root = (lambda {
- dir = File.dirname(__FILE__)
- loop do
- parent_dir = File.expand_path('..', dir)
- break if dir.empty? || parent_dir == dir
- dir = parent_dir
- break if File.exist?("#{dir}/project.godot")
- end
- return dir
- }).call
- CONFIG_ROOT = "#{$res_root}/.tbl"
- def get_options(tool_file)
- options = {}
- name = File.basename(tool_file, ".rb")
- JSON.parse(File.read("#{CONFIG_ROOT}/#{name}.json")).each do |unit|
- key, value = unit['name'], unit['value']
- value.gsub!('res:', $res_root) if value.is_a?(String)
- options[key] = value
- end
- return options
- end
- def convert_case(source)
- return source.split('_').collect(&:capitalize).join
- end
- def recreate_dir(dir)
- FileUtils.rm_rf dir
- FileUtils.mkdir_p dir
- end
|