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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67ba675dbcd11ee3e44b2360d35ca40fbe1dba08
4
- data.tar.gz: efec088da67ba317a7b1f93d3e3065ab42e1c9f8
3
+ metadata.gz: 9daaaef8f5ef79c01bca3a618c6c687047b46ca6
4
+ data.tar.gz: 62a0d6371903c02f98577e97e7ca55a5b39cc200
5
5
  SHA512:
6
- metadata.gz: 7188765143462d4f6cdc93424982e95518903604680e0e06b6c62a6dd6ba08724a3a9e2aa514fd2431f7e691fd33813d229caa8544879166f10717dc647df2ec
7
- data.tar.gz: 72fee1cbab65259f6c7f895ac180c65de15d7f0995d8f9dc46b690701ccc61a2ea2912468f96cfae5b1c8a7624cc1fdb4e6d8c58a67e16c0cbc11070fbf26bd1
6
+ metadata.gz: 41d07d66b3ab7dd0ffa81f8efe01ae9192c1bec194c11983c95bf06944950011520b3460e8ddd203a23f24417578e52ed790b0bee94009a91a80fa0c2906cbd7
7
+ data.tar.gz: 1563a31a1a26de436a4bc9cff92d8e98cc1cafb36ab90a889ad73f7f2d774a2fd6b58a5277944e42abfd191d7d1488f55e475e5aaf497cc767ddb033fefda299
@@ -1,6 +1,6 @@
1
1
  module Cul
2
2
  module Hydra
3
- VERSION = '0.22.9.8'
3
+ VERSION = '0.22.9.9'
4
4
  def self.version
5
5
  VERSION
6
6
  end
@@ -1,6 +1,6 @@
1
1
  module Cul
2
2
  module Hydra
3
- VERSION = '0.22.9.7'
3
+ VERSION = '0.22.9.8'
4
4
  def self.version
5
5
  VERSION
6
6
  end
@@ -1,122 +1,128 @@
1
- APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
2
- require 'active-fedora'
3
-
4
- def logger
5
- @logger ||= Logger.new($stdout)
6
- end
7
-
8
- def filename_for_pid(pid)
9
- pid.gsub(/\:/,'_') + '.xml'
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
- end
29
-
30
- def config_subs
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
- @subs
42
- end
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
- content
50
- end
51
-
52
- def connection
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
- end
71
-
72
- def purge(pid)
73
- begin
74
- connection.purge_object :pid=>pid
75
- rescue Exception => e
76
- puts "possible problem with purge of #{pid}: #{e.message}"
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
- end
80
-
81
- def reload(pid)
82
- fcontent = content_for(pid)
83
- purge(pid)
84
- load_content(fcontent, pid)
85
- end
86
-
87
-
88
- namespace :cul_scv_hydra do
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
- task :load do #=> :environment do
96
- pid = ENV["PID"]
97
- load_content(content_for(pid),pid)
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
- task :purge do #=> :environment do
101
- pid = ENV["PID"]
102
- purge(pid)
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
- task :reload do #=> :environment do
106
- pid = ENV["PID"]
107
- reload(pid)
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
- task :reload_all do #=> :environment do
111
- pattern = ENV["PATTERN"]
112
- pattern = Regexp.compile(pattern) if pattern
113
- reload("ldpd:nullbind")
114
- each_cmodel do |pid|
115
- unless (pattern and not pid =~ pattern)
116
- puts "reloading #{pid}"
117
- reload(pid)
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
- end
127
+
128
+ end
@@ -1,54 +1,60 @@
1
- APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../") unless defined?(APP_ROOT)
2
-
3
- require 'jettywrapper'
4
- JETTY_ZIP_BASENAME = '7.x-stable'
5
- Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
6
-
7
- namespace :cul_hydra do
8
-
9
- begin
10
- # This code is in a begin/rescue block so that the Rakefile is usable
11
- # in an environment where RSpec is unavailable (i.e. production).
12
-
13
- require 'rspec/core/rake_task'
14
-
15
- RSpec::Core::RakeTask.new(:rspec) do |spec|
16
- spec.pattern = FileList['spec/**/*_spec.rb']
17
- spec.pattern += FileList['spec/*_spec.rb']
18
- spec.rspec_opts = ['--backtrace'] if ENV['CI']
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
- RSpec::Core::RakeTask.new(:rcov) do |spec|
22
- spec.pattern = FileList['spec/**/*_spec.rb']
23
- spec.pattern += FileList['spec/*_spec.rb']
24
- spec.rcov = true
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
- rescue LoadError => e
28
- 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)."
29
- puts e
30
- end
31
-
32
- desc "CI build"
33
- task :ci do
34
- ENV['environment'] = "test"
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
- raise "test failures: #{error}" if error
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
- namespace :cul_scv_hydra do
2
-
3
- namespace :index do
4
-
5
- task :recursive => :environment do
6
-
7
- puts '---------------------------'
8
- puts 'Fedora URL: ' + ActiveFedora.config.credentials[:url]
9
- puts 'Solr URL: ' + ActiveFedora.solr_config[:url]
10
- puts '---------------------------'
11
-
12
- ENV["RAILS_ENV"] ||= Rails.env
13
-
14
- if ENV['PIDS']
15
- pids = ENV['PIDS'].split(',')
16
- else
17
- puts 'Please specify one or more comma-delimited pids to recurse over (e.g. PIDS=ldpd:123 or PIDS=ldpd:123,ldpd:456)'
18
- next
19
- end
20
-
21
- if ENV['OMIT']
22
- pids_to_omit = ENV['OMIT'].split(',').map{|pid|pid.strip}
23
- else
24
- pids_to_omit = nil
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
- skip_generic_resources = (ENV['skip_generic_resources'] == 'true')
28
-
29
- begin
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.recursively_index_fedora_objects(pid, pids_to_omit, skip_generic_resources, true)
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
- rescue => e
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
@@ -1,23 +1,29 @@
1
- namespace :cul_scv_hydra do
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 :transform do
4
-
5
- task :marc => :environment do
6
-
7
- begin
8
- src_path = File.join(Rails.root,'fixtures','spec','MARCXML','3867996.xml')
9
- xsl_path = File.join(Rails.root,'config','xsl','marc_to_mods.xsl')
10
- doc = Nokogiri::XML(File.read(src_path))
11
- xslt = Nokogiri::XSLT(File.read(xsl_path))
12
- puts xslt.transform(doc)
13
- rescue => e
14
- puts 'Error: ' + e.message
15
- puts e.backtrace
16
- next
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.8
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-10 00:00:00.000000000 Z
12
+ date: 2015-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blacklight