More strict module loading required by newer ruby versions

This commit is contained in:
2019-10-11 07:20:34 -05:00
parent 9d06b6cf6c
commit c676bb98fe
20 changed files with 65 additions and 62 deletions
@@ -39,5 +39,4 @@ class Dunlop
label_or_callback = 'anonymous'
(@setup_callbacks[label_or_callback] ||= []).push labelled_callback
@Dunlop = new Dunlop()
@@ -1,7 +1,7 @@
@import ./dunlop/mixins
@import ./dunlop-semantic/calendar
@import ./dunlop-semantic/ui-calendar-additions
//@import ./dunlop-semantic/calendar
//@import ./dunlop-semantic/ui-calendar-additions
@import ./dunlop-semantic/convenience-helpers
@import ./dunlop/components/environment-ribbon
//@import ./dunlop/components/user_management
+5 -5
View File
@@ -1,10 +1,10 @@
module Dunlop
module ApplicationHelper
include Dunlop::ActiveClassHelper
include Dunlop::AuthorizationHelper
include Dunlop::TableHelper
include Dunlop::StateBadgeHelper
include Dunlop::InterpretedTextHelper
include ::Dunlop::ActiveClassHelper
include ::Dunlop::AuthorizationHelper
include ::Dunlop::TableHelper
include ::Dunlop::StateBadgeHelper
include ::Dunlop::InterpretedTextHelper
delegate :mathjax_path, to: :main_app
def application_name
+2 -2
View File
@@ -1,11 +1,11 @@
module Dunlop::AuthorizationHelper
def has_permission_of_type(type, user = current_user)
Dunlop::Ability.has_permission_of_type(type, user)
::Dunlop::Ability.has_permission_of_type(type, user)
end
# - if any_permission_starts_with 'source-file'
# NOTE: always true for admin users
def any_permission_starts_with(expression, user = current_user)
Dunlop::Ability.any_permission_starts_with(expression, user)
::Dunlop::Ability.any_permission_starts_with(expression, user)
end
end
@@ -1,7 +1,7 @@
module Dunlop
module ApplicationRecordAdditions
extend ActiveSupport::Concern
include Dunlop::ApplicationRecordAdditions::EpochWeeks
include ::Dunlop::ApplicationRecordAdditions::EpochWeeks
included do
self.abstract_class = true
+3 -3
View File
@@ -2,7 +2,7 @@ module Dunlop::ExecutionBatchModel
extend ActiveSupport::Concern
included do
include Dunlop::Loggable
include ::Dunlop::Loggable
state_machine initial: :new do
after_transition { |o| o.log_state_transition }
@@ -61,9 +61,9 @@ module Dunlop::ExecutionBatchModel
end
def execute!
return if Dunlop::ExecutionBatchPid.new(batch_pid_id).locked?
return if ::Dunlop::ExecutionBatchPid.new(batch_pid_id).locked?
batch = nil
Dunlop::ExecutionBatchPid.new(batch_pid_id).lock do
::Dunlop::ExecutionBatchPid.new(batch_pid_id).lock do
batch = create
batch.execute_process
end
+5 -4
View File
@@ -9,7 +9,7 @@ module Dunlop::SourceFileModel
end
end
include Dunlop::SourceFileModel::ConversionHelpers
include ::Dunlop::SourceFileModel::ConversionHelpers
included do
include Dunlop::Loggable
@@ -19,7 +19,7 @@ module Dunlop::SourceFileModel
Dunlop.source_file_models << self
scope :processed, -> { where state: ['active', 'inactive'] }
mount_uploader :original_file, Dunlop::SourceFileUploader unless defined?(Paperclip) # CarrierWave still default.
mount_uploader :original_file, ::Dunlop::SourceFileUploader unless defined?(Paperclip) # CarrierWave still default.
# used by dunlop-file_transfer
def default_file
@@ -82,11 +82,11 @@ module Dunlop::SourceFileModel
else
original_file.path
end
Dunlop::FileZip.unzip(source_path, working_file.path)
::Dunlop::FileZip.unzip(source_path, working_file.path)
end
def pre_process_working_file(target_path = working_file.path)
Dunlop::FileSed.fix_line_endings(target_path)
::Dunlop::FileSed.fix_line_endings(target_path)
end
def load_source_records
@@ -213,6 +213,7 @@ module Dunlop::SourceFileModel
first
end
#TODO: this is not compatible with multiple source_file impolementations in one application
def recent_ids
group(:sti_type).map do |combination|
sti_type = combination.sti_type
+4 -4
View File
@@ -12,13 +12,13 @@ module Dunlop::TargetFileModel
end
included do
include Dunlop::Loggable
include ::Dunlop::Loggable
has_many :downloads, class_name: 'Dunlop::FileDownload', as: :file
attr_accessor :working_file, :original_file
attr_accessor :resource
Dunlop.target_file_models << self
mount_uploader :original_file, Dunlop::TargetFileUploader unless defined?(Paperclip) # CarrierWave still default.
mount_uploader :original_file, ::Dunlop::TargetFileUploader unless defined?(Paperclip) # CarrierWave still default.
# used by dunlop-file_transfer
def default_file
original_file
@@ -135,9 +135,9 @@ module Dunlop::TargetFileModel
end
def gzip_file
return if Dunlop::FileZip.mime_type(working_file.path) == "application/x-gzip" # no double action and working file replacement
return if ::Dunlop::FileZip.mime_type(working_file.path) == "application/x-gzip" # no double action and working file replacement
local_working_file = new_working_file
Dunlop::FileZip.gzip(working_file.path,local_working_file.path)
::Dunlop::FileZip.gzip(working_file.path,local_working_file.path)
working_file.unlink rescue SystemCallError # container permission issue
self.working_file = local_working_file
end
+1 -1
View File
@@ -11,7 +11,7 @@ module Dunlop
end
def settings
@settings ||= Dunlop::UserSettings.new(self, settings_storage)
@settings ||= ::Dunlop::UserSettings.new(self, settings_storage)
end
def all_role_names
@@ -2,7 +2,7 @@ module Dunlop::WorkflowInstanceBatchModel
extend ActiveSupport::Concern
included do
include Dunlop::ProcessIdentification
include ::Dunlop::ProcessIdentification
has_many :workflow_instances, inverse_of: :workflow_instance_batch
end
+6 -6
View File
@@ -2,12 +2,12 @@ module Dunlop::WorkflowInstanceModel
extend ActiveSupport::Concern
included do
include Dunlop::WorkflowInstanceModel::StateMachineHandling
include Dunlop::WorkflowInstanceModel::WorkflowStepHandling
include Dunlop::WorkflowInstanceModel::ArchivedHandling
include Dunlop::WorkflowInstanceModel::CategorizationAndResetHandling
include Dunlop::ProcessIdentification
include Dunlop::CollectionLookup
include ::Dunlop::WorkflowInstanceModel::StateMachineHandling
include ::Dunlop::WorkflowInstanceModel::WorkflowStepHandling
include ::Dunlop::WorkflowInstanceModel::ArchivedHandling
include ::Dunlop::WorkflowInstanceModel::CategorizationAndResetHandling
include ::Dunlop::ProcessIdentification
include ::Dunlop::CollectionLookup
@scenario_workflow_step_names = []
belongs_to :workflow_instance_batch, inverse_of: :workflow_instances, optional: true
+5 -5
View File
@@ -1,12 +1,12 @@
module Dunlop::WorkflowStepModel
extend ActiveSupport::Concern
include Dunlop::WorkflowStepModel::StateMachine
include Dunlop::ProcessIdentification
include Dunlop::AttributeChangesTracking
include ::Dunlop::WorkflowStepModel::StateMachine
include ::Dunlop::ProcessIdentification
include ::Dunlop::AttributeChangesTracking
included do
include Dunlop::CollectionLookup
include Dunlop::WorkflowStepModel::NotesHandling
include ::Dunlop::CollectionLookup
include ::Dunlop::WorkflowStepModel::NotesHandling
belongs_to :workflow_instance, optional: true
#include HasManyChangeEvents
end
+7 -7
View File
@@ -26,11 +26,11 @@ module Dunlop::Ability
end
def has_permission_of_type(type)
Dunlop::Ability.has_permission_of_type(type, user)
::Dunlop::Ability.has_permission_of_type(type, user)
end
def any_permission_starts_with(expression)
Dunlop::Ability.any_permission_starts_with(expression, user)
::Dunlop::Ability.any_permission_starts_with(expression, user)
end
def setup_dunlop_abilities
@@ -62,12 +62,12 @@ module Dunlop::Ability
roles.push get_role_for_role_name(role_name)
end
user.role_names_admin.each do |role_name|
roles.push get_role_for_role_name(role_name, role: Dunlop::Ability::AdminRole, verify_class: false)
roles.push get_role_for_role_name(role_name, role: ::Dunlop::Ability::AdminRole, verify_class: false)
end
@all_roles = roles.compact
end
def get_role_for_role_name(role_name, role: Dunlop::Ability::UserRole, verify_class: true)
def get_role_for_role_name(role_name, role: ::Dunlop::Ability::UserRole, verify_class: true)
return unless role_name =~ /\w+-\w+-[\w:\/-]+/
ability, type, class_name = role_name.split('-', 3)
case type
@@ -154,12 +154,12 @@ module Dunlop::Ability
def add_dunlop_allowed_authorization_classes!
result = ['Dunlop::Engine']
if Dunlop.has_workflow?
if ::Dunlop.has_workflow?
result += ['WorkflowInstance', 'WorkflowInstanceBatch']
result += WorkflowInstance.possible_workflow_step_names.map{|name| name.to_s.classify }
end
result += SourceFile.classes.map(&:name) if Dunlop.has_source_files?
result += TargetFile.classes.map(&:name) if Dunlop.has_target_files?
result += SourceFile.classes.map(&:name) if ::Dunlop.has_source_files?
result += TargetFile.classes.map(&:name) if ::Dunlop.has_target_files?
@allowed_authorization_classes |= result
end
end
+12 -12
View File
@@ -9,18 +9,18 @@ module Dunlop::Loggable
scope ||= caller[0][/`.*'/][1..-2]
options[:exception_notifier] = true unless options.has_key?(:exception_notifier)
backtrace = nil
Dunlop::NestedLogger.scope('empty sandbox', benchmark: false) do
result = Dunlop::NestedLogger.scope(scope, options) do
::Dunlop::NestedLogger.scope('empty sandbox', benchmark: false) do
result = ::Dunlop::NestedLogger.scope(scope, options) do
begin
yield
rescue => e
failed!
ExceptionNotifier.notify_exception(e) if options[:exception_notifier]
backtrace = Dunlop::LogEntry.exception_to_backtrace(e)
Dunlop::NestedLogger.error(e.message)
backtrace = ::Dunlop::LogEntry.exception_to_backtrace(e)
::Dunlop::NestedLogger.error(e.message)
end
end
log_yaml = Dunlop::NestedLogger.flush_as_yaml
log_yaml = ::Dunlop::NestedLogger.flush_as_yaml
log_entries.create(body: log_yaml, backtrace: backtrace) if log_yaml.present?
result # return block result
end
@@ -30,23 +30,23 @@ module Dunlop::Loggable
scope ||= caller[0][/`.*'/][1..-2]
e = nil
backtrace = nil
Dunlop::NestedLogger.scope('empty sandbox', benchmark: false) do
Dunlop::NestedLogger.scope(scope, options) do
::Dunlop::NestedLogger.scope('empty sandbox', benchmark: false) do
::Dunlop::NestedLogger.scope(scope, options) do
begin
yield
rescue => e
backtrace = Dunlop::LogEntry.exception_to_backtrace(e)
Dunlop::NestedLogger.error(e.message)
backtrace = ::Dunlop::LogEntry.exception_to_backtrace(e)
::Dunlop::NestedLogger.error(e.message)
end
end
log_yaml = Dunlop::NestedLogger.flush_as_yaml
log_yaml = ::Dunlop::NestedLogger.flush_as_yaml
log_entries.create(body: log_yaml, backtrace: backtrace) if log_yaml.present?
end
raise e if e
end
def logger
Dunlop::NestedLogger
::Dunlop::NestedLogger
end
def log_state_transition
@@ -54,6 +54,6 @@ module Dunlop::Loggable
end
def log_entry
Dunlop::LogEntryCreator.new(self)
::Dunlop::LogEntryCreator.new(self)
end
end
+2 -2
View File
@@ -88,7 +88,7 @@ module Dunlop::NestedLogger
end
def flush_as_yaml
(f = flush.presence) ? YAML.dump(f, Dunlop::NestedLogger.options[:yaml_options]).sub("---\n", '') : ''
(f = flush.presence) ? YAML.dump(f, ::Dunlop::NestedLogger.options[:yaml_options]).sub("---\n", '') : ''
end
def log(options={})
@@ -150,7 +150,7 @@ module Dunlop::NestedLogger
end
def to_entry
Dunlop::NestedLogger.formatter.call(severity, datetime, progname, msg)
::Dunlop::NestedLogger.formatter.call(severity, datetime, progname, msg)
end
end
+2 -2
View File
@@ -43,11 +43,11 @@ module Dunlop::OverdueHandling
workflow_step_proxy = WorkflowStepProxy.new(workflow_step, options)
workflow_step_proxy.instance_eval(&block) if block
workflow_step_proxy.register_callbacks!
Dunlop::OverdueHandling.registry[workflow_step] = workflow_step_proxy
::Dunlop::OverdueHandling.registry[workflow_step] = workflow_step_proxy
end
def the_final_states_are(states)
Dunlop::OverdueHandling.final_states = states
::Dunlop::OverdueHandling.final_states = states
end
end
+1 -1
View File
@@ -3,7 +3,7 @@ module Dunlop::Workflow
class << self
attr_accessor :configuration
def configuration
@configuration ||= Dunlop::Workflow::Configuration.new
@configuration ||= ::Dunlop::Workflow::Configuration.new
end
end
@@ -62,11 +62,11 @@ module Dunlop::WorkflowStepsInBatchFinished
def on_finishing_of(workflow_step, options = {}, &block)
workflow_step_proxy = WorkflowStepProxy.new
workflow_step_proxy.instance_eval(&block)
Dunlop::WorkflowStepsInBatchFinished.registry[workflow_step] = workflow_step_proxy
::Dunlop::WorkflowStepsInBatchFinished.registry[workflow_step] = workflow_step_proxy
end
def the_final_states_are(states)
Dunlop::WorkflowStepsInBatchFinished.final_states = states
::Dunlop::WorkflowStepsInBatchFinished.final_states = states
end
end
+3
View File
@@ -32,3 +32,6 @@ class JSONColumnCoder
end
end
# rails 6 does not eager load the JSONColumnCoder notation
class JsonColumnCoder < JSONColumnCoder
end
+1 -1
View File
@@ -40,7 +40,7 @@ module Dunlop
#TODO this generates noise and pollutes API based implementations (Like Panda)
initializer 'dunlop.action_controller' do |app|
ActiveSupport.on_load :action_controller do
helper Dunlop::ApplicationHelper if respond_to?(:helper)
helper ::Dunlop::ApplicationHelper if respond_to?(:helper)
end
end