berkeley_library-tind 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/tind.iml +42 -42
  3. data/.rubocop.yml +1 -1
  4. data/CHANGES.md +10 -2
  5. data/LICENSE.md +1 -1
  6. data/README.md +50 -6
  7. data/berkeley_library-tind.gemspec +2 -3
  8. data/lib/berkeley_library/tind/export/ods_exporter.rb +4 -6
  9. data/lib/berkeley_library/tind/mapping/alma_base.rb +7 -0
  10. data/lib/berkeley_library/tind/mapping/data/one_to_one_mapping.csv +39 -39
  11. data/lib/berkeley_library/tind/mapping/field_catalog.rb +2 -11
  12. data/lib/berkeley_library/tind/mapping/field_catalog_util.rb +49 -3
  13. data/lib/berkeley_library/tind/mapping/single_rule.rb +6 -0
  14. data/lib/berkeley_library/tind/mapping/tind_field_from_single_map.rb +13 -1
  15. data/lib/berkeley_library/tind/mapping/tind_record_util.rb +135 -0
  16. data/lib/berkeley_library/tind/mapping/util.rb +19 -0
  17. data/lib/berkeley_library/tind/module_info.rb +1 -1
  18. data/lib/berkeley_library/util/ods/spreadsheet.rb +3 -0
  19. data/spec/berkeley_library/tind/mapping/alma_multiple_tind_spec.rb +1 -1
  20. data/spec/berkeley_library/tind/mapping/alma_single_tind_spec.rb +1 -1
  21. data/spec/berkeley_library/tind/mapping/field_catalog_util_spec.rb +48 -0
  22. data/spec/berkeley_library/tind/mapping/match_tind_field_spec.rb +1 -2
  23. data/spec/berkeley_library/tind/mapping/tind_field_from_single_map_spec.rb +17 -0
  24. data/spec/berkeley_library/tind/mapping/tind_record_util_spec.rb +30 -0
  25. data/spec/data/api/pre_assigned_response.json +15 -0
  26. data/spec/data/api/result_file.csv +3 -0
  27. data/spec/data/api/upload_file.json +1 -0
  28. data/spec/data/api/upload_response.json +13 -0
  29. data/spec/data/mapping/record.xml +6 -3
  30. metadata +21 -83
  31. data/lib/berkeley_library/util/files.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ade606682d0d814a4debfbe0be2a6741ae72977d710511d5df70118569dea764
4
- data.tar.gz: 2da4f7cd4b7f0c1cf6f8dcf9bf3346d89599e9130f28a185cb0cab0a37a39d3d
3
+ metadata.gz: 5332f904f900b0625e2c8fd8053d82908dcbec81b0cd6b640a469d2f95444258
4
+ data.tar.gz: 86712b729232b939c4bdcb80f4f777350f2dc2a54b961f55cf0f5044ec6e28ac
5
5
  SHA512:
6
- metadata.gz: ed708269e8c628616c89643c49cb3394401febf8f9a0f4defde88abad17a8ac2f5b43663345cd0513aa2e7b02e41fb3475446f55aa7ad394aa83ad62ae114565
7
- data.tar.gz: b4f851305ad936b9f7cb46c8a521358cdfff34f51aebfb6d121481545777476af8adce6c3b8c0042aeaeca2ee00a7d1826f955f46ee5ad1f11361c7ed1843b72
6
+ metadata.gz: 128f6934601f62b3d4a62de941a3a059b23ff137d6385c0594cd4e7fe97d2cc43bfd3dd827a2cfe6c5e247ef1796f371ea6542c45ceb4849ac6235419a8c4ed3
7
+ data.tar.gz: 6e98e778835b65d4a0f21affcdbeed11a6f0d835c300a478e62784c90912a31dddec47f24881e95fa6258ae43ed70f1146d3a5d855551fb22bea742f5a5903b2
data/.idea/tind.iml CHANGED
@@ -9,20 +9,20 @@
9
9
  </content>
10
10
  <orderEntry type="jdk" jdkName="RVM: ruby-2.7.5" jdkType="RUBY_SDK" />
11
11
  <orderEntry type="sourceFolder" forTests="false" />
12
- <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="amazing_print (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="berkeley_library-alma (v0.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.6, RVM: ruby-2.7.5) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="berkeley_library-alma (v0.0.7.1, RVM: ruby-2.7.5) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.7, RVM: ruby-2.7.5) [gem]" level="application" />
20
20
  <orderEntry type="library" scope="PROVIDED" name="berkeley_library-marc (v0.3.1, RVM: ruby-2.7.5) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="berkeley_library-util (v0.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="berkeley_library-util (v0.1.5, RVM: ruby-2.7.5) [gem]" level="application" />
22
22
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-2.7.5) [gem]" level="application" />
23
23
  <orderEntry type="library" scope="PROVIDED" name="bundle-audit (v0.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
