-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
79 lines (63 loc) · 2.46 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require 'rubygems'
require 'rake'
require 'bundler'
require 'retries'
Dir.glob('lib/tasks/*.rake').each { |r| import r }
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
desc 'Get application version'
task :app_version do
puts File.read(File.expand_path('../VERSION', __FILE__)).match('[\w\.]+')[0]
end
require 'rspec/core/rake_task'
desc "Run specs"
RSpec::Core::RakeTask.new(:spec)
task default: [:rubocop, :spec]
require 'rubocop/rake_task'
RuboCop::RakeTask.new
if ['test', 'development'].include? ENV['ROBOT_ENVIRONMENT']
require 'jettywrapper'
Jettywrapper.hydra_jetty_version = 'v7.3.0' # this keeps us on fedora 3, hydra-jetty v8.x moves to fedora 4.
def load_order_files(fedora_files)
data_path = File.expand_path('../fedora_conf/data/', __FILE__)
fedora_files.delete_if {|f| f.strip.empty? }
fedora_files.map {|f| File.join(data_path, f.strip) }
end
namespace :repo do
desc "Load XML file(s) into repo (fedora and solr), default: contents of 'load_order' file. With a glob: rake repo:load[fedora_conf/data/*.xml]"
task :load, [:glob] do |task, args|
require 'active_fedora'
puts "travis_fold:start:repo-load\r" if ENV['TRAVIS'] == 'true'
file_list = []
if args.key?(:glob)
file_list = Dir.glob(args[:glob])
else
puts 'No file glob was specified so file order and inclusion is determined by the load_order file'
fedora_files = File.foreach(File.join(File.expand_path('../fedora_conf/data/', __FILE__), 'load_order')).to_a
file_list = load_order_files(fedora_files)
end
errors = []
i = 0
file_list.each do |file|
i += 1
handler = proc do |e, attempt_number, total_delay|
puts STDERR.puts "ERROR loading #{file}:\n#{e.message}\n#{e.backtrace.join "\n"}"
errors << file
end
with_retries(:max_tries => 3, :handler => handler, :rescue => [StandardError]) { |attempt|
puts "** File #{i}, Try #{attempt} ** repo:load foxml=#{file}"
pid = ActiveFedora::FixtureLoader.import_to_fedora(file)
ActiveFedora::FixtureLoader.index(pid)
}
end
puts 'Done loading repo files'
puts "ERROR in #{errors.size()} of #{i} files" if errors.size() > 0
puts "travis_fold:end:repo-load\r" if ENV['TRAVIS'] == 'true'
end
end # :repo
end