berkeley_library-tind 0.4.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +16 -4
  3. data/.gitignore +3 -0
  4. data/.idea/inspectionProfiles/Project_Default.xml +10 -0
  5. data/.idea/tind.iml +24 -22
  6. data/CHANGES.md +24 -0
  7. data/README.md +136 -3
  8. data/berkeley_library-tind.gemspec +2 -0
  9. data/bin/alma-multiple-tind +50 -0
  10. data/bin/alma-single-tind +48 -0
  11. data/bin/save_tind_records +80 -0
  12. data/bin/tind-marc +73 -0
  13. data/lib/berkeley_library/tind/mapping/additional_datafield_process.rb +128 -0
  14. data/lib/berkeley_library/tind/mapping/alma.rb +42 -0
  15. data/lib/berkeley_library/tind/mapping/alma_base.rb +101 -0
  16. data/lib/berkeley_library/tind/mapping/alma_multiple_tind.rb +31 -0
  17. data/lib/berkeley_library/tind/mapping/alma_single_tind.rb +28 -0
  18. data/lib/berkeley_library/tind/mapping/config.rb +44 -0
  19. data/lib/berkeley_library/tind/mapping/csv_mapper.rb +35 -0
  20. data/lib/berkeley_library/tind/mapping/csv_multiple_mapper.rb +41 -0
  21. data/lib/berkeley_library/tind/mapping/data/one_to_multiple_mapping.csv +4 -0
  22. data/lib/berkeley_library/tind/mapping/data/one_to_one_mapping.csv +39 -0
  23. data/lib/berkeley_library/tind/mapping/external_tind_field.rb +103 -0
  24. data/lib/berkeley_library/tind/mapping/field_catalog.rb +146 -0
  25. data/lib/berkeley_library/tind/mapping/field_catalog_util.rb +59 -0
  26. data/lib/berkeley_library/tind/mapping/match_tind_field.rb +77 -0
  27. data/lib/berkeley_library/tind/mapping/misc.rb +69 -0
  28. data/lib/berkeley_library/tind/mapping/multiple_rule.rb +36 -0
  29. data/lib/berkeley_library/tind/mapping/single_rule.rb +143 -0
  30. data/lib/berkeley_library/tind/mapping/tind_control_subfield.rb +59 -0
  31. data/lib/berkeley_library/tind/mapping/tind_field.rb +49 -0
  32. data/lib/berkeley_library/tind/mapping/tind_field_from_leader.rb +27 -0
  33. data/lib/berkeley_library/tind/mapping/tind_field_from_multiple_map.rb +59 -0
  34. data/lib/berkeley_library/tind/mapping/tind_field_from_single_map.rb +170 -0
  35. data/lib/berkeley_library/tind/mapping/tind_field_util.rb +112 -0
  36. data/lib/berkeley_library/tind/mapping/tind_marc.rb +134 -0
  37. data/lib/berkeley_library/tind/mapping/tind_subfield_util.rb +154 -0
  38. data/lib/berkeley_library/tind/mapping/util.rb +117 -0
  39. data/lib/berkeley_library/tind/mapping.rb +1 -0
  40. data/lib/berkeley_library/tind/marc/xml_builder.rb +70 -0
  41. data/lib/berkeley_library/tind/marc/xml_reader.rb +22 -16
  42. data/lib/berkeley_library/tind/marc/xml_writer.rb +152 -0
  43. data/lib/berkeley_library/tind/module_info.rb +1 -1
  44. data/lib/berkeley_library/util/files.rb +38 -0
  45. data/spec/berkeley_library/tind/mapping/additional_datafield_process_spec.rb +35 -0
  46. data/spec/berkeley_library/tind/mapping/alma_base_spec.rb +115 -0
  47. data/spec/berkeley_library/tind/mapping/alma_multiple_tind_spec.rb +20 -0
  48. data/spec/berkeley_library/tind/mapping/alma_single_tind_spec.rb +87 -0
  49. data/spec/berkeley_library/tind/mapping/alma_spec.rb +28 -0
  50. data/spec/berkeley_library/tind/mapping/config_spec.rb +19 -0
  51. data/spec/berkeley_library/tind/mapping/csv_mapper_spec.rb +27 -0
  52. data/spec/berkeley_library/tind/mapping/csv_multiple_mapper_spec.rb +27 -0
  53. data/spec/berkeley_library/tind/mapping/external_tind_field_spec.rb +45 -0
  54. data/spec/berkeley_library/tind/mapping/field_catalog_spec.rb +78 -0
  55. data/spec/berkeley_library/tind/mapping/field_catalog_util_spec.rb +57 -0
  56. data/spec/berkeley_library/tind/mapping/match_tind_field_spec.rb +25 -0
  57. data/spec/berkeley_library/tind/mapping/misc_spec.rb +51 -0
  58. data/spec/berkeley_library/tind/mapping/multiple_rule_spec.rb +44 -0
  59. data/spec/berkeley_library/tind/mapping/single_rule_spec.rb +52 -0
  60. data/spec/berkeley_library/tind/mapping/tind_control_subfield_spec.rb +96 -0
  61. data/spec/berkeley_library/tind/mapping/tind_field_from_leader_spec.rb +21 -0
  62. data/spec/berkeley_library/tind/mapping/tind_field_from_multiple_map_spec.rb +31 -0
  63. data/spec/berkeley_library/tind/mapping/tind_field_from_single_map_spec.rb +150 -0
  64. data/spec/berkeley_library/tind/mapping/tind_field_spec.rb +60 -0
  65. data/spec/berkeley_library/tind/mapping/tind_field_util_spec.rb +68 -0
  66. data/spec/berkeley_library/tind/mapping/tind_marc_spec.rb +88 -0
  67. data/spec/berkeley_library/tind/mapping/tind_subfield_util_spec.rb +48 -0
  68. data/spec/berkeley_library/tind/mapping/util_spec.rb +56 -0
  69. data/spec/berkeley_library/tind/marc/xml_reader_spec.rb +22 -0
  70. data/spec/berkeley_library/tind/marc/xml_writer_spec.rb +218 -0
  71. data/spec/data/issue-4.xml +157 -0
  72. data/spec/data/mapping/991032333019706532-sru.xml +216 -0
  73. data/spec/data/mapping/one_to_multiple_mapping.csv +4 -0
  74. data/spec/data/mapping/one_to_one_mapping.csv +39 -0
  75. data/spec/data/mapping/record.xml +263 -0
  76. data/spec/data/mapping/record_not_qualified.xml +36 -0
  77. data/spec/data/new-records.xml +46 -0
  78. metadata +128 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbfd8d5b1299063dc4986ae86860bcd050d64f4d22d1592f6373f8cf9c661fd9
