Skip to content

Commit

Permalink
Merge pull request #248 from samvera/upgrade-ruby3.0
Browse files Browse the repository at this point in the history
Introduces upgrades which ensures that Ruby 3.0.z releases are supported
  • Loading branch information
cjcolvar authored Feb 1, 2023
2 parents a9785b0 + 87f9571 commit 612ebf7
Show file tree
Hide file tree
Showing 64 changed files with 142 additions and 46 deletions.
24 changes: 18 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ jobs:
workflows:
ci:
jobs:
- bundle_lint_test:
name: ruby3-2
ruby_version: 3.2.0
- bundle_lint_test:
name: ruby3-1
ruby_version: 3.1.3
- bundle_lint_test:
name: ruby3-0
ruby_version: 3.0.3
- bundle_lint_test:
name: ruby2-7
ruby_version: 2.7.5
- bundle_lint_test:
name: ruby2-6
ruby_version: 2.6.9
- bundle_lint_test:
name: ruby2-5
ruby_version: 2.5.9

nightly:
triggers:
Expand All @@ -93,12 +99,18 @@ workflows:
only:
- main
jobs:
- bundle_lint_test:
name: ruby3-2
ruby_version: 3.2.0
- bundle_lint_test:
name: ruby3-1
ruby_version: 3.1.3
- bundle_lint_test:
name: ruby3-0
ruby_version: 3.0.3
- bundle_lint_test:
name: ruby2-7
ruby_version: 2.7.5
- bundle_lint_test:
name: ruby2-6
ruby_version: 2.6.9
- bundle_lint_test:
name: ruby2-5
ruby_version: 2.5.9
27 changes: 27 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: hydra_derivatives
services:
fcrepo4:
type: compose
app_mount: false
portforward: true
volumes:
fcrepo4:
services:
image: samvera/fcrepo4:4.7.5
command: /fedora-entrypoint.sh
volumes:
- fcrepo4:/data
ports:
- 8986:8080
solr:
type: solr:7
app_mount: false
portforward: 8985
core: hydra-test
config:
dir: solr/config
proxy:
fcrepo4:
- hydra-derivatives.fcrepo4.lndo.site:8986
solr:
- hydra-derivatives.solr.lndo.site:8985
5 changes: 3 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require: rubocop-rspec
inherit_gem:
bixby: bixby_default.yml
inherit_from: .rubocop_todo.yml

AllCops:
Expand All @@ -12,7 +13,7 @@ AllCops:
- Rakefile

Layout/IndentationConsistency:
EnforcedStyle: rails
EnforcedStyle: indented_internal_methods

Metrics/AbcSize:
Max: 42
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ gemspec
gem 'sprockets', '~> 3.7'

group :development, :test do
gem 'bixby'
gem 'coveralls'
gem 'rspec_junit_formatter'
gem 'rubocop', '~> 0.52.0', require: false
gem 'rubocop-rspec', require: false
gem 'simplecov'
end
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

require "bundler/gem_tasks"

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

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

Expand Down
15 changes: 7 additions & 8 deletions hydra-derivatives.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
spec.add_development_dependency 'pry-byebug'
spec.add_development_dependency 'rails', '> 5.1', '< 7.0'
spec.add_development_dependency 'rake', '~> 10.1'
spec.add_development_dependency 'rails', '> 5.1', '< 7.1'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 3.1'
spec.add_development_dependency "solr_wrapper", "~> 2.0"
spec.add_development_dependency "solr_wrapper"

