Skip to content

Commit

Permalink
Merge eaa617b into c78393b
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravShah authored Aug 29, 2018
2 parents c78393b + eaa617b commit fcef116
Show file tree
Hide file tree
Showing 51 changed files with 278 additions and 798 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ tags
tmp
/workflow_service.log*
coverage
spec/lib/test_data/logging/progress_log_file.yml

# Ignore master key for decrypting credentials and more.
/config/master.key

config/settings.local.yml
config/settings/*.local.yml
config/environments/*.local.yml
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--color
--require spec_helper
--require rails_helper
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ gem 'turbolinks'
gem 'resque', '~> 1.27'
gem 'resque-lock'
gem 'resque-pool'
gem 'config'

group :test do
gem 'rspec', '~> 3.0'
gem 'yard'
gem 'solr_wrapper'
gem 'jettywrapper'
Expand Down
38 changes: 33 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ GEM
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
concurrent-ruby (1.0.5)
config (1.7.0)
activesupport (>= 3.0)
deep_merge (~> 1.2.1)
dry-validation (>= 0.10.4)
confstruct (0.2.7)
connection_pool (2.2.2)
coveralls (0.8.22)
Expand All @@ -109,6 +113,7 @@ GEM
csv-mapper (0.5.1)
fastercsv
daemons (1.2.6)
deep_merge (1.2.1)
deprecation (0.99.0)
activesupport
diff-lcs (1.3)
Expand Down Expand Up @@ -155,6 +160,33 @@ GEM
nokogiri (~> 1.6)
retries
druid-tools (1.0.0)
dry-configurable (0.7.0)
concurrent-ruby (~> 1.0)
dry-container (0.6.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.7)
concurrent-ruby (~> 1.0)
dry-equalizer (0.2.1)
dry-inflector (0.1.2)
dry-logic (0.4.2)
dry-container (~> 0.2, >= 0.2.6)
dry-core (~> 0.2)
dry-equalizer (~> 0.2)
dry-types (0.13.2)
concurrent-ruby (~> 1.0)
dry-container (~> 0.3)
dry-core (~> 0.4, >= 0.4.4)
dry-equalizer (~> 0.2)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 0.4, >= 0.4.2)
dry-validation (0.12.1)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (~> 0.2, >= 0.2.1)
dry-equalizer (~> 0.2)
dry-logic (~> 0.4, >= 0.4.0)
dry-types (~> 0.13.1)
edtf (3.0.4)
activesupport (>= 3.0, < 6.0)
equivalent-xml (0.6.0)
Expand Down Expand Up @@ -336,10 +368,6 @@ GEM
rsolr (2.2.1)
builder (>= 2.1.2)
faraday (>= 0.9.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
Expand Down Expand Up @@ -459,6 +487,7 @@ DEPENDENCIES
capistrano (~> 3)
capistrano-bundler
capistrano-rvm
config
coveralls
csv-mapper
dlss-capistrano (~> 3.1)
Expand All @@ -480,7 +509,6 @@ DEPENDENCIES
rest-client
retries
roo
rspec (~> 3.0)
rspec-rails (~> 3.7)
rubocop (~> 0.58)
rubocop-rspec
Expand Down
68 changes: 3 additions & 65 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,68 +1,6 @@
require_relative 'config/application'
require 'rspec/core/rake_task'
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

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
require_relative 'config/application'

Rails.application.load_tasks

Dir.glob('lib/tasks/*.rake').each { |r| import r }

desc "Run specs"
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

if ['test', 'development'].include? ENV['RAILS_ENV']
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
5 changes: 5 additions & 0 deletions app/lib/pre_assembly.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'fileutils'
require 'erb'
require 'assembly-image'
require 'rest_client'
require 'honeybadger'
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,22 @@ def stager(source, destination)

# set this object's content_md_creation_style
def content_md_creation_style
# map the content type tags set inside an object to content metadata creation styles supported by the assembly-objectfile gem
# format is 'tag_value' => 'gem style name'
content_type_tag_mapping = {
'Image' => :simple_image,
'File' => :file,
'Book (flipbook, ltr)' => :simple_book,
'Book (image-only)' => :book_as_image,
'Manuscript (flipbook, ltr)' => :simple_book,
'Manuscript (image-only)' => :book_as_image,
'Map' => :map
}
# if this object needs to be registered or has no content type tag for a registered object, use the default set in the YAML file
if !project_style[:content_tag_override] || content_type_tag.blank?
default_content_md_creation_style
else # if the object is already registered and there is a content type tag and we allow overrides, use it if we know what it means (else use the default)
CONTENT_TYPE_TAG_MAPPING[content_type_tag] || default_content_md_creation_style
content_type_tag_mapping[content_type_tag] || default_content_md_creation_style
end
end

Expand Down Expand Up @@ -196,12 +207,14 @@ def prepare_for_reaccession
# Create the druid tree within the staging directory,
# and then copy-recursive all stageable items to that area.
def stage_files
# these are the names of special datastream files that will be staged in the 'metadata' folder instead of the 'content' folder
metadata_files = ['descMetadata.xml', 'contentMetadata.xml'].map(&:downcase)
log " - staging(druid_tree_dir = #{druid_tree_dir.inspect})"
create_object_directories
stageable_items.each do |si_path|
log " - staging(#{si_path}, #{content_dir})", :debug
# determine destination of staged file by looking to see if it is a known datastream XML file or not
destination = METADATA_FILES.include?(File.basename(si_path).downcase) ? metadata_dir : content_dir
destination = metadata_files.include?(File.basename(si_path).downcase) ? metadata_dir : content_dir
stager si_path, destination
end
end
Expand Down
File renamed without changes.
14 changes: 6 additions & 8 deletions lib/pre_assembly/logging.rb → app/lib/pre_assembly/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ module Logging
LOG_FORMAT = "%-6s -- %s -- %s\n"
TIME_FORMAT = "%Y-%m-%d %H:%M:%S"

def self.setup(project_root, environment)
log_file = File.join(project_root, 'log', "#{environment}.log")
@@log ||= Logger.new(log_file)
@@log.level = LEVELS[:info]

@@log.formatter = proc do |severity, datetime, _progname, msg|
LOG_FORMAT % [severity, datetime.strftime(TIME_FORMAT), msg]
end

@@log ||= Logger.new(File.join(Rails.root, 'log', "#{Rails.env}.log"))
@@log.level = LEVELS[:info]

@@log.formatter = proc do |severity, datetime, _progname, msg|
LOG_FORMAT % [severity, datetime.strftime(TIME_FORMAT), msg]
end

def log(msg, severity = :info)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 0 additions & 42 deletions bin/batch_run

This file was deleted.

23 changes: 0 additions & 23 deletions bin/cleanup

This file was deleted.

41 changes: 0 additions & 41 deletions bin/completion_report

This file was deleted.

Loading

0 comments on commit fcef116

Please sign in to comment.