4
- data.tar.gz: fefc0570733f3116aae9fe5377773d7fb327ba4f71ccfa15399bf5dae8a67ac5
3
+ metadata.gz: ade606682d0d814a4debfbe0be2a6741ae72977d710511d5df70118569dea764
4
+ data.tar.gz: 2da4f7cd4b7f0c1cf6f8dcf9bf3346d89599e9130f28a185cb0cab0a37a39d3d
5
5
  SHA512:
6
- metadata.gz: 43a3e9e88ddacc0c37619b49b223a6fe4967d2bd13fb7a493514a72e7903cd0f54bfb92c052e347e4aebbf5cd33106410f39dff81936f606d25df21e7dc1f000
7
- data.tar.gz: a0295b58cb6139205ccfc7e381f1c0111d8e125ab55b5d1109d467fee59b5a80436e06b2c6a77c1c11c6e38962ee19f91695640800658a00ba054608be423d56
6
+ metadata.gz: ed708269e8c628616c89643c49cb3394401febf8f9a0f4defde88abad17a8ac2f5b43663345cd0513aa2e7b02e41fb3475446f55aa7ad394aa83ad62ae114565
7
+ data.tar.gz: b4f851305ad936b9f7cb46c8a521358cdfff34f51aebfb6d121481545777476af8adce6c3b8c0042aeaeca2ee00a7d1826f955f46ee5ad1f11361c7ed1843b72
@@ -1,5 +1,5 @@
1
1
  name: Build
2
- on: [ push, pull_request ]
2
+ on: [ push, pull_request, workflow_dispatch ]
3
3
  jobs:
4
4
  test:
5
5
  strategy:
