Module: Kiba::Extend::Fcar

Extended by:
Dry::Configurable
Defined in:
lib/kiba/extend/fcar.rb

Overview

Optional settings for creating sequenced FCAR processes in a project.

This code’s original use was in an abstract project, where it was used to determine whether a client project was using a given facilitated cleanup and remapping (FCAR) process or not, and thus automagically determine the correct source job for a given FCAR process in a given client project

Class Method Summary collapse

Class Method Details

.base_sourceSymbol

Returns job key of job whose output should be used as input for initial FCAR process.

Returns:

  • (Symbol)

    job key of job whose output should be used as input for initial FCAR process



24
# File 'lib/kiba/extend/fcar.rb', line 24

setting :base_source, reader: true, default: :your__jobkey

.chuteArray<String>, Hash{String => String}

Sample CHUTE for a reusable codebase on which multiple client projects can be based:

  • ObjectCounts

    The order of the overall CHUTE is NOT the order you must complete all the FCAR processes. For instance, your migration process may have you starting with the 2, not Itemandboxcount. Without an Itemandboxcount process set up, the source for AgencyMuseumNameCleanup will be the base_source. If/when you set up an Itemandboxcount process, its source will be base_source and AgencyMuseumNameCleanup’s source will become the output of the merge job for Itemandboxcount.

Within a group, you can leave out steps if they aren’t needed. For instance, if no site values are multi-value, you can skip SiteSplit. If multiple processs from a group are needed, they must be done in order.

Any hard-dependencies on order between processes and/or groups should be specified in the comments.

Returns:

  • (Array<String>, Hash{String => String})

    All FCAR processes defined for your project, in the order they are run. Use the Hash form if you wish to provide comments on the processes.



51
52
53
54
55
56
57
58
59
# File 'lib/kiba/extend/fcar.rb', line 51

setting :chute,
reader: true,
default: [],
constructor: ->(default) do
  return {} if default.empty?
  return default if default.is_a?(Hash)

  default.map { |e| [e, ""] }.to_h
end

.final_mergedObject



77
# File 'lib/kiba/extend/fcar.rb', line 77

def final_merged = processes[-1]&.merge_job || base_source

.pending_processesArray<Module>

Returns FCAR processes intended for use in your project, for which there are not yet any files.

Returns:

  • (Array<Module>)

    FCAR processes intended for use in your project, for which there are not yet any files



20
# File 'lib/kiba/extend/fcar.rb', line 20

setting :pending_processes, reader: true, default: []

.previous_merged(mod) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/kiba/extend/fcar.rb', line 69

def previous_merged(mod)
  idx = processes.find_index(mod)
  fail(Kiba::Extend::UnknownFcarConfigError.new(mod)) unless idx
  return base_source if idx == 0

  processes[idx - 1].merge_job
end

.processesArray<Module>

Returns FCAR processes used in client project.

Returns:

  • (Array<Module>)

    FCAR processes used in client project



62
63
64
65
66
67
# File 'lib/kiba/extend/fcar.rb', line 62

def processes
  chute.keys
    .map { |name| project_process(name) }
    .compact
    .select { |mod| active?(mod) && valid?(mod) }
end