Rakefile in fanforce-plugin-factory-0.41.0 vs Rakefile in fanforce-plugin-factory-1.6.0.rc1
- old
+ new
@@ -1,16 +1,73 @@
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'fileutils'
include FileUtils
-# Default Rake task is compile
-#task :default => :compile
+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/plugin_factory/cli'
+ require 'fanforce/plugin_factory/cli/lib/scaffolding_file'
+
+ task :register do
+ scaffolding_dir = File.expand_path('../lib/fanforce/plugin_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::PluginFactory::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-plugin-factory-#{Fanforce::PluginFactory::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.libs.push 'lib'
+ t.libs.push 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end