require 'semver' require 'rake' require 'rake/clean' include Rake::DSL require_relative './commands.rb' require_relative './dependencies.rb' require_relative './console.rb' CLEAN.include("*.gem") VERSION='0.0.9' class DevTasks attr_accessor :version, :commands, :dependencies def initialize v=SemVer.find @version=VERSION @commands=Commands.new @dependencies=Dependencies.new update_tasks end def execute_task task start_time=Time.now Console.announce_task_start task if(!@commands.has_key?(task)) puts "no commands discovered for task " + task else @commands[task].each {|c| @commands.execute_command(c) } end end_time=Time.now elapsed=end_time-start_time elapsed_str="[" + "%.0f" %(elapsed) + "s]" Console.announce_task_end task, elapsed_str end def define_task task_name if(!Rake::Task.task_defined?(task_name)) ruby="desc '#{task_name} task';task :#{task_name} do;DEV_TASKS.execute_task '#{task_name}';end" eval(ruby) end end def update_tasks dev_task_defaults=Array.new @commands.each do |key,array| if(array.length > 0) define_task key dev_task_defaults << key end end if(!Rake::Task.task_defined?('dev_tasks_default')) tasklist="" dev_task_defaults.each{|t| tasklist = tasklist + "," if tasklist.length > 0 tasklist = tasklist + ":" + t } ruby="desc 'dev_tasks_default task';task :dev_tasks_default => [#{tasklist}] do;end" eval(ruby) end end end DEV_TASKS=DevTasks.new desc 'displays information about current rake directory' task :info do puts Color.green + "dev_tasks " + version + Color.clear puts "DEV_TASKS.commands" puts " " puts DEV_TASKS.commands.show puts " " puts "DEV_TASKS.dependencies" puts " " puts DEV_TASKS.dependencies.show puts " " end desc 'displays help for dev_task' task :help do puts "use rake -T to see available tasks" end