24
24
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.31, RVM: ruby-2.7.5) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="bundler-audit (v0.9.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="bundler-audit (v0.9.1, RVM: ruby-2.7.5) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter_rspec (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
28
28
  <orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -32,50 +32,50 @@
32
32
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.5) [gem]" level="application" />
33
33
  <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
34
34
  <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, RVM: ruby-2.7.5) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.7.6, RVM: ruby-2.7.5) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
36
36
  <orderEntry type="library" scope="PROVIDED" name="equivalent-xml (v0.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="erubi (v1.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="erubi (v1.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
38
38
  <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
39
39
  <orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.7.5) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.5, RVM: ruby-2.7.5) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
42
42
  <orderEntry type="library" scope="PROVIDED" name="ice_nine (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
43
43
  <orderEntry type="library" scope="PROVIDED" name="lograge (v0.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
44
- <orderEntry type="library" scope="PROVIDED" name="loofah (v2.15.0, RVM: ruby-2.7.5) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="marc (v1.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="loofah (v2.19.1, RVM: ruby-2.7.5) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="marc (v1.2.0, RVM: ruby-2.7.5) [gem]" level="application" />
46
46
  <orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
47
47
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
48
48
  <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, RVM: ruby-2.7.5) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.5) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.17.0, RVM: ruby-2.7.5) [gem]" level="application" />
50
50
  <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
51
- <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.3, RVM: ruby-2.7.5) [gem]" level="application" />
52
- <orderEntry type="library" scope="PROVIDED" name="oj (v3.13.11, RVM: ruby-2.7.5) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="oj (v3.13.23, RVM: ruby-2.7.5) [gem]" level="application" />
53
53
  <orderEntry type="library" scope="PROVIDED" name="ougai (v1.9.1, RVM: ruby-2.7.5) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-2.7.5) [gem]" level="application" />
55
- <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-2.7.5) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
56
56
  <orderEntry type="library" scope="PROVIDED" name="parslet (v2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
57
- <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
58
- <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
59
- <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
60
- <orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.2, RVM: ruby-2.7.5) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.6.2, RVM: ruby-2.7.5) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v2.0.2, RVM: ruby-2.7.5) [gem]" level="application" />
61
61
  <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, RVM: ruby-2.7.5) [gem]" level="application" />
62
- <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
63
- <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.4, RVM: ruby-2.7.5) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
64
64
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
65
65
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
66
66
  <orderEntry type="library" scope="PROVIDED" name="rchardet (v1.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
67
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.1, RVM: ruby-2.7.5) [gem]" level="application" />
67
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.6.1, RVM: ruby-2.7.5) [gem]" level="application" />
68
68
  <orderEntry type="library" scope="PROVIDED" name="request_store (v1.5.1, RVM: ruby-2.7.5) [gem]" level="application" />
69
69
  <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
70
70
  <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.5) [gem]" level="application" />
71
- <orderEntry type="library" scope="PROVIDED" name="roo (v2.8.3, RVM: ruby-2.7.5) [gem]" level="application" />
72
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
73
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
74
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
75
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
76
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
71
+ <orderEntry type="library" scope="PROVIDED" name="roo (v2.9.0, RVM: ruby-2.7.5) [gem]" level="application" />
72
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.2, RVM: ruby-2.7.5) [gem]" level="application" />
75
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.3, RVM: ruby-2.7.5) [gem]" level="application" />
76
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.0, RVM: ruby-2.7.5) [gem]" level="application" />
77
77
  <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
78
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.2, RVM: ruby-2.7.5) [gem]" level="application" />
78
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.24.1, RVM: ruby-2.7.5) [gem]" level="application" />
79
79
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rake (v0.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
80
80
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v2.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
81
81
  <orderEntry type="library" scope="PROVIDED" name="ruby-marc-spec (v0.1.3, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -83,18 +83,18 @@
83
83
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
84
84
  <orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, RVM: ruby-2.7.5) [gem]" level="application" />
85
85
  <orderEntry type="library" scope="PROVIDED" name="scrub_rb (v1.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
