module Cbt # handle file platform versinn and copy class SrcFile attr_accessor :component_name def initialize component_name, basename, ext=nil unless ext if /^(?.+?)\.(?\w+)$/ =~ basename basename, ext = basename_, ext_ end end @component_name, @basename, @ext = component_name, basename, ext end # search up for the source file for the current file object # with @name as the basename def path dir = [], platform = 'debug' # search up for each dir in row dir.each do |d| [".#{platform}.", "."].each do |filename| file_path = File.join(d, @basename + filename + @ext) # end search and return the file first found in the given directories # return File.expand_path(file_path) if File.exists? file_path return file_path if File.exists? file_path end end nil end # file copy to under workspace def target workspace_dir File.join(workspace_dir, @basename + '.' + @ext) end end # class file # module lua file object holds file contents digest to # prevent accedental over-write class LuaModule < SrcFile attr_accessor :name, :super_class def initialize component_name, name @name, @super_class = name.split("<") super(component_name, @name, 'lua') end end # assets files class AssetFile < SrcFile end class Component attr_accessor :name, :modules, :assets def initialize name, conf @name, @conf = name, conf # if no modules defined, use the name as default @conf["lua_modules"] = Array.new unless @conf["lua_modules"] @conf["lua_modules"] << @name if @conf["lua_modules"].size == 0 @conf["assets"] = Array.new unless @conf["assets"] # parse module definitions, convert to objects @modules, @assets = {}, {} # name => object pair @conf["lua_modules"].each do |lname| raise "invalid lua module name '#{lname}'" unless /^[a-zA-Z][\