cul_scv_hydra 0.22.9.8 → 0.22.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cul_hydra/version.rb +1 -1
- data/lib/cul_hydra/version.rb~ +1 -1
- data/lib/tasks/cmodel.rake +115 -109
- data/lib/tasks/cul_hydra_dev.rake +55 -49
- data/lib/tasks/index.rake +72 -66
- data/lib/tasks/transform.rake +24 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9daaaef8f5ef79c01bca3a618c6c687047b46ca6
|
4
|
+
data.tar.gz: 62a0d6371903c02f98577e97e7ca55a5b39cc200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41d07d66b3ab7dd0ffa81f8efe01ae9192c1bec194c11983c95bf06944950011520b3460e8ddd203a23f24417578e52ed790b0bee94009a91a80fa0c2906cbd7
|
7
|
+
data.tar.gz: 1563a31a1a26de436a4bc9cff92d8e98cc1cafb36ab90a889ad73f7f2d774a2fd6b58a5277944e42abfd191d7d1488f55e475e5aaf497cc767ddb033fefda299
|
data/lib/cul_hydra/version.rb
CHANGED
data/lib/cul_hydra/version.rb~
CHANGED
data/lib/tasks/cmodel.rake
CHANGED
@@ -1,122 +1,128 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def pid_for_filename(fname)
|
13
|
-
fname.sub(/\.xml$/,'').sub(/_/,':')
|
14
|
-
end
|
15
|
-
|
16
|
-
def cmodel_fixture(name)
|
17
|
-
path = File.join(APP_ROOT, 'fixtures','cmodels',name)
|
18
|
-
File.open(path, 'rb')
|
19
|
-
end
|
20
|
-
|
21
|
-
def each_cmodel
|
22
|
-
path = File.join(APP_ROOT, 'fixtures','cmodels')
|
23
|
-
Dir.new(path).each do |fname|
|
24
|
-
if fname =~ /\.xml$/
|
25
|
-
yield pid_for_filename(fname)
|
26
|
-
end
|
1
|
+
# This first line is a temporary fix until we get rid of the dual cul_hydra/cul_scv_hydra nature of this gem.
|
2
|
+
# Without it, these rake tasks will run twice when invoked.
|
3
|
+
unless Rake::Task.task_defined?("cul_scv_hydra:cmodel:reload_all")
|
4
|
+
|
5
|
+
APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
|
6
|
+
require 'active-fedora'
|
7
|
+
|
8
|
+
def logger
|
9
|
+
@logger ||= Logger.new($stdout)
|
27
10
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@subs ||= begin
|
32
|
-
cfile = File.join(APP_ROOT,'config','subs.yml')
|
33
|
-
subs = {}
|
34
|
-
if File.exists? cfile
|
35
|
-
open(cfile) {|blob| subs = YAML::load(blob)[ENV['RAILS_ENV'] || 'test'] }
|
36
|
-
else
|
37
|
-
logger.warn("No subs.yml found; CModels will be loaded without inline substitutions")
|
38
|
-
end
|
39
|
-
subs
|
11
|
+
|
12
|
+
def filename_for_pid(pid)
|
13
|
+
pid.gsub(/\:/,'_') + '.xml'
|
40
14
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def do_subs(orig)
|
45
|
-
content = orig.clone
|
46
|
-
config_subs.each do |key, val|
|
47
|
-
content.gsub!(/\$#{key.to_s}\$/, val)
|
15
|
+
|
16
|
+
def pid_for_filename(fname)
|
17
|
+
fname.sub(/\.xml$/,'').sub(/_/,':')
|
48
18
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# no need to go through AF for this except laziness re: finding the YAML
|
54
|
-
@connection ||= (ActiveFedora::Base.fedora_connection[0] ||= ActiveFedora::RubydoraConnection.new(ActiveFedora.config.credentials)).connection
|
55
|
-
end
|
56
|
-
|
57
|
-
def content_for(pid)
|
58
|
-
fname = filename_for_pid(pid)
|
59
|
-
fcontent = cmodel_fixture(fname).read
|
60
|
-
fcontent = do_subs(fcontent)
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_content(content, pid)
|
64
|
-
begin
|
65
|
-
connection.ingest(:file=>StringIO.new(content), :pid=>pid)
|
66
|
-
rescue Exception => e
|
67
|
-
puts "possible problem with ingest of #{pid}: #{e.message}"
|
68
|
-
raise e
|
19
|
+
|
20
|
+
def cmodel_fixture(name)
|
21
|
+
path = File.join(APP_ROOT, 'fixtures','cmodels',name)
|
22
|
+
File.open(path, 'rb')
|
69
23
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
24
|
+
|
25
|
+
def each_cmodel
|
26
|
+
path = File.join(APP_ROOT, 'fixtures','cmodels')
|
27
|
+
Dir.new(path).each do |fname|
|
28
|
+
if fname =~ /\.xml$/
|
29
|
+
yield pid_for_filename(fname)
|
30
|
+
end
|
31
|
+
end
|
77
32
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
namespace :cmodel do
|
90
|
-
task :test do #=> :environment do
|
91
|
-
pid = ENV["PID"]
|
92
|
-
puts content_for(pid)
|
33
|
+
|
34
|
+
def config_subs
|
35
|
+
@subs ||= begin
|
36
|
+
cfile = File.join(APP_ROOT,'config','subs.yml')
|
37
|
+
subs = {}
|
38
|
+
if File.exists? cfile
|
39
|
+
open(cfile) {|blob| subs = YAML::load(blob)[ENV['RAILS_ENV'] || 'test'] }
|
40
|
+
else
|
41
|
+
logger.warn("No subs.yml found; CModels will be loaded without inline substitutions")
|
42
|
+
end
|
43
|
+
subs
|
93
44
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
45
|
+
@subs
|
46
|
+
end
|
47
|
+
|
48
|
+
def do_subs(orig)
|
49
|
+
content = orig.clone
|
50
|
+
config_subs.each do |key, val|
|
51
|
+
content.gsub!(/\$#{key.to_s}\$/, val)
|
98
52
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
53
|
+
content
|
54
|
+
end
|
55
|
+
|
56
|
+
def connection
|
57
|
+
# no need to go through AF for this except laziness re: finding the YAML
|
58
|
+
@connection ||= (ActiveFedora::Base.fedora_connection[0] ||= ActiveFedora::RubydoraConnection.new(ActiveFedora.config.credentials)).connection
|
59
|
+
end
|
60
|
+
|
61
|
+
def content_for(pid)
|
62
|
+
fname = filename_for_pid(pid)
|
63
|
+
fcontent = cmodel_fixture(fname).read
|
64
|
+
fcontent = do_subs(fcontent)
|
65
|
+
end
|
66
|
+
|
67
|
+
def load_content(content, pid)
|
68
|
+
begin
|
69
|
+
connection.ingest(:file=>StringIO.new(content), :pid=>pid)
|
70
|
+
rescue Exception => e
|
71
|
+
puts "possible problem with ingest of #{pid}: #{e.message}"
|
72
|
+
raise e
|
103
73
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
74
|
+
end
|
75
|
+
|
76
|
+
def purge(pid)
|
77
|
+
begin
|
78
|
+
connection.purge_object :pid=>pid
|
79
|
+
rescue Exception => e
|
80
|
+
puts "possible problem with purge of #{pid}: #{e.message}"
|
108
81
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def reload(pid)
|
86
|
+
fcontent = content_for(pid)
|
87
|
+
purge(pid)
|
88
|
+
load_content(fcontent, pid)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
namespace :cul_scv_hydra do
|
93
|
+
namespace :cmodel do
|
94
|
+
task :test do #=> :environment do
|
95
|
+
pid = ENV["PID"]
|
96
|
+
puts content_for(pid)
|
97
|
+
end
|
98
|
+
|
99
|
+
task :load do #=> :environment do
|
100
|
+
pid = ENV["PID"]
|
101
|
+
load_content(content_for(pid),pid)
|
102
|
+
end
|
103
|
+
|
104
|
+
task :purge do #=> :environment do
|
105
|
+
pid = ENV["PID"]
|
106
|
+
purge(pid)
|
107
|
+
end
|
108
|
+
|
109
|
+
task :reload do #=> :environment do
|
110
|
+
pid = ENV["PID"]
|
111
|
+
reload(pid)
|
112
|
+
end
|
113
|
+
|
114
|
+
task :reload_all do #=> :environment do
|
115
|
+
pattern = ENV["PATTERN"]
|
116
|
+
pattern = Regexp.compile(pattern) if pattern
|
117
|
+
reload("ldpd:nullbind")
|
118
|
+
each_cmodel do |pid|
|
119
|
+
unless (pattern and not pid =~ pattern)
|
120
|
+
puts "reloading #{pid}"
|
121
|
+
reload(pid)
|
122
|
+
end
|
118
123
|
end
|
119
124
|
end
|
120
125
|
end
|
121
126
|
end
|
122
|
-
|
127
|
+
|
128
|
+
end
|
@@ -1,54 +1,60 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
# This first line is a temporary fix until we get rid of the dual cul_hydra/cul_scv_hydra nature of this gem.
|
2
|
+
# Without it, these rake tasks will run twice when invoked.
|
3
|
+
unless Rake::Task.task_defined?("cul_scv_hydra:ci")
|
4
|
+
|
5
|
+
APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
|
6
|
+
|
7
|
+
require 'jettywrapper'
|
8
|
+
JETTY_ZIP_BASENAME = '7.x-stable'
|
9
|
+
Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
|
10
|
+
|
11
|
+
namespace :cul_hydra do
|
12
|
+
|
13
|
+
begin
|
14
|
+
# This code is in a begin/rescue block so that the Rakefile is usable
|
15
|
+
# in an environment where RSpec is unavailable (i.e. production).
|
16
|
+
|
17
|
+
require 'rspec/core/rake_task'
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new(:rspec) do |spec|
|
20
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
21
|
+
spec.pattern += FileList['spec/*_spec.rb']
|
22
|
+
spec.rspec_opts = ['--backtrace'] if ENV['CI']
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
26
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
27
|
+
spec.pattern += FileList['spec/*_spec.rb']
|
28
|
+
spec.rcov = true
|
29
|
+
end
|
30
|
+
|
31
|
+
rescue LoadError => e
|
32
|
+
puts "[Warning] Exception creating rspec rake tasks. This message can be ignored in environments that intentionally do not pull in the RSpec gem (i.e. production)."
|
33
|
+
puts e
|
19
34
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
35
|
+
|
36
|
+
desc "CI build"
|
37
|
+
task :ci do
|
38
|
+
ENV['environment'] = "test"
|
39
|
+
#Rake::Task["active_fedora:configure_jetty"].invoke
|
40
|
+
jetty_params = Jettywrapper.load_config
|
41
|
+
error = Jettywrapper.wrap(jetty_params) do
|
42
|
+
Rake::Task["cul_scv_hydra:cmodel:reload_all"].invoke
|
43
|
+
Rake::Task['cul_hydra:coverage'].invoke
|
44
|
+
end
|
45
|
+
raise "test failures: #{error}" if error
|
25
46
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#Rake::Task["active_fedora:configure_jetty"].invoke
|
36
|
-
jetty_params = Jettywrapper.load_config
|
37
|
-
error = Jettywrapper.wrap(jetty_params) do
|
38
|
-
Rake::Task["cul_scv_hydra:cmodel:reload_all"].invoke
|
39
|
-
Rake::Task['cul_hydra:coverage'].invoke
|
47
|
+
|
48
|
+
desc "Execute specs with coverage"
|
49
|
+
task :coverage do
|
50
|
+
# Put spec opts in a file named .rspec in root
|
51
|
+
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
52
|
+
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
|
53
|
+
|
54
|
+
# Rake::Task["active_fedora:fixtures"].invoke
|
55
|
+
Rake::Task["cul_hydra:rspec"].invoke
|
40
56
|
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
desc "Execute specs with coverage"
|
45
|
-
task :coverage do
|
46
|
-
# Put spec opts in a file named .rspec in root
|
47
|
-
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
48
|
-
ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
|
49
|
-
|
50
|
-
# Rake::Task["active_fedora:fixtures"].invoke
|
51
|
-
Rake::Task["cul_hydra:rspec"].invoke
|
57
|
+
|
52
58
|
end
|
53
59
|
|
54
|
-
end
|
60
|
+
end
|
data/lib/tasks/index.rake
CHANGED
@@ -1,73 +1,79 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
# This first line is a temporary fix until we get rid of the dual cul_hydra/cul_scv_hydra nature of this gem.
|
2
|
+
# Without it, these rake tasks will run twice when invoked.
|
3
|
+
unless Rake::Task.task_defined?("cul_scv_hydra:index:recursive")
|
4
|
+
|
5
|
+
namespace :cul_scv_hydra do
|
6
|
+
|
7
|
+
namespace :index do
|
8
|
+
|
9
|
+
task :recursive => :environment do
|
10
|
+
|
11
|
+
puts '---------------------------'
|
12
|
+
puts 'Fedora URL: ' + ActiveFedora.config.credentials[:url]
|
13
|
+
puts 'Solr URL: ' + ActiveFedora.solr_config[:url]
|
14
|
+
puts '---------------------------'
|
15
|
+
|
16
|
+
ENV["RAILS_ENV"] ||= Rails.env
|
17
|
+
|
18
|
+
if ENV['PIDS']
|
19
|
+
pids = ENV['PIDS'].split(',')
|
20
|
+
else
|
21
|
+
puts 'Please specify one or more comma-delimited pids to recurse over (e.g. PIDS=ldpd:123 or PIDS=ldpd:123,ldpd:456)'
|
22
|
+
next
|
23
|
+
end
|
24
|
+
|
25
|
+
if ENV['OMIT']
|
26
|
+
pids_to_omit = ENV['OMIT'].split(',').map{|pid|pid.strip}
|
27
|
+
else
|
28
|
+
pids_to_omit = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
skip_generic_resources = (ENV['skip_generic_resources'] == 'true')
|
32
|
+
|
33
|
+
begin
|
34
|
+
pids.each do |pid|
|
35
|
+
Cul::Hydra::Indexer.recursively_index_fedora_objects(pid, pids_to_omit, skip_generic_resources, true)
|
36
|
+
end
|
37
|
+
rescue => e
|
38
|
+
puts 'Error: ' + e.message
|
39
|
+
puts e.backtrace
|
40
|
+
next
|
41
|
+
end
|
42
|
+
|
25
43
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
44
|
+
|
45
|
+
task :by_project_pid => :environment do
|
46
|
+
|
47
|
+
puts '---------------------------'
|
48
|
+
puts 'Fedora URL: ' + ActiveFedora.config.credentials[:url]
|
49
|
+
puts 'Solr URL: ' + ActiveFedora.solr_config[:url]
|
50
|
+
puts '---------------------------'
|
51
|
+
|
52
|
+
if ENV['PID']
|
53
|
+
project_pid = ENV['PID']
|
54
|
+
else
|
55
|
+
puts 'Please specify a project PID (e.g. PID=cul:123)'
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
skip_generic_resources = (ENV['skip_generic_resources'] == 'true')
|
60
|
+
|
61
|
+
start_time = Time.now
|
62
|
+
pids = Cul::Scv::Hydra::RisearchMembers.get_project_constituent_pids(project_pid, true)
|
63
|
+
total = pids.length
|
64
|
+
puts "Found #{total} project members."
|
65
|
+
counter = 0
|
66
|
+
|
30
67
|
pids.each do |pid|
|
31
|
-
Cul::Hydra::Indexer.
|
68
|
+
Cul::Hydra::Indexer.index_pid(pid, skip_generic_resources, false)
|
69
|
+
counter += 1
|
70
|
+
puts "Indexed #{counter} of #{total} | #{Time.now - start_time} seconds"
|
32
71
|
end
|
33
|
-
|
34
|
-
puts 'Error: ' + e.message
|
35
|
-
puts e.backtrace
|
36
|
-
next
|
72
|
+
|
37
73
|
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
task :by_project_pid => :environment do
|
42
|
-
|
43
|
-
puts '---------------------------'
|
44
|
-
puts 'Fedora URL: ' + ActiveFedora.config.credentials[:url]
|
45
|
-
puts 'Solr URL: ' + ActiveFedora.solr_config[:url]
|
46
|
-
puts '---------------------------'
|
47
|
-
|
48
|
-
if ENV['PID']
|
49
|
-
project_pid = ENV['PID']
|
50
|
-
else
|
51
|
-
puts 'Please specify a project PID (e.g. PID=cul:123)'
|
52
|
-
next
|
53
|
-
end
|
54
|
-
|
55
|
-
skip_generic_resources = (ENV['skip_generic_resources'] == 'true')
|
56
|
-
|
57
|
-
start_time = Time.now
|
58
|
-
pids = Cul::Scv::Hydra::RisearchMembers.get_project_constituent_pids(project_pid, true)
|
59
|
-
total = pids.length
|
60
|
-
puts "Found #{total} project members."
|
61
|
-
counter = 0
|
62
|
-
|
63
|
-
pids.each do |pid|
|
64
|
-
Cul::Hydra::Indexer.index_pid(pid, skip_generic_resources, false)
|
65
|
-
counter += 1
|
66
|
-
puts "Indexed #{counter} of #{total} | #{Time.now - start_time} seconds"
|
67
|
-
end
|
68
|
-
|
74
|
+
|
69
75
|
end
|
70
|
-
|
76
|
+
|
71
77
|
end
|
72
78
|
|
73
|
-
end
|
79
|
+
end
|
data/lib/tasks/transform.rake
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
-
|
1
|
+
# This first line is a temporary fix until we get rid of the dual cul_hydra/cul_scv_hydra nature of this gem.
|
2
|
+
# Without it, these rake tasks will run twice when invoked.
|
3
|
+
unless Rake::Task.task_defined?("cul_scv_hydra:transform:marc")
|
2
4
|
|
3
|
-
namespace :
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
namespace :cul_scv_hydra do
|
6
|
+
|
7
|
+
namespace :transform do
|
8
|
+
|
9
|
+
task :marc => :environment do
|
10
|
+
|
11
|
+
begin
|
12
|
+
src_path = File.join(Rails.root,'fixtures','spec','MARCXML','3867996.xml')
|
13
|
+
xsl_path = File.join(Rails.root,'config','xsl','marc_to_mods.xsl')
|
14
|
+
doc = Nokogiri::XML(File.read(src_path))
|
15
|
+
xslt = Nokogiri::XSLT(File.read(xsl_path))
|
16
|
+
puts xslt.transform(doc)
|
17
|
+
rescue => e
|
18
|
+
puts 'Error: ' + e.message
|
19
|
+
puts e.backtrace
|
20
|
+
next
|
21
|
+
end
|
22
|
+
|
17
23
|
end
|
18
|
-
|
24
|
+
|
19
25
|
end
|
20
|
-
|
26
|
+
|
21
27
|
end
|
22
28
|
|
23
|
-
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_scv_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.9.
|
4
|
+
version: 0.22.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Armintor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blacklight
|