This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.rb
87 lines (78 loc) · 2.42 KB
/
configuration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# frozen_string_literal: true
require 'mime/types'
require 'logger'
module Derivative
module Rodeo
##
# @api public
#
# This class is responsible for the consistent configuration of the "application" that leverages
# the {Derivative::Rodeo}.
#
# Whereas the {Arena} is the place where we process an original file, the {Configuration}
# sits above the {Arena} and provides the information for processing all things within the
# application.
class Configuration
def initialize
@logger = Logger.new(STDERR, level: Logger::FATAL)
# Note the log level synchronization.
@dry_run_reporter = ->(string) { logger.info("\n#{string}\n") }
yield self if block_given?
end
attr_accessor :logger
##
# @!group Dry Run Configurations
#
# The desired mechanism for reporting on the {DryRun} activity.
#
# @example
# ##
# # Send the dry notices to STDERR
# Derivative::Rodeo.config do |cfg|
# cfg.dry_run_reporter = ->(text) { $stderr.puts text }
# end
# @return [#call]
attr_accessor :dry_run_reporter
# @!attribute [rw]
# @return [Boolean]
class_attribute :dry_run, default: false
# @!endgroup Dry Run Configurations
##
# @return [Array<Symbol>] the derivatives that are part of the initial pre-processing.
def derivatives_for_pre_process
@derivatives_for_pre_process || [:base_file_for_chain, :mime_type]
end
##
# @param derivatives [Array<#to_sym>]
#
# @see Derivative::Rodeo.start_pre_processing
def derivatives_for_pre_process=(derivatives)
@derivatives_for_pre_process = Array(derivatives).map(&:to_sym)
end
##
# @return [Symbol] the name of the queue we're using
#
# @see Derivative::Rodeo::QueueAdapters
def queue
@queue || :inline
end
attr_writer :queue
##
# @return [Symbol] the name of the local storage we're using
#
# @see Derivative::Rodeo::StorageAdapters
def local_storage
@local_storage || :file_system
end
attr_writer :local_storage
##
# @return [Symbol] the name of the local storage we're using
#
# @see Derivative::Rodeo::StorageAdapters
def remote_storage
@remote_storage || :file_system
end
attr_writer :remote_storage
end
end
end