spec.add_dependency 'active-fedora', '>= 11.5.6',
'!= 12.0.0', '!= 12.0.1', '!= 12.0.2', '!= 12.0.3', '!= 12.1.0', '!= 12.1.1', '!= 12.2.0', '!= 12.2.1',
'!= 13.0.0', '!= 13.1.0', '!= 13.1.1', '!= 13.1.2', '!= 13.1.3', '!= 13.2.0', '!= 13.2.1'
spec.add_dependency 'active_encode', '~>0.1'
spec.add_dependency 'activesupport', '>= 4.0', '< 7'
spec.add_dependency 'active_encode', '~> 0.1'
spec.add_dependency 'active-fedora', '>= 14.0'
spec.add_dependency 'active-triples', '>= 1.2'
spec.add_dependency 'activesupport', '>= 4.0', '< 7.1'
spec.add_dependency 'addressable', '~> 2.5'
spec.add_dependency 'deprecation'
spec.add_dependency 'mime-types', '> 2.0', '< 4.0'
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'active_fedora'
require 'deprecation'

Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/audio_encoder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'open3'

module Hydra::Derivatives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'tmpdir'

module Hydra
Expand Down
3 changes: 2 additions & 1 deletion lib/hydra/derivatives/io_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Naive implementation of IO wrapper class that adds mime_type and original_filename
# attributes. This is done to match the interface of ActionDispatch::HTTP::UploadedFile
# so the attributes do not have to be passed as additional arguments, and are attached
Expand All @@ -16,7 +17,7 @@ class IoDecorator < SimpleDelegator
alias original_name original_filename
deprecation_deprecate original_name: 'original_name has been deprecated. Use original_filename instead. This will be removed in hydra-derivatives 4.0'
alias original_name= original_filename=
deprecation_deprecate :"original_name=" => 'original_name= has been deprecated. Use original_filename= instead. This will be removed in hydra-derivatives 4.0'
deprecation_deprecate "original_name=": 'original_name= has been deprecated. Use original_filename= instead. This will be removed in hydra-derivatives 4.0'

def initialize(file, mime_type = nil, original_filename = nil)
super(file)
Expand Down
7 changes: 4 additions & 3 deletions lib/hydra/derivatives/logger.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class Logger
class << self
Expand All @@ -17,9 +18,9 @@ def respond_to_missing?(method_name, include_private = false)

private

def logger
ActiveFedora::Base.logger || ::Logger.new(STDOUT)
end
def logger
ActiveFedora::Base.logger || ::Logger.new(STDOUT)
end
end
end
end
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
module Processors
extend ActiveSupport::Autoload
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/active_encode.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'active_encode'

module Hydra::Derivatives::Processors
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/audio.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives::Processors
class Audio < Processor
include Ffmpeg
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/ffmpeg.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# An abstract class for asyncronous jobs that transcode files using FFMpeg
module Hydra::Derivatives::Processors
module Ffmpeg
Expand Down
3 changes: 2 additions & 1 deletion lib/hydra/derivatives/processors/image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'mini_magick'

module Hydra::Derivatives::Processors
Expand Down Expand Up @@ -61,7 +62,7 @@ def quality
end

def selected_layers(image)
if image.type =~ /pdf/i
if /pdf/i.match?(image.type)
image.layers[directives.fetch(:layer, 0)]
elsif directives.fetch(:layer, false)
image.layers[directives.fetch(:layer)]
Expand Down
5 changes: 2 additions & 3 deletions lib/hydra/derivatives/processors/jpeg2k_image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'mini_magick'
require 'nokogiri'

Expand Down Expand Up @@ -90,9 +91,7 @@ def process
long_dim = self.class.long_dim(image)
file_path = self.class.tmp_file('.tif')
to_srgb = directives.fetch(:to_srgb, true)
if directives[:resize] || to_srgb
preprocess(image, resize: directives[:resize], to_srgb: to_srgb, src_quality: quality)
end
preprocess(image, resize: directives[:resize], to_srgb: to_srgb, src_quality: quality) if directives[:resize] || to_srgb
image.write file_path
recipe = self.class.kdu_compress_recipe(directives, quality, long_dim)
encode_file(recipe, file_path: file_path)
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/processor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives::Processors
# Processors take a single input and produce a single output
class Processor
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/raw_image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'mini_magick'

