Sha256: 8b996b16a481666ac260c715c5650e2083821c3fa47033136df94d232dcf8f62
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
Dir["#{File.dirname(__FILE__)}/manifests/*.rb"].each {|f| require f} class RulesEngineTemplatesGenerator < Rails::Generator::Base attr_reader :rule_type attr_reader :rule_name, :rule_class def initialize(runtime_args, runtime_options = {}) super @rule_type = runtime_args[0] unless runtime_args.length < 1 @rule_name = runtime_args[1].downcase.gsub(/[^a-zA-Z0-9]+/i, '_') unless runtime_args.length < 2 @rule_class = @rule_name.camelize unless runtime_args.length < 2 end def after_generate puts '' puts '******************************************************' if @rule_type.nil? Dir["#{File.dirname(__FILE__)}/manifests/*.rb"].each do |manifest| puts "run >script/generate rules_engine_templates #{File.basename(manifest, '.rb')} [rule name]" end puts '' elsif @rule_name.nil? puts "run >script/generate rules_engine_templates #{@rule_type} [rule name]" puts '' else puts 'run >rake spec to test the new rule' puts '' end end def manifest record do |m| unless @rule_type.nil? klass = Kernel.const_get("#{@rule_type.classify}Manifest") klass.populate_record(m, @rule_name ,@rule_class) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems