You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/file_registry_entry.md
+51-37Lines changed: 51 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,16 +40,16 @@ The allowable Hash keys, expected Hash value formats, and expectations about the
40
40
**NOTE:** (Since 3.0.0) For all keys besides `:dest_special_opts`, you may pass a Proc that returns the expected value format when called. For `:dest_special_opts`, you may pass Procs as individual values within the option Hash. This can be useful if you need to pass in a value that depends on other project config that may not be loaded/set up when registry is initially populated. A publicly available example is in `kiba-tms` which [sets destination initial headers](https://github.com/lyrasis/kiba-tms/blob/eb8f222f0dc753921e58d136cd15e5eab7472c60/lib/kiba/tms/table/prep/destination_options.rb#L32-L34)[based on the preferred name field for a given TMS client project, and whether they want to include "flipped" form as variant terms](https://github.com/lyrasis/kiba-tms/blob/eb8f222f0dc753921e58d136cd15e5eab7472c60/lib/kiba/tms/constituents.rb#L140-L148).
41
41
42
42
### `:path`
43
-
[String] full or expandable relative path to the expected location of the file
43
+
[String] full path or expandable relative path to the expected location of the file associated with the registry entry. If it is a supplied entry, the file must be present at this location. If it is a job entry, this is the location where the output of the job is written.
44
44
45
45
* default: `nil`
46
-
* required if either `:src_class` or `:dest_class` requires a path
46
+
*A path String value is required if either `:src_class` or `:dest_class` requires a path
47
47
48
48
### `:src_class`
49
-
[Class] the Ruby class used to read in data. This class must be defined in the `Sources` namespace or equivalent. Example: you should never use {Kiba::Extend::Destinations::CSV} as a `src_class`value.
49
+
[Class] the Ruby class used to read in data. This class must be defined in the `Sources` namespace or equivalent. That is, {Kiba::Extend::Destinations::CSV} will not work as a `src_class`value.
50
50
51
51
* required, but default supplied if not given
52
-
* default: value of {Kiba::Extend.source} (`Kiba::Extend::Sources::CSV` unless overridden by your ETL app)
52
+
* default: value of {Kiba::Extend.source} (This will be `Kiba::Extend::Sources::CSV` unless overridden by your ETL app)
53
53
54
54
### `:src_opt`
55
55
[Hash] file options used when reading in source
@@ -62,10 +62,10 @@ The allowable Hash keys, expected Hash value formats, and expectations about the
62
62
* A hash of keyword parameters defined for [MARC::Reader](https://github.com/ruby-marc/ruby-marc/blob/main/lib/marc/reader.rb) can be entered, for example: `{external_encoding: "MARC-8", internal_encoding: "UTF-16LE"}`
63
63
64
64
### `:dest_class`
65
-
[Class] the Ruby class used to write out the data. This class must be defined in the `Destinations` namespace or equivalent. Example: you should never use `Kiba::Extend::Sources::CSV` as a `:dest_class` value.
65
+
[Class] the Ruby class used to write out the data. This class must be defined in the `Destinations` namespace or equivalent. That is, `Kiba::Extend::Sources::CSV` will not work as a `:dest_class` value.
66
66
67
67
* required, but default supplied if not given
68
-
* default: value of {Kiba::Extend.destination} ({Kiba::Extend::Destinations::CSV} unless overridden by your ETL app)
68
+
* default: value of {Kiba::Extend.destination} (This will be {Kiba::Extend::Destinations::CSV} unless overridden by your ETL app)
69
69
70
70
### `:dest_opt`
71
71
[Hash] file options used when writing data
@@ -82,7 +82,7 @@ The allowable Hash keys, expected Hash value formats, and expectations about the
82
82
* optional
83
83
* Only the following destination classes support extra options. If you provide unsupported extra options, they will not be sent through to the destination class, and you will receive a warning in STDOUT.
* {Kiba::Extend::Destinations::Marc} (`allow_oversized`) - Sets the `MARC::Writer` created by the destination to allow oversized records. See [`MARC::Writer` code](https://github.com/ruby-marc/ruby-marc/blob/main/lib/marc/writer.rb) for explanation.
86
86
87
87
Examples:
88
88
@@ -103,19 +103,19 @@ reghash = {
103
103
~~~
104
104
105
105
### `:creator`
106
-
[Method, Module, Hash]Ruby method that generates this file
106
+
[Method, Module, Hash]to run the job and create the expected output
107
107
108
108
* Used to run ETL jobs to create necessary files, if said files do not exist
109
-
* Not required at all if file is supplied
110
-
* If the method that runs the job is a module instance method named `job`, creator value can just be the `Module` containing the `:job` method
111
-
* Otherwise, the creator value must be a `Method` (Pattern: `Class::Or::Module::ConstantName.method(:name_of_method)`)
112
-
* Sometimes you may need to call a job with arguments. This may be particularly useful if the same job logic can be reused many times with slightly different parameters. In this case creator may be a Hash with `callee` and `args` keys
109
+
* Not required if file is supplied
110
+
* When to give a `Method`, `Module`, or `Hash` as `:creator` is described below.
113
111
114
-
NOTE: The default value for {Kiba::Extend.default_job_method_name} is `:job`. You can override this in your project's base file as follows (since 2.7.2):
112
+
#### `Module` creator example (since 2.7.2)
113
+
114
+
The default value for {Kiba::Extend.default_job_method_name} is `:job`. You can override this in your project's base file as follows (since 2.7.2):
* If the method that runs the job is a module instance method with the default job method name, the `:creator` can be the `Module` containing that method
119
119
120
120
This is valid because the default `:job` method is present in the module:
121
121
@@ -142,15 +142,15 @@ reghash = {
142
142
143
143
#### `Method` creator example
144
144
145
-
Default `:job` method not present (or is not the method you need to call for this job).
145
+
If the method that runs the job is not the default job method name, you must set a `Method` as `:creator`:
146
146
147
147
~~~ruby
148
148
# in job definitions
149
149
moduleProject
150
150
moduleTable
151
151
module_function
152
152
153
-
defprep
153
+
defprepjob
154
154
Kiba::Extend::Jobs::Job.new(
155
155
...
156
156
)
@@ -161,19 +161,22 @@ end
161
161
# in file registry
162
162
reghash = {
163
163
path:'/project/working/objects_prep.csv',
164
-
creator:Project::Table.method(:prep)
164
+
creator:Project::Table.method(:prepjob)
165
165
}
166
166
~~~
167
167
168
168
#### `Hash` creator example (since 2.7.2)
169
169
170
+
You may wish to call a job with arguments if the same job logic can be reused many times with slightly different parameters. In this case, `:creator` may be a Hash with `callee` and `args` keys
171
+
170
172
Hash keys:
171
173
172
174
*`callee`: `Method` or `Module` (as described above)
173
175
*`args`: `Hash` of keyword arguments to pass to the callee
transform FilterRows::FieldEqualTo, action::keep, field::lookup_type, value: type
252
+
transform FilterRows::FieldEqualTo,
253
+
action::keep,
254
+
field::lookup_type,
255
+
value: type
243
256
end
244
257
end
245
258
end
@@ -249,14 +262,13 @@ end
249
262
~~~
250
263
251
264
### `:supplied`
252
-
[true, false] whether the file/data is supplied from outside the ETL
265
+
[true, false] whether the file/data is supplied from outside the kiba-extend project
253
266
254
267
- default: false
255
268
- Manually set to true for:
256
269
- original data files from client
257
270
- mappings/reconciliations to be merged into the ETL/migration
258
271
- any other files created external to the ETL, which only need to be read from and never generated by the ETL process
259
-
- entries where `:src_class` is {Kiba::Extend::Sources::Marc}
260
272
261
273
Both of the following are valid:
262
274
@@ -279,12 +291,12 @@ reghash = {
279
291
280
292
If the output of a given entry is expected to be used as a lookup on only one field, set a `:lookup_on` value in the registry.
281
293
282
-
If you need to lookup in the output data on different columns, either within one job or in different jobs, this can be achieved by providing more information in the job definition's `files[:lookup]` value. See {Kiba::Extend::Jobs} for details. (Or you can register the same file multiple times under different file keys with different `:lookup_on` values, but yuck to that)
294
+
If you need to lookup in the output data on different columns, either within one job or in different jobs, this can be achieved by providing more information in the job definition's `files[:lookup]` value, starting with v5.1.0. See {Kiba::Extend::Jobs} for details. (Or you can register the same file multiple times under different file keys with different `:lookup_on` values, but yuck to that)
283
295
284
296
Currently only the following types of registry entries can be used as lookups:
285
297
286
-
*`:supplied` = `true` and `:src_class` returns row/record Hashes
287
-
*`:dest_class`writes/returns row/record Hashes
298
+
*Supplied registry entries where the `:src_class` returns each row/record as a Ruby `Hash`
299
+
*Job registry entries where the `as_source_class` class attribute of the `:dest_class` returns each row/record as a Ruby `Hash`
288
300
289
301
Other types of registry entries should not define a `:lookup_on` value.
290
302
@@ -297,9 +309,11 @@ Other types of registry entries should not define a `:lookup_on` value.
297
309
[Array (of Symbols)] list of arbitrary tags useful for categorizing data/jobs in your ETL
298
310
299
311
* optional
300
-
* If set, you can filter to run only jobs tagged with a given tag (or tags)1
312
+
* If set, you can filter to run only jobs tagged with a given tag (or tags)
301
313
* Tags I commonly use:
302
314
*:report_problems - reports that indicate something unexpected or that I need to do more work
303
315
*:report_fyi - informational reports
304
316
*:postmigcleanup - for reports I will need to generate for client after production migration is complete
305
317
*:cspace or :ingest- final files ready to import
318
+
319
+
You can do `thor reg:tags` to see a list of all tags already defined in your registry.
0 commit comments