@@ -10,9 +10,21 @@ jobs:
10
10
  runs-on: ${{ matrix.os }}
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v2
14
- - uses: ruby/setup-ruby@v1
13
+ - name: Check out repository
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
15
18
  with:
16
19
  ruby-version: ${{ matrix.ruby }}
17
20
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18
- - run: bundle exec rake
21
+
22
+ - name: Run checks
23
+ run: bundle exec rake
24
+
25
+ - name: Upload artifacts
26
+ if: ${{ always() }}
27
+ uses: actions/upload-artifact@v3
28
+ with:
29
+ name: artifacts
30
+ path: artifacts/**
data/.gitignore CHANGED
@@ -7,6 +7,9 @@
7
7
  # Additional IDEA/RubyMine ignores
8
8
  .idea/.rakeTasks
9
9
 
10
+ # Visual Studio Code ignores
11
+ .vscode
12
+
10
13
  # Don't commit Gemfile.lock for libraries
11
14
  Gemfile.lock
12
15
 
@@ -10,6 +10,14 @@
10
10
  <inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
11
11
  <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
12
12
  <inspection_tool class="RubyCaseWithoutElseBlockInspection" enabled="false" level="WARNING" enabled_by_default="false" />
13
+ <inspection_tool class="RubyClassMethodNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
14
+ <inspection_tool class="RubyClassModuleNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
15
+ <inspection_tool class="RubyClassVariableNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
16
+ <inspection_tool class="RubyConstantNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
17
+ <inspection_tool class="RubyGlobalVariableNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
18
+ <inspection_tool class="RubyInstanceMethodNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
19
+ <inspection_tool class="RubyInstanceVariableNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
20
+ <inspection_tool class="RubyLocalVariableNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
13
21
  <inspection_tool class="RubyMismatchedArgumentType" enabled="true" level="WARNING" enabled_by_default="true">
14
22
  <option name="myCheckNilability" value="false" />
15
23
  </inspection_tool>
@@ -28,6 +36,8 @@
28
36
  <inspection_tool class="RubyMismatchedVariableType" enabled="true" level="WARNING" enabled_by_default="true">
29
37
  <option name="myCheckNilability" value="false" />
30
38
  </inspection_tool>
39
+ <inspection_tool class="RubyNilAnalysis" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
40
+ <inspection_tool class="RubyParameterNamingConvention" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
31
41
  <inspection_tool class="RubyStringKeysInHashInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
32
42
  <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
33
43
  <option name="processCode" value="true" />
data/.idea/tind.iml CHANGED
@@ -9,13 +9,14 @@
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 (v6.1.4.4, RVM: ruby-2.7.5) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="actionview (v6.1.4.4, RVM: ruby-2.7.5) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4.4, RVM: ruby-2.7.5) [gem]" level="application" />
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
15
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, 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-logging (v0.2.5, 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" />
19
20
  <orderEntry type="library" scope="PROVIDED" name="berkeley_library-marc (v0.3.1, RVM: ruby-2.7.5) [gem]" level="application" />
20
21
  <orderEntry type="library" scope="PROVIDED" name="berkeley_library-util (v0.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
21
22
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -25,28 +26,29 @@
25
26
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
26
27
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter_rspec (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
27
28
  <orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, RVM: ruby-2.7.5) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, RVM: ruby-2.7.5) [gem]" level="application" />
29
30
  <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.5, RVM: ruby-2.7.5) [gem]" level="application" />
30
31
  <orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
31
32
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.5) [gem]" level="application" />
32
33
  <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
33
34
  <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, RVM: ruby-2.7.5) [gem]" level="application" />
34
35
  <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.7.6, RVM: ruby-2.7.5) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="equivalent-xml (v0.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
35
37
  <orderEntry type="library" scope="PROVIDED" name="erubi (v1.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
36
38
  <orderEntry type="library" scope="PROVIDED" name="hashdiff (v1.0.1, RVM: ruby-2.7.5) [gem]" level="application" />
37
39
  <orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.7.5) [gem]" level="application" />
38
40
  <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.11, 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
42
  <orderEntry type="library" scope="PROVIDED" name="ice_nine (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="lograge (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="loofah (v2.13.0, RVM: ruby-2.7.5) [gem]" level="application" />
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" />
43
45
  <orderEntry type="library" scope="PROVIDED" name="marc (v1.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
44
46
  <orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
45
47
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
46
48
  <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, RVM: ruby-2.7.5) [gem]" level="application" />
47
49
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-2.7.5) [gem]" level="application" />
48
50
  <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.1, 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" />
50
52
  <orderEntry type="library" scope="PROVIDED" name="oj (v3.13.11, RVM: ruby-2.7.5) [gem]" level="application" />
51
53
  <orderEntry type="library" scope="PROVIDED" name="ougai (v1.9.1, RVM: ruby-2.7.5) [gem]" level="application" />
52
54
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -58,25 +60,25 @@
58
60
  <orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
59
61
  <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, RVM: ruby-2.7.5) [gem]" level="application" />
60
62
  <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
61
- <orderEntry type="library" scope="PROVIDED" name="railties (v6.1.4.4, 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
64
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
63
65
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
64
66
  <orderEntry type="library" scope="PROVIDED" name="rchardet (v1.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
65
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.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" />
66
68
  <orderEntry type="library" scope="PROVIDED" name="request_store (v1.5.1, RVM: ruby-2.7.5) [gem]" level="application" />
67
69
  <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
68
70
  <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.5) [gem]" level="application" />
69
71
  <orderEntry type="library" scope="PROVIDED" name="roo (v2.8.3, RVM: ruby-2.7.5) [gem]" level="application" />
70
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
71
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, RVM: ruby-2.7.5) [gem]" level="application" />
72
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.2, RVM: ruby-2.7.5) [gem]" level="application" />
73
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, RVM: ruby-2.7.5) [gem]" level="application" />
74
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.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" />
75
77
  <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
76
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.1, 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" />
77
79
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rake (v0.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
78
80
  <orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v2.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
79
- <orderEntry type="library" scope="PROVIDED" name="ruby-marc-spec (v0.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
81
+ <orderEntry type="library" scope="PROVIDED" name="ruby-marc-spec (v0.1.3, RVM: ruby-2.7.5) [gem]" level="application" />
80
82
  <orderEntry type="library" scope="PROVIDED" name="ruby-prof (v0.17.0, RVM: ruby-2.7.5) [gem]" level="application" />
81
83
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
82
84
  <orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -84,15 +86,15 @@
84
86
  <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, RVM: ruby-2.7.5) [gem]" level="application" />
85
87
  <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-2.7.5) [gem]" level="application" />
86
88
  <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
87
- <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.3, RVM: ruby-2.7.5) [gem]" level="application" />
89
+ <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
88
90
  <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.5) [gem]" level="application" />
89
91
  <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.0, RVM: ruby-2.7.5) [gem]" level="application" />
90
92
  <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
91
93
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
92
- <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8, 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" />
93
95
  <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
94
96
  <orderEntry type="library" scope="PROVIDED" name="webmock (v3.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
95
- <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.3, 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" />
96
98
  </component>
97
99
  <component name="RModuleSettingsStorage">
98
100
  <LOAD_PATH number="2" string0="$MODULE_DIR$/lib" string1="$MODULE_DIR$/spec" />
@@ -109,7 +111,7 @@
109
111
  </RakeTaskImpl>
110
112
  <RakeTaskImpl description="Run all specs in spec directory, with coverage" fullCommand="coverage" id="coverage" />
111
113
  <RakeTaskImpl description="Run tests, check test coverage, check code style, check for vulnerabilities, build gem" fullCommand="default" id="default" />
112
- <RakeTaskImpl description="Build berkeley_library-tind.gemspec as berkeley_library-tind-0.4.3.gem" fullCommand="gem" id="gem" />
114
+ <RakeTaskImpl description="Build berkeley_library-tind.gemspec as berkeley_library-tind-0.6.0.gem" fullCommand="gem" id="gem" />
113
115
  <RakeTaskImpl description="Run RuboCop with auto-correct, and output results to console" fullCommand="ra" id="ra" />
114
116
  <RakeTaskImpl description="Run rubocop with HTML output" fullCommand="rubocop" id="rubocop" />
115
117
  <RakeTaskImpl id="rubocop">
data/CHANGES.md CHANGED
@@ -1,3 +1,27 @@
1
+ # 0.6.0 (2023-04-06)
2
+
3
+ - Adds `BerkeleyLibrary::TIND::Mapping` module to map MARC records from Alma to TIND.
4
+ - `BerkeleyLibrary::TIND::MARC::XMLWriter` now assumes that any object that response to `:write`
5
+ and `:close` is suffiently `IO`-like to write to.
6
+
7
+ # 0.5.1 (2023-03-23)
8
+
9
+ - Fix an issue where `BerkeleyLibrary::TIND::MARC::XMLWriter` would drop fields with nonstandard tags (e.g. `FFT` fields)
10
+ and would group and sort fields by tag instead of preserving the original order.
11
+
12
+ # 0.5.0 (2022-01-17)
13
+
14
+ - Adds a class `BerkeleyLibrary::TIND::MARC::XMLWriter` to write MARCXML in the format expected by the TIND batch uploader:
15
+
16
+ - MARC leader is written to control field 000 as required by TIND
17
+ - control fields (including the leader) use `\` (0x5c), not space (0x32), for unspecified positional
18
+ values
19
+
20
+ In addition, a `nil` or empty MARC leader is not written at all.
21
+ - Modifies `BerkeleyLibrary::TIND::MARC::XMLReader` to take into account the same peculiarities:
22
+ control field 000 is read into the leader of the MARC record, and slashes in control field values
23
+ (including the leader) are replaced with spaces.
24
+
1
25
  # 0.4.3 (2022-01-26)
2
26
 
3
27
  - Pins `berkeley_library-marc` to version 0.3.x (0.3.1 or higher).
data/README.md CHANGED
@@ -1,10 +1,24 @@
1
1
  # BerkeleyLibrary::TIND
2
2
 
3
3
  [![Build Status](https://github.com/BerkeleyLibrary/tind/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/BerkeleyLibrary/tind/actions/workflows/build.yml)
4
- [![Gem Version](https://img.shields.io/gem/v/berkeley_library-tind.svg)](https://github.com/BerkeleyLibrary/tind/releases)
4
+ [![Gem Version](https://img.shields.io/gem/v/berkeley_library-tind.svg)](https://rubygems.org/gems/berkeley_library-tind)
5
5
 
6
6
  Utility gem for working with the TIND DA digital archive.
7
7
 
8
+ ## Installation
9
+
10
+ In your Gemfile:
11
+
12
+ ```ruby
13
+ gem 'berkeley_library-tind'
14
+ ```
15
+
16
+ In your code:
17
+
18
+ ```ruby
19
+ require 'berkeley_library/tind'
20
+ ```
21
+
8
22
  ## Configuration
9
23
 
10
24
  To access the TIND API, you will need to set:
@@ -16,7 +30,7 @@ To access the TIND API, you will need to set:
16
30
  it a "key", so that's the term we use here.)
17
31
 
18
32
  These can be set directly, via accessors in the `BerkeleyLibrary::TIND::Config` module;
19
- if they are not set, a value will be read from the environment, and if no
33
+ if they are not set, a value will be read from the environment, and if no
20
34
  value is present in the environment and Rails is loaded, from the Rails
21
35
  application configuration (`Rails.application.config`).
22
36
 
@@ -29,9 +43,18 @@ application configuration (`Rails.application.config`).
29
43
  object, but will always be returned as a `URI` object, and an invalid
30
44
  string setting will raise `URI::InvalidURIError`.
31
45
 
46
+ ### Alma configuration
47
+
48
+ When mapping Alma records to TIND (see below), this gem uses
49
+ [`berkeley_library-alma`](https://github.com/BerkeleyLibrary/alma) to load
50
+ Alma records. The scripts in the `bin` directory use the default Alma
51
+ configuration; see the `berkeley_library-alma`
52
+ [README](https://github.com/BerkeleyLibrary/alma#configuration) for
53
+ details.
54
+
32
55
  ## Command-line tool: `tind-export`
33
56
 
34
- The `tind-export` command allows you to list TIND collections, or to
57
+ The `tind-export` command allows you to list TIND collections, or to
35
58
  export a TIND collection from the command line. (If the gem is installed,
36
59
  `tind-export` should be in your `$PATH`. If you've cloned the gem source,
37
60
  you can invoke it with `bin/tind-export` from the project root directory.)
@@ -71,3 +94,113 @@ For the full list of options, type `tind-export --help`. Note that you can set
71
94
  the TIND base URL and API key either via the environment, as above, or as options
72
95
  passed to the `tind-export` command. If both an explicit option and an environment
73
96
  variable are set for either, the explicit option takes precedence.
97
+
98
+ ## Mapping MARC records from Alma to TIND
99
+
100
+ ### Transforming Class:
101
+
102
+ 1. BerkeleyLibrary::TIND::Mapping::AlmaSingleTIND (Transforming one Alma record => One TIND record)
103
+ 2. BerkeleyLibrary::TIND::Mapping::AlmaMultipleTIND (Transforming one Alma record => Multiple TIND records)
104
+
105
+ ### Source of TIND fields
106
+
107
+ 1. Mapped from an Alma record (automatically)
108
+
109
+ 2. Derived from collection information, mms_id, and date (automatically)
110
+
111
+ - 336$a
112
+ - 852$c
113
+ - 980$a
114
+ - 982$a,$b
115
+ - 991$a - (optional)
116
+ - 902$d
117
+ - 901$m
118
+ - 85641$u,$y
119
+
120
+ 3. Added at the time of transforming TIND record (fields of a collection or its record)
121
+
122
+ - FFT
123
+ - 035$a
124
+ - 998$a
125
+ - ...
126
+
127
+ ### Example
128
+
129
+ 1. Setup collection information
130
+
131
+ - 336: type of resource
132
+ - 852: collection's repository name
133
+ - 980: collection's 980 value
134
+ - 982: collection's short name and long name
135
+ - 991: collection' restricted name (optional)
136
+
137
+ ``` ruby
138
+
139
+ def setup_collection
140
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = {
141
+ '336' => ['Image'],
142
+ '852' => ['East Asian Library'],
143
+ '980' => ['pre_1912'],
144
+ '982' => ['Pre 1912 Chinese Materials - short name', 'Pre 1912 Chinese Materials - long name'],
145
+ '991' => []
146
+ }
147
+
148
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.is_035_from_mms_id = true
149
+
150
+ # Flag on getting Alma record using Barcode
151
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = true
152
+ end
153
+ ```
154
+
155
+ 2. Praparing additional fields
156
+
157
+ Adding field using:
158
+ - field methods from module: BerkeleyLibrary::TIND::Mapping::TindField
159
+ - Or the original method from Ruby Marc when field method found in above module
160
+ ::MARC::DataField.new(tag, indicator1, indicator, [code1, value1], [code2, value2] ...)
161
+
162
+ ```ruby
163
+
164
+ def additional_tind_fields_1
165
+ txt = 'v001_0064'
166
+ url = 'https://digitalassets.lib.berkeley.edu/pre1912ChineseMaterials/ucb/ready/991032333019706532/991032333019706532_v001_0064.jpg'
167
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
168
+
169
+ f = ::MARC::DataField.new('998', ' ', ' ', ['a', 'fake-value'])
170
+ [fft] << f
171
+ end
172
+
173
+ def additional_tind_fields_2
174
+ txt = 'v001_0065'
175
+ url = 'https://digitalassets.lib.berkeley.edu/pre1912ChineseMaterials/ucb/ready/991032333019706532/991032333019706532_v001_0065.jpg'
176
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
177
+ [fft]
178
+ end
179
+ ```
180
+
181
+ 3. Transforming one Alma record => One TIND record
182
+
183
+ ```ruby
184
+ setup_collection
185
+
186
+ # id can be 1)mms_id; 2)Millennium no ; or 3)Barcode
187
+ id = 'C084093187'
188
+
189
+ alma_tind = BerkeleyLibrary::TIND::Mapping::AlmaSingleTIND.new
190
+ tind_record = alma_tind.record(id, additional_tind_fields_1)
191
+ ```
192
+
193
+
194
+ 4. Or transforming one Alma record => Multiple TIND records
195
+
196
+ ``` ruby
197
+ setup_collection
198
+
199
+ # id can be 1) mms_id; 2) Millennium bib number; or 3) Item barcode
200
+ # id = '991085821143406532'
201
+ id = 'C084093187'
202
+
203
+ alma_tind = BerkeleyLibrary::TIND::Mapping::AlmaMultipleTIND.new(id)
204
+ tind_record_1 = alma_tind.record(additional_tind_fields_1)
205
+ tind_record_2 = alma_tind.record(additional_tind_fields_2)
206
+ ```
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.required_ruby_version = ruby_version
25
25
 
26
+ spec.add_dependency 'berkeley_library-alma', '~> 0.0.1'
26
27
  spec.add_dependency 'berkeley_library-logging', '~> 0.2'
27
28
  spec.add_dependency 'berkeley_library-marc', '~> 0.3.0', '>= 0.3.1'
28
29
  spec.add_dependency 'berkeley_library-util', '~> 0.1'
@@ -37,6 +38,7 @@ Gem::Specification.new do |spec|
37
38
  spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
38
39
  spec.add_development_dependency 'colorize', '~> 0.8'
39
40
  spec.add_development_dependency 'dotenv', '~> 2.7'
41
+ spec.add_development_dependency 'equivalent-xml', '~> 0.6'
40
42
  spec.add_development_dependency 'rake', '~> 13.0'
41
43
  spec.add_development_dependency 'roo', '~> 2.8'
42
44
  spec.add_development_dependency 'rspec', '~> 3.10'
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ # This should work if (1) the gem is installed, or
5
+ # (2) we're in development and used `bundle exec`
6
+ require 'berkeley_library/tind'
7
+ require 'berkeley_library/alma'
8
+ rescue LoadError
9
+ # If we're in development, `require 'bundler/setup'`
10
+ # is roughly equivalent to `bundle exec`
11
+ require 'bundler/setup'
12
+ require 'berkeley_library/tind'
13
+ require 'berkeley_library/alma'
14
+ end
15
+
16
+ def setup
17
+ # set collection name information
18
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = {
19
+ '336' => ['Image'],
20
+ '852' => ['East Asian Library'],
21
+ '980' => ['pre_1912'],
22
+ '982' => ['Pre 1912 Chinese Materials - short name', 'Pre 1912 Chinese Materials - long name'],
23
+ '991' => []
24
+ }
25
+
26
+ # flag: set it to true if using barcode getting Alma record; default is false
27
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = true
28
+ end
29
+
30
+ def additional_tind_fields
31
+ txt = 'v001_0064'
32
+ url = 'https://digitalassets.lib.berkeley.edu/pre1912ChineseMaterials/ucb/ready/991032333019706532/991032333019706532_v001_0064.jpg'
33
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
34
+ datafields = [fft]
35
+
36
+ f_035 = BerkeleyLibrary::TIND::Mapping::TindField.f_035_from_alma_id('pre_1912', '991085821143406532')
37
+ datafields << f_035
38
+ end
39
+
40
+ ########### Use this, when creating multiple TIND records from a single Alma record ############
41
+ alma_id = '991085821143406532'
42
+ # alma_id = '99108582114340653' # a bad alma_id
43
+ # alma_id = '991084606989706532' # Host histrical record
44
+
45
+ setup
46
+
47
+ BerkeleyLibrary::Alma::Config.default!
48
+ alma_multiple_tind = BerkeleyLibrary::TIND::Mapping::AlmaMultipleTIND.new(alma_id)
49
+ tind_record = alma_multiple_tind.record(additional_tind_fields)
50
+ alma_multiple_tind.save_tind_record_to_file(tind_record, 'tmp/multiple.xml')
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ # This should work if (1) the gem is installed, or
5
+ # (2) we're in development and used `bundle exec`
6
+ require 'berkeley_library/tind'
7
+ require 'berkeley_library/alma'
8
+ rescue LoadError
9
+ # If we're in development, `require 'bundler/setup'`
10
+ # is roughly equivalent to `bundle exec`
11
+ require 'bundler/setup'
12
+ require 'berkeley_library/tind'
13
+ require 'berkeley_library/alma'
14
+ end
15
+
16
+ def setup
17
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = {
18
+ '336' => ['Image'],
19
+ '852' => ['East Asian Library'],
20
+ '980' => ['pre_1912'],
21
+ '982' => ['Pre 1912 Chinese Materials - short name', 'Pre 1912 Chinese Materials - long name'],
22
+ '991' => []
23
+ }
24
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.is_035_from_mms_id = true
25
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = false
26
+ end
27
+
28
+ def additional_tind_fields
29
+ txt = 'v001_0064'
30
+ url = 'https://digitalassets.lib.berkeley.edu/pre1912ChineseMaterials/ucb/ready/991032333019706532/991032333019706532_v001_0064.jpg'
31
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
32
+ f = ::MARC::DataField.new('998', ' ', ' ', ['a', 'fake-value'])
33
+ [fft] << f
34
+ end
35
+
36
+ ############## Use this, when creating a TIND record from each Alma record ############
37
+ # alma_id = '991085821143406532'
38
+ # alma_id_bad = '99108582114340653' # a bad alma_id
39
+ # alma_id_not_qualified = '991084606989706532' # Host historical record
40
+ barcode = 'C084093187'
41
+
42
+ id = barcode
43
+ setup
44
+
45
+ BerkeleyLibrary::Alma::Config.default!
46
+ alma_single_tind = BerkeleyLibrary::TIND::Mapping::AlmaSingleTIND.new
47
+ tind_record = alma_single_tind.record(id, additional_tind_fields)
48
+ alma_single_tind.save_tind_record_to_file(id, tind_record, 'tmp/test_single.xml')
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ # This should work if (1) the gem is installed, or
5
+ # (2) we're in development and used `bundle exec`
6
+ require 'berkeley_library/tind'
7
+ require 'berkeley_library/alma'
8
+ rescue LoadError
9
+ # If we're in development, `require 'bundler/setup'`
10
+ # is roughly equivalent to `bundle exec`
11
+ require 'bundler/setup'
12
+ require 'berkeley_library/tind'
13
+ require 'berkeley_library/alma'
14
+ end
15
+
16
+ def setup
17
+ BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = {
18
+ '336' => ['Image'],
19
+ '852' => ['Bioscience, Natural Resources & Public Health Library'],
20
+ '980' => ['Forestry'],
21
+ '982' => ['Forestry', 'Forestry'],
22
+ '991' => []
23
+ }
24
+
25
+ # BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = true
26
+ end
27
+
28
+ def fake_additional_tind_fields1
29
+ fields = []
30
+ txt = '001'
31
+ url = 'https://digitalassets.lib.berkeley.edu/forestry/ucb/images/b142086125_i180839998/b142086125_i180839998_001.jpg'
32
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
33
+ f_998 = ::MARC::DataField.new('998', ' ', ' ', ['a', 'fake-value'])
34
+ f_035 = BerkeleyLibrary::TIND::Mapping::TindField.f_035('b142086125')
35
+ fields << f_998
36
+ fields << f_035
37
+ fields << fft
38
+ end
39
+
40
+ def fake_additional_tind_fields2
41
+ fields = []
42
+ txt = '002'
43
+ url = 'https://digitalassets.lib.berkeley.edu/forestry/ucb/images/b142086125_i180839998/b142086125_i180839998_002.jpg'
44
+ fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt)
45
+
46
+ f_998 = ::MARC::DataField.new('998', ' ', ' ', ['a', 'fake-value'])
47
+
48
+ f_035 = BerkeleyLibrary::TIND::Mapping::TindField.f_035('b142107827')
49
+ fields << f_998
50
+ fields << f_035
51
+ fields << fft
52
+ end
53
+
54
+ def tind_records
55
+ records = []
56
+ alma_tind = BerkeleyLibrary::TIND::Mapping::AlmaSingleTIND.new
57
+
58
+ record1 = alma_tind.record('b142086125', fake_additional_tind_fields1)
59
+ record2 = alma_tind.record('b142107827', fake_additional_tind_fields2)
60
+ records << record1
61
+ records << record2
62
+ end
63
+
64
+ def save_batch(file, with_tind_xmlwritter)
65
+ setup
66
+ writer = ::MARC::XMLWriter.new(file)
67
+ writer = BerkeleyLibrary::TIND::MARC::XMLWriter.new(file) if with_tind_xmlwritter
68
+
69
+ tind_records.each do |record|
70
+ record.leader = nil if with_tind_xmlwritter
71
+ writer.write(record)
72
+ end
73
+ writer.close
74
+ end
75
+
76
+ # save with tind xmlwritter
77
+ save_batch('tmp/test_tind_xmlwritter.xml', true)
78
+
79
+ # save with Marc xmlwritter
80
+ save_batch('tmp/test_marc_xmlwritter.xml', false)