From 2162c3c96f9b7703205c07420260d9a56d1fb6c7 Mon Sep 17 00:00:00 2001 From: Philip Li Date: Wed, 25 Oct 2023 13:02:17 +0800 Subject: [PATCH] lib/lkp_pattern.rb: support arbitrary path Signed-off-by: Philip Li --- lib/lkp_pattern.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/lkp_pattern.rb b/lib/lkp_pattern.rb index ca6d68862..dfc20becb 100755 --- a/lib/lkp_pattern.rb +++ b/lib/lkp_pattern.rb @@ -27,17 +27,22 @@ def load end class << self + attr_reader :klass_2_path + def generate_klass(file_path) + @klass_2_path ||= {} + klass = Class.new(self) do include Singleton def initialize - file_name = self.class.name.sub(/^LKP::/, '').underscore.dasherize - super LKP::Path.src('etc', file_name) + super self.class.superclass.klass_2_path[self.class.name] end end LKP.const_set File.basename(file_path).underscore.camelize, klass + + @klass_2_path[klass.name] = file_path end end end