require 'bundler/gem_tasks' require 'rake/testtask' require 'fileutils' include FileUtils task :pre_build do Rake::Task['test'].execute puts '---------------------------------------------------------------------' puts 'TESTS PASSED!' puts '---------------------------------------------------------------------' puts 'UPDATING SCAFFOLDING DIGESTS...' Rake::Task['scaffolding:register'].execute puts 'READY TO BUILD!' puts '---------------------------------------------------------------------' end namespace :scaffolding do require 'digest' class Fanforce::CLI DIR = '' TYPE = '' end require 'fanforce/app_factory/cli' require 'fanforce/app_factory/cli/scaffolding_file' task :register do scaffolding_dir = File.expand_path('../lib/fanforce/app_factory/scaffolding', __FILE__) Dir.glob("#{scaffolding_dir}/**/*", File::FNM_DOTMATCH).each do |scaffold_filepath| next if scaffold_filepath =~ /\.registry/ or File.directory?(scaffold_filepath) file_parts = scaffold_filepath.split('/') registry_filepath = "#{file_parts[0...-1].join('/')}/._#{file_parts[-1]}.registry" file = Fanforce::AppFactory::CLI::ScaffoldingFile.new(scaffold_filepath) if [:file,:image,:partial].include?(file.scaffold_type) next if file.digest_exists_in_registry?(file.scaffold_digest) File.open(registry_filepath, 'a') {|f| f.puts "fanforce-app-factory-#{Fanforce::AppFactory::VERSION}:#{file.scaffold_digest}" } elsif [:items].include?(file.scaffold_type) scaffold_contents = File.open(file.scaffold_filepath).read raise "item changes are not registered for #{file.scaffold_filepath}" if !file.list_matches_latest_registry?(scaffold_contents) next elsif [:json].include?(file.scaffold_type) scaffold_contents = File.open(file.scaffold_filepath).read raise "json changes are not registered for #{file.scaffold_filepath}" if !file.json_matches_latest_registry?(scaffold_contents) next elsif [:skipped].include?(file.scaffold_type) next else raise "unknown scaffold type: #{file.scaffold_type}" end puts "- REGISTERED #{scaffold_filepath.gsub(scaffolding_dir, '')} (#{file.scaffold_type})" end end end task :build => :pre_build task :default => :build ######################################################################## Rake::TestTask.new do |t| t.libs.push 'lib' t.libs.push 'test' t.pattern = 'test/**/*_test.rb' t.verbose = false end