From f35b1b3bce2b2af1972698a71821c397a515e509 Mon Sep 17 00:00:00 2001 From: John Scofield Date: Mon, 2 May 2011 21:13:38 -0400 Subject: [PATCH] Adding rake tasks: hudson, active_fedora, etc. Adds following rake tasks: rake hudson rake active_fedora:doc rake active_fedora:rspec rake active_fedora:configure_jetty --- Rakefile | 9 +++- spec/rcov.opts | 2 + tasks/active_fedora.rake | 93 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 spec/rcov.opts create mode 100644 tasks/active_fedora.rake diff --git a/Rakefile b/Rakefile index 7aa267536..56c6c9dc8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ require 'rake/clean' require 'rubygems' load 'tasks/rspec.rake' +load 'tasks/active_fedora.rake' + $: << 'lib' @@ -25,7 +27,12 @@ begin gem.add_dependency("mediashelf-loggable") gem.add_dependency("equivalent-xml") gem.add_dependency("facets") - + gem.add_development_dependency("yard") + gem.add_development_dependency("RedCloth") + gem.add_development_dependency("rcov") + gem.add_development_dependency("solrizer") + gem.add_development_dependency("solrizer-fedora") + gem.add_development_dependency("jettywrapper") # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::GemcutterTasks.new diff --git a/spec/rcov.opts b/spec/rcov.opts new file mode 100644 index 000000000..c293e9077 --- /dev/null +++ b/spec/rcov.opts @@ -0,0 +1,2 @@ +--exclude "spec/*,gems/*" +--rails diff --git a/tasks/active_fedora.rake b/tasks/active_fedora.rake new file mode 100644 index 000000000..031988cf5 --- /dev/null +++ b/tasks/active_fedora.rake @@ -0,0 +1,93 @@ +$: << 'lib' + +JETTY_PARAMS = { + :quiet => true, + :jetty_home => File.join(File.dirname(__FILE__),'..','jetty'), + :jetty_port => 8983, + :solr_home => File.expand_path(File.join(File.dirname(__FILE__),'..','jetty','solr')), + :fedora_home => File.expand_path(File.join(File.dirname(__FILE__),'..','jetty','fedora','default')), + :startup_wait=>30 +} + + + desc "Hudson build" + task :hudson do + require 'jettywrapper' + Rake::Task["active_fedora:doc"].invoke + Rake::Task["active_fedora:configure_jetty"].invoke + error = Jettywrapper.wrap(JETTY_PARAMS) do + Rake::Task["active_fedora:load_fixtures"].invoke + Rake::Task["active_fedora:rspec"].invoke + end + raise "test failures: #{error}" if error + end + + +namespace :active_fedora do + require 'lib/active-fedora' + + # Use yard to build docs + begin + require 'yard' + require 'yard/rake/yardoc_task' + project_root = File.expand_path("#{File.dirname(__FILE__)}/../") + doc_destination = File.join(project_root, 'doc') + + YARD::Rake::YardocTask.new(:doc) do |yt| + yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + + [ File.join(project_root, 'README.textile') ] + yt.options = ['--output-dir', doc_destination, '--readme', 'README.textile'] + end + rescue LoadError + desc "Generate YARD Documentation" + task :doc do + abort "Please install the YARD gem to generate rdoc." + end + end + + + Spec::Rake::SpecTask.new(:rspec) do |t| + t.spec_files = FileList['spec/**/*_spec.rb'] + t.rcov = true + t.rcov_opts << "--exclude \"spec/* gems/*\" --rails" + end + + task :refresh_fixtures do + Rake::Task["active_fedora:clean_jetty"].invoke + Rake::Task["active_fedora:load_fixtures"].invoke + end + + task :clean_jetty do + Dir.chdir("./jetty") + system("git clean -f -d") + system("git checkout .") + Dir.chdir("..") + end + + task :load_fixtures do + require 'solrizer' + require 'solrizer-fedora' + ENV["FEDORA_HOME"]=File.expand_path(File.join(File.dirname(__FILE__),'..','jetty','fedora','default')) + retval = `$FEDORA_HOME/client/bin/fedora-ingest-demos.sh localhost 8983 fedoraAdmin fedoraAdmin http` + puts "loaded demo objects #{retval}" + fixture = File.open(File.expand_path(File.join("spec","fixtures","hydrangea_fixture_mods_article1.foxml.xml")),"r") + ActiveFedora.init unless Thread.current[:repo] + result = foxml = Fedora::Repository.instance.ingest(fixture.read) + if result + solrizer = Solrizer::Fedora::Solrizer.new + solrizer.solrize "hydrangea:fixture_mods_article1" + end + #retval = `$FEDORA_HOME/client/bin/fedora-ingest.sh f #{fixture} info:fedora/fedora-system:FOXML-1.1 localhost:8983 fedoraAdmin fedoraAdmin http` + puts "Loaded #{fixture}: #{retval}" + end + + desc "Copies the default SOLR config for the bundled Testing Server" + task :configure_jetty do + Rake::Task["active_fedora:clean_jetty"].invoke + FileList['solr/conf/*'].each do |f| + cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true) + cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true) + end + end + +end