module Hydra::Derivatives::Processors
Expand Down
9 changes: 6 additions & 3 deletions lib/hydra/derivatives/processors/shell_based_processor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# An abstract class for asyncronous jobs that transcode files using FFMpeg

require 'tmpdir'
Expand Down Expand Up @@ -59,7 +60,7 @@ def execute_with_timeout(timeout, command, context)
end

def execute_without_timeout(command, context)
err_str = ''
error_buffer = ''
stdin, stdout, stderr, wait_thr = popen3(command)
context[:pid] = wait_thr[:pid]
files = [stderr, stdout]
Expand All @@ -78,7 +79,9 @@ def execute_without_timeout(command, context)

case fileno
when stderr.fileno
err_str << data
updated_error_buffer = error_buffer.dup
updated_error_buffer << data
error_buffer = updated_error_buffer
end
rescue EOFError
Hydra::Derivatives::Logger.debug "Caught an eof error in ShellBasedProcessor"
Expand All @@ -91,7 +94,7 @@ def execute_without_timeout(command, context)
stderr.close
exit_status = wait_thr.value

raise "Unable to execute command \"#{command}\". Exit code: #{exit_status}\nError message: #{err_str}" unless exit_status.success?
raise "Unable to execute command \"#{command}\". Exit code: #{exit_status}\nError message: #{error_buffer}" unless exit_status.success?
end

def all_eof?(files)
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/video.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives::Processors
module Video
extend ActiveSupport::Autoload
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/video/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives::Processors::Video
class Config
attr_writer :video_bitrate, :video_attributes, :size_attributes, :audio_attributes
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/processors/video/processor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives::Processors
module Video
class Processor < Hydra::Derivatives::Processors::Processor
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/active_encode_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class ActiveEncodeDerivatives < Runner
# @param [String, ActiveFedora::Base] object_or_filename source file name (or path), or an object that has a method that will return the file name
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/audio_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class AudioDerivatives < Runner
def self.processor_class
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/document_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class DocumentDerivatives < Runner
def self.processor_class
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/full_text_extract.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class FullTextExtract < ImageDerivatives
# Adds format: 'txt' as the default to each of the directives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/image_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class ImageDerivatives < Runner
# Adds format: 'png' as the default to each of the directives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/jpeg2k_image_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class Jpeg2kImageDerivatives < Runner
# # Adds format: 'png' as the default to each of the directives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/pdf_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra
module Derivatives
class PdfDerivatives < ImageDerivatives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra
module Derivatives
class Runner
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/runners/video_derivatives.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class VideoDerivatives < Runner
def self.processor_class
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/services/capability_service.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'open3'

module Hydra::Derivatives
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/services/mime_type_service.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'mime/types'

module Hydra::Derivatives
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
# This Service is an implementation of the Hydra::Derivatives::PeristOutputFileService
# It supports basic contained files, which is the behavior associated with Fedora 3 file datastreams that were migrated to Fedora 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'addressable'

module Hydra::Derivatives
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class PersistOutputFileService
# Persists the file within the object at destination_name. Uses basic containment.
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/services/remote_source_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# For the case where the source file is a remote file, and we
# don't want to download the file locally, just return the
# file name or file path (or whatever we need to pass to the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Hydra::Derivatives
class RetrieveSourceFileService
# Retrieves the source
Expand Down
1 change: 1 addition & 0 deletions lib/hydra/derivatives/services/tempfile_service.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'mime/types'

module Hydra::Derivatives
Expand Down
1 change: 1 addition & 0 deletions spec/processors/active_encode_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Hydra::Derivatives::Processors::ActiveEncode do
Expand Down
1 change: 1 addition & 0 deletions spec/processors/document_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'spec_helper'

describe Hydra::Derivatives::Processors::Document do
Expand Down
Loading

0 comments on commit 612ebf7

Please sign in to comment.