lib/dev_tasks.rb in dev_tasks-0.0.141 vs lib/dev_tasks.rb in dev_tasks-0.0.142

- old
+ new

@@ -4,19 +4,18 @@ include Rake::DSL require_relative './environment.rb' require_relative './commands.rb' require_relative './dependencies.rb' -require_relative './artifacts.rb' require_relative './console.rb' require_relative './timer.rb' require_relative './settings.rb' require_relative './text.rb' require_relative './svnexports.rb' -CLEAN.include('log','*.gem','bin/**/*.dll','bin/**/*.pdb','bin/**/*.exe') -CLOBBER.include('bin','obj','TestResults') +CLEAN.include('log','bin/**/*.pdb') +CLOBBER.include('bin','obj','TestResults','*.gem','bin/**/*.exe') class DevTasks < Hash attr_accessor :timer @@ -25,21 +24,30 @@ self[:name]=pwd.split('/').last#Rake.application.original_dir.split('/').last self[:svn_exports]=SvnExports.new self[:scm]=Environment.scm self[:scm_origin]=Environment.scm_origin self[:branch]=Environment.branch - self[:src_glob]="**/{*.{rb,feature,spec,cs,c,m,cpp,cxx,h,hpp,i,jam,csproj,vcproj,snk,vcxproj,xcodeproj,plist,xib,sln,filters,xaml,resx,settings,config},Jamfile,.semver,Gemfile,README,LICENSE}" - self[:newest_src_file]=Dir.glob(self[:src_glob]).max_by {|f| File.mtime(f)} + + + + self[:command_order]=['pull','upgrade','setup','add','build','test','commit','push','verify','publish'] self[:relative_directory]=Environment.relative_directory self[:working_directory]=Environment.working_directory self[:context]=Environment.context self[:machine]=Environment.machine self[:platform]=RUBY_PLATFORM self[:dev_root]=Environment.dev_root self[:settings]=Settings.new + self[:files]=Hash.new + self[:files][:source]=Rake::FileList.new("**/{*.{rb,feature,spec,cs,c,m,cpp,cxx,h,hpp,i,jam,csproj,vcproj,snk,vcxproj,xcodeproj,plist,xib,sln,filters,xaml,resx,settings,config},Jamfile,.semver,Gemfile,README,LICENSE}") + self[:files][:build]=Rake::FileList.new('**/*.{gemspec,sln}') + self[:files][:artifact]=Rake::FileList.new("**/*.{gem,lib,exe,h,hpp}") + + + self[:commands]=Commands.new update end def add hash @@ -48,27 +56,27 @@ end end def update self[:dependencies]=Dependencies.new if !has_key?(:dependencies) - self[:artifacts]=Artifacts.new if !has_key?(:artifacts) - self[:artifacts].update allartifactsexist = true - self[:artifacts].each{|f| allartifactsexist=false if !File.exists?(f)} - self[:newest_artifact]=self[:artifacts].max_by { |f| File.mtime(f) } if allartifactsexist + self[:files][:artifact].each{|f| allartifactsexist=false if !File.exists?(f)} + self[:newest_source_file]=self[:files][:source].max_by {|f| File.mtime(f)} + self[:newest_artifact_file]=self[:files][:artifact].max_by { |f| File.mtime(f) } if allartifactsexist + self[:commands]=Commands.new if !has_key?(:commands) - self[:commands].update + #self[:commands].update self[:up_to_date] = false if(allartifactsexist && !self[:newest_artifact].nil? && !self[:newest_src_file].nil? && File.exists?(self[:newest_artifact]) && File.exists?(self[:newest_src_file])) if(File.mtime(self[:newest_artifact]) > File.mtime(self[:newest_src_file])) self[:command_order]=['upgrade'] if(File.mtime(self[:newest_artifact]) > File.mtime(self[:newest_src_file])) self[:up_to_date]=true end - self[:newest_artifact_mtime]=File.mtime(self[:newest_artifact]).to_s - self[:newest_src_file_mtime]=File.mtime(self[:newest_src_file]).to_s + self[:newest_artifact_file_mtime]=File.mtime(self[:newest_artifact_file]).to_s + self[:newest_source_file_mtime]=File.mtime(self[:newest_source_file]).to_s end update_tasks end def execute cmd @@ -77,13 +85,15 @@ def execute_task task sym_task = task.to_sym timer=Timer.new Console.announce_task_start task + #self[:commands][sym_task].update if self[:commands][sym_task].respond_to? update if(!self[:commands].has_key?(sym_task)) puts "no commands discovered for task " + task else + self[:commands][sym_task].update self[:commands][sym_task].each {|c| self[:commands].execute_command(c) } end elapsed = timer.elapsed if elapsed > 30 elapsed_str="[" + "%.0f" %(elapsed) + "s]" @@ -99,14 +109,14 @@ end def update_tasks dev_task_defaults=Array.new self[:commands].each do |key,array| - if(array.length > 0) + #if(array.length > 0) define_task key dev_task_defaults << key - end + #end end end def setup_svn_export(uri,dir) @@ -126,9 +136,10 @@ end end end DEV_TASKS=DevTasks.new +DEV=DEV_TASKS desc 'executes tasks in order of command_order, if they are defined' task :dev_tasks_default do DEV_TASKS.update DEV_TASKS[:command_order].each{|c|