86
- <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, RVM: ruby-2.7.5) [gem]" level="application" />
86
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.22.0, RVM: ruby-2.7.5) [gem]" level="application" />
87
87
  <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-2.7.5) [gem]" level="application" />
88
- <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
88
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.3.1, RVM: ruby-2.7.5) [gem]" level="application" />
89
89
  <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
90
90
  <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.5) [gem]" level="application" />
91
- <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.0, RVM: ruby-2.7.5) [gem]" level="application" />
92
- <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
91
+ <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.1, RVM: ruby-2.7.5) [gem]" level="application" />
92
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.5, RVM: ruby-2.7.5) [gem]" level="application" />
93
93
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
94
- <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
95
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
96
- <orderEntry type="library" scope="PROVIDED" name="webmock (v3.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
97
- <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, RVM: ruby-2.7.5) [gem]" level="application" />
94
+ <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.2, RVM: ruby-2.7.5) [gem]" level="application" />
95
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
96
+ <orderEntry type="library" scope="PROVIDED" name="webmock (v3.18.1, RVM: ruby-2.7.5) [gem]" level="application" />
97
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.6.6, RVM: ruby-2.7.5) [gem]" level="application" />
98
98
  </component>
99
99
  <component name="RModuleSettingsStorage">
100
100
  <LOAD_PATH number="2" string0="$MODULE_DIR$/lib" string1="$MODULE_DIR$/spec" />
@@ -111,7 +111,7 @@
111
111
  </RakeTaskImpl>
112
112
  <RakeTaskImpl description="Run all specs in spec directory, with coverage" fullCommand="coverage" id="coverage" />
113
113
  <RakeTaskImpl description="Run tests, check test coverage, check code style, check for vulnerabilities, build gem" fullCommand="default" id="default" />
114
- <RakeTaskImpl description="Build berkeley_library-tind.gemspec as berkeley_library-tind-0.6.0.gem" fullCommand="gem" id="gem" />
114
+ <RakeTaskImpl description="Build berkeley_library-tind.gemspec as berkeley_library-tind-0.7.0.gem" fullCommand="gem" id="gem" />
115
115
  <RakeTaskImpl description="Run RuboCop with auto-correct, and output results to console" fullCommand="ra" id="ra" />
116
116
  <RakeTaskImpl description="Run rubocop with HTML output" fullCommand="rubocop" id="rubocop" />
117
117
  <RakeTaskImpl id="rubocop">
data/.rubocop.yml CHANGED
@@ -331,4 +331,4 @@ Style/SwapValues: # (new in 1.1)
331
331
  Gemspec/DateAssignment: # (new in 1.10)
332
332
  Enabled: true
333
333
  Style/HashConversion: # (new in 1.10)
334
- Enabled: true
334
+ Enabled: true
data/CHANGES.md CHANGED
@@ -1,10 +1,18 @@
1
- # 0.6.0 (2023-04-06)
1
+ # 0.7.0 (2022-10-26)
2
+
3
+ - Preserves subfield order insofar as possible when mapping Alma records to TIND.
4
+ - Adds collection-specific configuration for mapping Alma records to TIND.
5
+ - Adds `BerkeleyLibrary::TIND::Mapping::TindRecordUtil` class for manipulating
6
+ subfields in TIND MARC records.
7
+ - Removes `BerkeleyLibrary::Util::Files` class, which is now part of `berkeley_library-util`.
8
+
9
+ # 0.6.0 (2022-04-06)
2
10
 
3
11
  - Adds `BerkeleyLibrary::TIND::Mapping` module to map MARC records from Alma to TIND.
4
12
  - `BerkeleyLibrary::TIND::MARC::XMLWriter` now assumes that any object that response to `:write`
5
13
  and `:close` is suffiently `IO`-like to write to.
6
14
 
7
- # 0.5.1 (2023-03-23)
15
+ # 0.5.1 (2022-03-23)
8
16
 
9
17
  - Fix an issue where `BerkeleyLibrary::TIND::MARC::XMLWriter` would drop fields with nonstandard tags (e.g. `FFT` fields)
10
18
  and would group and sort fields by tag instead of preserving the original order.
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
 
3
- Copyright © 2021 The Regents of the University of California
3
+ Copyright © 2023 The Regents of the University of California
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a
6
6
  copy of this software and associated documentation files (the “Software”),
data/README.md CHANGED
@@ -45,10 +45,10 @@ string setting will raise `URI::InvalidURIError`.
45
45
 
46
46
  ### Alma configuration
47
47
 
