Dir[File.join(File.dirname(File.expand_path(__FILE__)),"..","itrigga-generator","*.rb")].each {|f| require f } namespace :itrigga do desc "Generates files" task :generator do raise "Must enter an config file" unless ENV['CONFIG_FILE'] # Example rake calls # rake itrigga:generator PATTERN=monit TEMPLATE_DIR=/tmp/test/templates OUTPUT_DIR=/tmp/test/output CONFIG_FILE=/tmp/test/test.yml BASE_DIR=/var/www/itrigga/shared # # rake itrigga:generator PATTERN=logrotate TEMPLATE_DIR=/tmp/test/templates OUTPUT_DIR=/tmp/test/output CONFIG_FILE=false BASE_DIR=/var/www/itrigga/shared # convert all ENV params into a hash with symbolised keys args = ENV.inject({}){|h,e| h[e[0].to_s.downcase.to_sym] = (e[1].to_s == "false" ? false : e[1]);h; } generator = ITrigga::Generator::Generator.new args generator.generate end end