Sha256: 925c18945d78aa7b3a9af8d6d54b6eda582c68f99f6ee7b37f7d62e7b416e091
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
Dir["#{File.dirname(__FILE__)}/manifests/*.rb"].each {|f| require f} module RulesEngineTemplates module Generators class RuleGenerator < Rails::Generators::Base source_root File.expand_path(File.dirname(__FILE__) + "/manifests/templates") 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 install if @rule_type.blank? || @rule_name.blank? puts " ***************** rule_type and rule_name required ***************** " puts RuleGenerator.description else begin manifest = Kernel.const_get("#{@rule_type.classify}Manifest") manifest.populate_record(self, @rule_name) rescue puts " ***************** Failed to generate rule #{@rule_type.classify}Manifest ***************** " end end end def self.description result = %Q( ******************************************************************* To create a new rule from the templates run) Dir["#{File.dirname(__FILE__)}/manifests/*.rb"].each do |manifest| result << %Q( script/rails generate rules_engine_templates:rule #{File.basename(manifest, '.rb')} [rule name]) end result << %Q( NOTE : twitter reader requires the 'twitter' gem *******************************************************************) result end desc(description) protected def rule_name @rule_name end def rule_class @rule_class end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rules_engine_templates-0.3.0 | generators/rule_generator.rb |