48
- When mapping Alma records to TIND (see below), this gem uses
48
+ When mapping Alma records to TIND (see below), this gem uses
49
49
  [`berkeley_library-alma`](https://github.com/BerkeleyLibrary/alma) to load
50
50
  Alma records. The scripts in the `bin` directory use the default Alma
51
- configuration; see the `berkeley_library-alma`
51
+ configuration; see the `berkeley_library-alma`
52
52
  [README](https://github.com/BerkeleyLibrary/alma#configuration) for
53
53
  details.
54
54
 
@@ -127,7 +127,8 @@ variable are set for either, the explicit option takes precedence.
127
127
  ### Example
128
128
 
129
129
  1. Setup collection information
130
-
130
+
131
+ Include below collection level fields:
131
132
  - 336: type of resource
132
133
  - 852: collection's repository name
133
134
  - 980: collection's 980 value
@@ -137,6 +138,7 @@ variable are set for either, the explicit option takes precedence.
137
138
  ``` ruby
138
139
 
139
140
  def setup_collection
141
+ # 1. Define collection level field information
140
142
  BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = {
141
143
  '336' => ['Image'],
142
144
  '852' => ['East Asian Library'],
@@ -144,11 +146,27 @@ def setup_collection
144
146
  '982' => ['Pre 1912 Chinese Materials - short name', 'Pre 1912 Chinese Materials - long name'],
145
147
  '991' => []
146
148
  }
147
-
149
+
150
+ # 2. A flag to include a pre-defined 035 formated in "(980__$a)mms_id",
151
+ # the default value is 'false'
148
152
  # BerkeleyLibrary::TIND::Mapping::AlmaBase.is_035_from_mms_id = true
149
153
 
150
- # Flag on getting Alma record using Barcode
151
- BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = true
154
+ # 3. A flag on getting Alma record using Barcode, the defalut value is 'false'
155
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = true
156
+
157
+ # 4. Define a list of origin tags from an Alma record.
158
+ # Only those related fields (including 880 fields) will be mapped to a TIND record.
159
+ # The default value is []. '001', '008' will be included by default, no need to be listed here.
160
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags = %w[256]
161
+
162
+ # 5. Define a list of origin tags from an Alma record which will be excluded during mapping.
163
+ # The default value is []
164
+ # 1) When the list includes an 880 tag, all 880 fields will be excluded
165
+ # 2) When the list has no 880 tag, only related 880 fields will be excludded
166
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags = %w[245 700]
167
+
168
+ # 6. Not allow to define both #5 and #6. Returning empty fields when defining both #5 and #6
169
+
152
170
  end
153
171
  ```
154
172
 
@@ -204,3 +222,29 @@ alma_tind = BerkeleyLibrary::TIND::Mapping::AlmaMultipleTIND.new(id)
204
222
  tind_record_1 = alma_tind.record(additional_tind_fields_1)
205
223
  tind_record_2 = alma_tind.record(additional_tind_fields_2)
206
224
  ```
225
+
226
+ 5. Updating TIND record with TindRecordUtil : 1) add/update subfields to one-occurrenced field; 2) remove fields.
227
+
228
+ ``` ruby
229
+ # 5.1 This is an example hash for updating/adding subfields.
230
+ tag_subfield_hash = { '245' => { 'b' => 'subtitle', 'a' => 'title' }, '336' => { 'a' => 'Audio' }, '246' => {'a' => nil}}
231
+
232
+ # if 245__$b existed, it will be replaced it with 'subtitle';
233
+ # otherwise, adding a new 245__$b subfield with value 'subtile';
234
+ # '246' => {'a' => nil}, since value is nil, it won't add/update 246__$a
235
+
236
+ # 5.2 This is an example array of removing fields.
237
+ fields_removal_list = [%w[856 4 1] %w[260 _ _]]
238
+
239
+ # Each item includes field information: [tag, indicator1, indictor2].
240
+ # if indicator is empty, using '_'
241
+
242
+ # How to use it:
243
+ # a. add/update subfields of existed fields in a TIND Marc record:
244
+ new_record = BerkeleyLibrary::TIND::Mapping::TindRecordUtil.update_record(record, tag_subfield_hash)
245
+ # b. remove a list of fields in a TIND Marc record:
246
+ new_record = BerkeleyLibrary::TIND::Mapping::TindRecordUtil.update_record(record, nil, fields_removal_list)
247
+ # c. both a. and b. :
248
+ new_record = BerkeleyLibrary::TIND::Mapping::TindRecordUtil.update_record(record, tag_subfield_hash, fields_removal_list)
249
+
250
+ ```
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.homepage = BerkeleyLibrary::TIND::ModuleInfo::HOMEPAGE
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0")
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
20
  spec.require_paths = ['lib']
22
21
  spec.executables << 'tind-export'
23
22
 
@@ -26,12 +25,12 @@ Gem::Specification.new do |spec|
26
25
  spec.add_dependency 'berkeley_library-alma', '~> 0.0.1'
27
26
  spec.add_dependency 'berkeley_library-logging', '~> 0.2'
28
27
  spec.add_dependency 'berkeley_library-marc', '~> 0.3.0', '>= 0.3.1'
29
- spec.add_dependency 'berkeley_library-util', '~> 0.1'
28
+ spec.add_dependency 'berkeley_library-util', '~> 0.1', '>= 0.1.2'
30
29
  spec.add_dependency 'ice_nine', '~> 0.11'
31
30
  spec.add_dependency 'marc', '~> 1.0'
32
31
  spec.add_dependency 'rchardet', '~> 1.8'
33
32
  spec.add_dependency 'rest-client', '~> 2.1'
34
- spec.add_dependency 'rubyzip', '~> 2.3'
33
+ spec.add_dependency 'rubyzip', '~> 2.3', '< 3.0'
35
34
  spec.add_dependency 'typesafe_enum', '~> 0.3'
36
35
 
37
36
  spec.add_development_dependency 'bundle-audit', '~> 0.1'
@@ -67,12 +67,10 @@ module BerkeleyLibrary
67
67
 
68
68
  def header_cell_style_for(col_index)
69
69
  @header_cell_styles ||= []
70
- @header_cell_styles[col_index] ||= begin
71
- find_or_create_cell_style(
72
- color: color_for(col_index),
73
- font_weight: 'bold'
74
- )
75
- end
70
+ @header_cell_styles[col_index] ||= find_or_create_cell_style(
71
+ color: color_for(col_index),
72
+ font_weight: 'bold'
73
+ )
76
74
  end
77
75
 
78
76
  def find_or_create_cell_style(color:, font_weight: nil, wrap: false)
@@ -9,11 +9,16 @@ module BerkeleyLibrary
9
9
  @collection_parameter_hash = {}
10
10
  @is_barcode = false
11
11
  @is_035_from_mms_id = false
12
+ @including_origin_tags = []
13
+ @excluding_origin_tags = []
12
14
 
13
15
  class << self
14
16
  attr_accessor :collection_parameter_hash
15
17
  attr_accessor :is_barcode
16
18
  attr_accessor :is_035_from_mms_id
19
+ attr_accessor :including_origin_tags
20
+ attr_accessor :excluding_origin_tags
21
+
17
22
  end
18
23
 
19
24
  # id can be:
@@ -74,6 +79,8 @@ module BerkeleyLibrary
74
79
  end
75
80
 
76
81
  def tind_record(id, marc_record, datafields)
82
+ return nil unless Util.collection_config_correct?
83
+
77
84
  tindmarc = TindMarc.new(marc_record)
78
85
  # get all derived tind_fields: 1) from collection information; 2) from id
79
86
  mms_id = tindmarc.field_catalog.mms_id
@@ -1,39 +1,39 @@
1
- tag_origin,tag_destination,subfield_single_from,subfield_single_to,subfield_combined_from_1,subfield_combined_to_1,symbol_1 ,subfield_combined_from_2,subfield_combined_to_2,symbol_2,subfield_combined_from_3,subfield_combined_to_3,symbol_3,New_indecator,Position_from,Position_to,Map_if_no_this_tag_existed,Map_if_no_this_tag_subfield_existed, Keep_one_if_multiple_available
2
- 100,700,"6,e","6,e","a,b,c,d,q",a,,,,,,,,"1,_",,,,,
3
- 110,710,"6,e","6,e","a,b",a,,,,,,,,"2,_",,,,,
4
- 111,711,6,6,"a,c,d,e,f,n,p,t",a,,,,,,,,"_,_",,,,,
5
- 242,246,6,6,"a,b,p,n",a,,,,,,,,,,,,,
6
- 245,245,"6,a","6,a","n,p",p,,,,,"b,f,k",b,,"_,_",,,,,
7
- 246,246,6,6,"a,b,p,n",a,,,,,,,,"_,_",,,,,
8
- 250,250,"6,a","6,a",,,,,,,,,,"_,_",,,,,
9
- 255,255,"6,a,b,c","6,a,b,c",,,,,,,,,,"_,_",,,,,
10
- 260,260,"6,a,b,c","6,a,b,c",,,,,,,,,,"_,_",,,,,
11
- 264,260,"6,a,b,c","6,a,b,c",,,,,,,,,,"_,_",,,260,,1
12
- 300,300,"6,b,c","6,b,c","3,a",a,,,,,,,,"_,_",,,,,
13
- 351,505,6,6,"a,b",a,,,,,,,,"_,_",,,,,
14
- 490,490,6,6,"a,v",a,,,,,,,,"_,_",,,,,
15
- 500,500,"6,a","6,a",,,,,,,,,,"_,_",,,,,
16
- 502,502,6,6,"a,b,c,d,g,o",a,,,,,,,,"_,_",,,,,
17
- 505,505,6,6,"a,g,r,t",a,,,,,,,,"_,_",,,,,
18
- 507,255,"6,a","6,a",,,,,,,,,,"_,_",,,,255__a,
19
- 520,520,"6,a","6,a",,,,,,,,,,"_,_",,,,,
20
- 522,522,"6,a","6,a",,,,,,,,,,"_,_",,,,,
21
- 524,524,"6,a","6,a",,,,,,,,,,"_,_",,,,,
22
- 536,536,"6,a","6,a",,,,,,,,,,"_,_",,,,,
23
- 541,541,6,6,"c,a,d",a,,,,,,,,"_,_",,,,,
24
- 545,545,"6,a","6,a",,,,,,,,,,"_,_",,,,,
25
- 546,546,"6,a","6,a",,,,,,,,,,"_,_",,,,,
26
- 600,600,6,6,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
27
- 610,610,6,6,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
28
- 611,611,6,6,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
29
- 630,630,6,6,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
30
- 650,650,6,6,"a,b,c",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
31
- 651,651,6,6,a,a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
32
- 655,655,"6,2","6,2",a,a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
33
- 700,700,"6,e","6,e","a,b,c,d,q",a,,,,,,,,"1,_",,,,,
34
- 710,710,"6,e","6,e","a,b",a,,,,,,,,"2,_",,,,,
35
- 711,711,6,6,"a,c,d,e,f,n,p,t",a,,,,,,,,"_,_",,,,,
36
- 720,700,"6,a,e","6,a,e",,,,,,,,,,"1,_",,,,,
37
- 752,651,6,6,,,,"a,b,c,d,f,g",a,a--a,,,,"_,_",,,,,
38
- 773,773,"6,t,j,k,o","6,t,j,k,o",,,,,,,,,,"_,_",,,,,
39
- 907,901,"6,a","6,m",,,,,,,,,,"_,_",,,,,
1
+ tag_origin,tag_destination,subfield_single_from,subfield_single_to,order,subfield_combined_from_1,subfield_combined_to_1,symbol_1 ,subfield_combined_from_2,subfield_combined_to_2,symbol_2,subfield_combined_from_3,subfield_combined_to_3,symbol_3,New_indecator,Position_from,Position_to,Map_if_no_this_tag_existed,Map_if_no_this_tag_subfield_existed, Keep_one_if_multiple_available
2
+ 100,700,"6,e","6,e","6,a,e","a,b,c,d,q",a,,,,,,,,"1,_",,,,,
3
+ 110,710,"6,e","6,e","6,a,e","a,b",a,,,,,,,,"2,_",,,,,
4
+ 111,711,6,6,,"a,c,d,e,f,n,p,t",a,,,,,,,,"_,_",,,,,
5
+ 242,246,6,6,,"a,b,p,n",a,,,,,,,,,,,,,
6
+ 245,245,"6,a","6,a","6,a,b,p","n,p",p,,,,,"b,f,k",b,,"_,_",,,,,
7
+ 246,246,6,6,,"a,b,p,n",a,,,,,,,,"_,_",,,,,
8
+ 250,250,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
9
+ 255,255,"6,a,b,c","6,a,b,c",,,,,,,,,,,"_,_",,,,,
10
+ 260,260,"6,a,b,c","6,a,b,c",,,,,,,,,,,"_,_",,,,,
11
+ 264,260,"6,a,b,c","6,a,b,c",,,,,,,,,,,"_,_",,,260,,1
12
+ 300,300,"6,b,c","6,b,c","6,a,b,c","3,a",a,,,,,,,,"_,_",,,,,
13
+ 351,505,6,6,,"a,b",a,,,,,,,,"_,_",,,,,
14
+ 490,490,6,6,,"a,v",a,,,,,,,,"_,_",,,,,
15
+ 500,500,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
16
+ 502,502,6,6,,"a,b,c,d,g,o",a,,,,,,,,"_,_",,,,,
17
+ 505,505,6,6,,"a,g,r,t",a,,,,,,,,"_,_",,,,,
18
+ 507,255,"6,a","6,a",,,,,,,,,,,"_,_",,,,255__a,
19
+ 520,520,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
20
+ 522,522,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
21
+ 524,524,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
22
+ 536,536,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
23
+ 541,541,6,6,,"c,a,d",a,,,,,,,,"_,_",,,,,
24
+ 545,545,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
25
+ 546,546,"6,a","6,a",,,,,,,,,,,"_,_",,,,,
26
+ 600,600,6,6,,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
27
+ 610,610,6,6,,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
28
+ 611,611,6,6,,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
29
+ 630,630,6,6,,"a,b,c,d,f,j,k,l,m,n,o,p,q,r,s,t",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
30
+ 650,650,6,6,,"a,b,c",a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
31
+ 651,651,6,6,,a,a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
32
+ 655,655,"6,2","6,2",,a,a,,"x,y,z,v",a,a--a,,,,"_,_",,,,,
33
+ 700,700,"6,e","6,e","6,a,e","a,b,c,d,q",a,,,,,,,,"1,_",,,,,
34
+ 710,710,"6,e","6,e","6,a,e","a,b",a,,,,,,,,"2,_",,,,,
35
+ 711,711,6,6,,"a,c,d,e,f,n,p,t",a,,,,,,,,"_,_",,,,,
36
+ 720,700,"6,a,e","6,a,e",,,,,,,,,,,"1,_",,,,,
37
+ 752,651,6,6,,,,,"a,b,c,d,f,g",a,a--a,,,,"_,_",,,,,
38
+ 773,773,"6,t,j,k,o","6,t,j,k,o",,,,,,,,,,,"_,_",,,,,
39
+ 907,901,"6,a","6,m",,,,,,,,,,,"_,_",,,,,
@@ -47,7 +47,8 @@ module BerkeleyLibrary
47
47
  def prepare_catalog(record)
48
48
  clean_fields = clean_subfields(record.fields)
49
49
  check_abnormal_formated_subfield6(clean_fields)
50
- allocate_fields(clean_fields)
50
+ final_fields_to_map = fields_to_map(clean_fields)
51
+ allocate_fields(final_fields_to_map)
51
52
  remove_fields_with_subject_fast
52
53
  end
53
54
 
@@ -115,16 +116,6 @@ module BerkeleyLibrary
115
116
  # If tag is listed in csv_mapper.one_occurrence_tags
116
117
  # Check pre_existed field of this tag
117
118
  # make sure to keep the first datafield for an one_occurrence_tag defined in csv mapping file
118
- # def no_pre_existed_field?(tag)
119
- # # no one-occurrence defined in csv
120
- # return true unless one_occurrence_tags.include? tag
121
-
122
- # # Checking the exsisting regular fields include the one-occurrence field defined in the csv
123
- # return false if @alma_field_tags.compact.include? tag
124
-
125
- # true
126
- # end
127
-
128
119
  def no_pre_existed_field?(tag)
129
120
  # no one-occurrence defined in csv
130
121
  return true unless one_occurrence_tags.include? tag
@@ -1,7 +1,10 @@
1
+ require 'berkeley_library/tind/mapping/alma_base'
2
+
1
3
  module BerkeleyLibrary
2
4
  module TIND
3
5
  module Mapping
4
6
  module FieldCatalogUtil
7
+ include AlmaBase
5
8
 
6
9
  # Excluding fields: subfield2 = 'fast' and tag or refered tag(880 fields) started with '6':
7
10
  def exluding_fields_with_fast_subject(fields)
@@ -17,14 +20,56 @@ module BerkeleyLibrary
17
20
 
18
21
  rule = rules[Util.tag_symbol(tag)]
19
22
 
20
- assing_field(rule, f, datafields_hash)
23
+ assign_field(rule, f, datafields_hash)
21
24
  end
22
25
 
23
26
  datafields_hash
24
27
  end
25
28
 
29
+ # Defining a list of fields from Alma to be mapped to TIND fields based on
30
+ # collection configuration:
31
+ # 1) BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags
32
+ # 2) BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags
33
+ def fields_to_map(fields)
34
+ including_defined = !BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags.empty?
35
+ excluding_defined = !BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags.empty?
36
+ return [] if including_defined && excluding_defined # not allow to define both including and excluding tags
37
+ return fields unless including_defined || excluding_defined # Neither including nor excluding tags are defined
38
+ return fields_included(fields) if including_defined # including tags defined
39
+ return fields_exclued(fields) if excluding_defined # excluding tags defined
40
+ end
41
+
26
42
  private
27
43
 
44
+ def fields_included(fields)
45
+ fields.select { |f| inclduing?(f) }
46
+ end
47
+
48
+ def inclduing?(f)
49
+ return true if %w[001 008].include? f.tag # always keeping 001, 008 field since it include almid
50
+
51
+ tag = origin_mapping_tag(f)
52
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags.include? tag
53
+ end
54
+
55
+ def fields_exclued(fields)
56
+ new_fields = []
57
+ exclude_tags = BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags
58
+ fields.each do |f|
59
+ tag = tag(f, exclude_tags)
60
+ new_fields << f unless exclude_tags.include? tag
61
+ end
62
+ new_fields
63
+ end
64
+
65
+ # 1. exluding tags have '880' : all 880 fields will be excluded
66
+ # 2. excluding tags have no '880', then excluding 880 fields whoses refered tag located in excluding tags
67
+ def tag(field, exclude_tags)
68
+ return field.tag if exclude_tags.include? '880' # Case: excluding all 880 fields
69
+
70
+ origin_mapping_tag(field)
71
+ end
72
+
28
73
  def excluding_field?(f)
29
74
  return false unless field_6xx?(f)
30
75
  return false unless subfield2_fast(f)
@@ -46,10 +91,11 @@ module BerkeleyLibrary
46
91
  end
47
92
 
48
93
  # f is either from field whose tag having a match in csv mapping file - 'from tag' column
49
- def assing_field(rule, f, datafields_hash)
94
+ def assign_field(rule, f, datafields_hash)
50
95
  if rule.pre_existed_tag then datafields_hash[:pre_tag] << f
51
96
  elsif rule.pre_existed_tag_subfield then datafields_hash[:pre_tag_subfield] << f
52
- else datafields_hash[:normal] << f
97
+ else
98
+ datafields_hash[:normal] << f
53
99
  end
54
100
  end
55
101
 
@@ -26,6 +26,7 @@ module BerkeleyLibrary
26
26
  attr_reader :single_rule_hash
27
27
  attr_reader :single_rule_subfield_excluded_hash
28
28
  attr_reader :combined_rules
29
+ attr_reader :subfields_order
29
30
 
30
31
  def initialize(row)
31
32
  @tag_origin = row[:tag_origin]
@@ -36,6 +37,7 @@ module BerkeleyLibrary
36
37
  @single_rule_hash = single_map_dic(row[:subfield_single_from], row[:subfield_single_to])
37
38
  @single_rule_subfield_excluded_hash = single_map_subfield_excluded_dic
38
39
  @combined_rules = rules_with_same_subfield_name(row)
40
+ @subfields_order = order(row[:order])
39
41
  end
40
42
 
41
43
  # 1. Return an array of combined rules, an item in the array
@@ -51,6 +53,10 @@ module BerkeleyLibrary
51
53
 
52
54
  private
53
55
 
56
+ def order(str)
57
+ str.nil? ? nil : str.split(',')
58
+ end
59
+
54
60
  # return an array of tag and subfield name, example '255__a' => ['255','a']
55
61
  def existed_tag_subfield(str)
56
62
  str.nil? ? nil : str.split('__')
@@ -39,6 +39,7 @@ module BerkeleyLibrary
39
39
  @single_mapping = nil
40
40
  @ready_to_mapping = ready_to_mapping?
41
41
 
42
+ @codes = subfield_codes(@from_datafield)
42
43
  @to_subfields = all_subfields
43
44
  end
44
45
 
@@ -82,7 +83,18 @@ module BerkeleyLibrary
82
83
  end
83
84
 
84
85
  def all_subfields
85
- @ready_to_mapping ? (subfields_from_single_map + subfields_from_combined_map) : []
86
+ return [] unless @ready_to_mapping
87
+
88
+ subfields = subfields_from_single_map + subfields_from_combined_map
89
+ codes = @mapping_rule.subfields_order || @codes
90
+
91
+ return subfields unless subfields.length > 1
92
+
93
+ Util.order_subfields(subfields, codes)
94
+ end
95
+
96
+ def subfield_codes(f)
97
+ f.subfields.map(&:code).uniq
86
98
  end
87
99
 
88
100
  # 1.subfields mapped with single rule, mapping one subfield to another subfield