berkeley_library-tind 0.7.2 → 0.7.3

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +37 -23
  3. data/.github/workflows/gem-push.yml +1 -1
  4. data/.rubocop.yml +232 -4
  5. data/.ruby-version +1 -1
  6. data/Dockerfile +3 -2
  7. data/Rakefile +1 -1
  8. data/berkeley_library-tind.gemspec +10 -5
  9. data/bin/alma-single-tind +1 -1
  10. data/bin/save_tind_records +3 -3
  11. data/bin/tind-marc +1 -1
  12. data/lib/berkeley_library/tind/api/api.rb +1 -1
  13. data/lib/berkeley_library/tind/api.rb +1 -1
  14. data/lib/berkeley_library/tind/export/column_group.rb +2 -2
  15. data/lib/berkeley_library/tind/export/column_group_list.rb +4 -4
  16. data/lib/berkeley_library/tind/export/export_format.rb +6 -3
  17. data/lib/berkeley_library/tind/export/exporter.rb +2 -1
  18. data/lib/berkeley_library/tind/export/table.rb +1 -1
  19. data/lib/berkeley_library/tind/export.rb +1 -1
  20. data/lib/berkeley_library/tind/mapping/data/one_to_one_mapping.csv +2 -1
  21. data/lib/berkeley_library/tind/mapping/external_tind_field.rb +2 -2
  22. data/lib/berkeley_library/tind/mapping/field_catalog_util.rb +4 -3
  23. data/lib/berkeley_library/tind/mapping.rb +1 -1
  24. data/lib/berkeley_library/tind/marc/xml_reader.rb +1 -1
  25. data/lib/berkeley_library/tind/marc.rb +1 -1
  26. data/lib/berkeley_library/tind/module_info.rb +3 -3
  27. data/lib/berkeley_library/tind.rb +1 -1
  28. data/lib/berkeley_library/util/ods/xml/namespace.rb +2 -1
  29. data/lib/berkeley_library/util/ods/xml/office/automatic_styles.rb +2 -1
  30. data/lib/berkeley_library/util/ods/xml/style/text_properties.rb +1 -1
  31. data/lib/berkeley_library/util/ods/xml/table/table_column.rb +2 -2
  32. data/lib/berkeley_library/util/ods/xml/text/p.rb +2 -1
  33. data/lib/berkeley_library/view +339 -0
  34. data/spec/berkeley_library/tind/api/collection_spec.rb +1 -1
  35. data/spec/berkeley_library/tind/api/search_spec.rb +3 -2
  36. data/spec/berkeley_library/tind/config_spec.rb +11 -8
  37. data/spec/berkeley_library/tind/export/config_spec.rb +3 -3
  38. data/spec/berkeley_library/tind/mapping/alma_spec.rb +11 -1
  39. data/spec/berkeley_library/tind/mapping/csv_mapper_spec.rb +2 -2
  40. data/spec/berkeley_library/tind/mapping/field_catalog_util_spec.rb +1 -1
  41. data/spec/berkeley_library/tind/mapping/tind_field_spec.rb +4 -4
  42. data/spec/berkeley_library/tind/mapping/tind_record_util_spec.rb +1 -1
  43. data/spec/berkeley_library/tind/mapping/util_spec.rb +4 -0
  44. data/spec/berkeley_library/tind/marc/xml_reader_spec.rb +1 -1
  45. data/spec/berkeley_library/util/ods/spreadsheet_spec.rb +4 -2
  46. data/spec/data/mapping/one_to_one_mapping.csv +2 -1
  47. data/spec/data/mapping/record_missing_control.xml +253 -0
  48. metadata +35 -13
@@ -15,7 +15,7 @@ module BerkeleyLibrary
15
15
  # ############################################################
16
16
  # Constant
17
17
 
18
- COMMENT_TOTAL_RE = /Search-Engine-Total-Number-Of-Results: ([0-9]+)/.freeze
18
+ COMMENT_TOTAL_RE = /Search-Engine-Total-Number-Of-Results: ([0-9]+)/
19
19
 
20
20
  # ############################################################
21
21
  # Attributes
@@ -1 +1 @@
1
- Dir.glob(File.expand_path('marc/*.rb', __dir__)).sort.each(&method(:require))
1
+ Dir.glob(File.expand_path('marc/*.rb', __dir__)).each(&method(:require))
@@ -2,12 +2,12 @@ module BerkeleyLibrary
2
2
  module TIND
3
3
  class ModuleInfo
4
4
  NAME = 'berkeley_library-tind'.freeze
5
- AUTHOR = 'David Moles'.freeze
6
- AUTHOR_EMAIL = 'dmoles@berkeley.edu'.freeze
5
+ AUTHORS = ['David Moles', 'Yuchai Zhou', 'David Zuckerman'].freeze
6
+ AUTHOR_EMAILS = ['dmoles@berkeley.edu', 'zhouyu@berkeley.edu', 'dzuckerm@berkeley.edu'].freeze
7
7
  SUMMARY = 'TIND DA utilities for the UC Berkeley Library'.freeze
8
8
  DESCRIPTION = 'UC Berkeley Library utility gem for working with the TIND DA digital archive.'.freeze
9
9
  LICENSE = 'MIT'.freeze
10
- VERSION = '0.7.2'.freeze
10
+ VERSION = '0.7.3'.freeze
11
11
  HOMEPAGE = 'https://github.com/BerkeleyLibrary/tind'.freeze
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  require 'marc_extensions'
2
2
 
3
- Dir.glob(File.expand_path('tind/*.rb', __dir__)).sort.each(&method(:require))
3
+ Dir.glob(File.expand_path('tind/*.rb', __dir__)).each(&method(:require))
@@ -34,7 +34,8 @@ module BerkeleyLibrary
34
34
 
35
35
  class << self
36
36
  def for_prefix(prefix)
37
- @by_prefix ||= Namespace.map { |ns| [ns.prefix, ns] }.to_h
37
+ # @by_prefix ||= Namespace.map { |ns| [ns.prefix, ns] }.to_h
38
+ @by_prefix ||= Namespace.to_h { |ns| [ns.prefix, ns] }
38
39
  @by_prefix[prefix.to_s]
39
40
  end
40
41
  end
@@ -145,7 +145,8 @@ module BerkeleyLibrary
145
145
  return add_cell_style if f == Style::Family::TABLE_CELL
146
146
  return add_column_style if f == Style::Family::TABLE_COLUMN
147
147
  return add_row_style if f == Style::Family::TABLE_ROW
148
- return add_table_style if f == Style::Family::TABLE
148
+
149
+ add_table_style if f == Style::Family::TABLE
149
150
  end
150
151
 
151
152
  def next_name_for(family)
@@ -8,7 +8,7 @@ module BerkeleyLibrary
8
8
  class TextProperties < ElementNode
9
9
 
10
10
  FONT_WEIGHT_ATTRS = %w[font-weight font-weight-asian font-weight-complex].freeze
11
- COLOR_RE = /^#[[:xdigit:]]{6}$/.freeze
11
+ COLOR_RE = /^#[[:xdigit:]]{6}$/
12
12
 
13
13
  attr_reader :color, :font_name, :language, :country, :font_weight
14
14
 
@@ -23,11 +23,11 @@ module BerkeleyLibrary
23
23
  set_default_attributes!
24
24
  end
25
25
 
26
- # rubocop:disable Naming/PredicateName
26
+ # rubocop:disable Naming/PredicatePrefix
27
27
  def has_styles?(column_style, default_cell_style)
28
28
  self.column_style == column_style && self.default_cell_style == default_cell_style
29
29
  end
30
- # rubocop:enable Naming/PredicateName
30
+ # rubocop:enable Naming/PredicatePrefix
31
31
 
32
32
  private
33
33
 
@@ -87,7 +87,8 @@ module BerkeleyLibrary
87
87
 
88
88
  return S.new(doc: doc) if c == ' '
89
89
  return Tab.new(doc: doc) if c == "\t"
90
- return LineBreak.new(doc: doc) if c == "\n"
90
+
91
+ LineBreak.new(doc: doc) if c == "\n"
91
92
  end
92
93
  end
93
94
 
@@ -0,0 +1,339 @@
1
+ Inspecting 98 files
2
+ WWC.C..C.WCC....C..CC..C..C.W.....................C...W.C.CCCC.C.CC.CCCCCCCCCCC.CCCCCCCCCCCC.CCCCC
3
+
4
+ Offenses:
5
+
6
+ tind.rb:3:50: W: [Correctable] Lint/RedundantDirGlobSort: Remove redundant sort.
7
+ Dir.glob(File.expand_path('tind/*.rb', __dir__)).sort.each(&method(:require))
8
+ ^^^^
9
+ tind/api.rb:1:49: W: [Correctable] Lint/RedundantDirGlobSort: Remove redundant sort.
10
+ Dir.glob(File.expand_path('api/*.rb', __dir__)).sort.each(&method(:require))
11
+ ^^^^
12
+ tind/api/api.rb:109:42: C: [Correctable] Style/HashSyntax: Omit the hash value.
13
+ URIs.get(endpoint_uri, params: params, headers: headers)
14
+ ^^^^^^
15
+ tind/api/api.rb:109:59: C: [Correctable] Style/HashSyntax: Omit the hash value.
16
+ URIs.get(endpoint_uri, params: params, headers: headers)
17
+ ^^^^^^^
18
+ tind/api/api.rb:111:65: C: [Correctable] Style/HashSyntax: Omit the hash value.
19
+ raise APIException.wrap(e, url: endpoint_uri, params: params)
20
+ ^^^^^^
21
+ tind/api/collection.rb:28:63: C: [Correctable] Style/HashSyntax: Omit the hash value.
22
+ children.each { |c| c.each_descendant(include_self: include_self, &block) }
23
+ ^^^^^^^^^^^^
24
+ tind/api/search.rb:53:48: C: [Correctable] Style/HashSyntax: Omit the hash value.
25
+ return to_enum(:each_result, freeze: freeze) unless block_given?
26
+ ^^^^^^
27
+ tind/api/search.rb:55:34: C: [Correctable] Style/HashSyntax: Omit the hash value.
28
+ perform_search(freeze: freeze, &block)
29
+ ^^^^^^
30
+ tind/api/search.rb:63:61: C: [Correctable] Style/HashSyntax: Omit the hash value.
31
+ params = search_id ? self.params.merge(search_id: search_id) : self.params
32
+ ^^^^^^^^^
33
+ tind/api/search.rb:65:61: C: [Correctable] Style/HashSyntax: Omit the hash value.
34
+ perform_search(search_id: next_search_id, freeze: freeze, &block) if next_search_id
35
+ ^^^^^^
36
+ tind/api/search.rb:81:82: C: [Correctable] Style/HashSyntax: Omit the hash value.
37
+ xml_reader = BerkeleyLibrary::TIND::MARC::XMLReader.read(body, freeze: freeze)
38
+ ^^^^^^
39
+ tind/export.rb:1:52: W: [Correctable] Lint/RedundantDirGlobSort: Remove redundant sort.
40
+ Dir.glob(File.expand_path('export/*.rb', __dir__)).sort.each(&method(:require))
41
+ ^^^^
42
+ tind/export/column.rb:46:55: C: [Correctable] Style/HashSyntax: Omit the hash value.
43
+ return to_enum(:each_value, include_header: include_header) unless block_given?
44
+ ^^^^^^^^^^^^^^
45
+ tind/export/column_group.rb:19:24: C: [Correctable] Style/RedundantFreeze: Do not freeze immutable objects, as freezing them has no effect.
46
+ INDICATOR_RE = /^[0-9a-z ]$/i.freeze
47
+ ^^^^^^^^^^^^^^^^^^^^^
48
+ tind/export/column_group.rb:21:28: C: [Correctable] Style/RedundantFreeze: Do not freeze immutable objects, as freezing them has no effect.
49
+ SUBFIELD_CODE_RE = /^[0-9a-z]$/.freeze
50
+ ^^^^^^^^^^^^^^^^^^^
51
+ tind/export/export.rb:29:72: C: [Correctable] Style/HashSyntax: Omit the hash value.
52
+ exporter = exporter_for(collection, format, exportable_only: exportable_only)
53
+ ^^^^^^^^^^^^^^^
54
+ tind/export/export.rb:41:67: C: [Correctable] Style/HashSyntax: Omit the hash value.
55
+ export_format.exporter_for(collection, exportable_only: exportable_only)
56
+ ^^^^^^^^^^^^^^^
57
+ tind/export/export_format.rb:15:63: C: [Correctable] Style/HashSyntax: Omit the hash value.
58
+ return CSVExporter.new(collection, exportable_only: exportable_only) if self == ExportFormat::CSV
59
+ ^^^^^^^^^^^^^^^
60
+ tind/export/export_format.rb:16:63: C: [Correctable] Style/HashSyntax: Omit the hash value.
61
+ return ODSExporter.new(collection, exportable_only: exportable_only) if self == ExportFormat::ODS
62
+ ^^^^^^^^^^^^^^^
63
+ tind/export/exporter.rb:94:51: C: [Correctable] Style/HashSyntax: Omit the hash value.
64
+ results = API::Search.new(collection: collection).each_result(freeze: true)
65
+ ^^^^^^^^^^
66
+ tind/export/exporter.rb:98:80: C: [Correctable] Style/HashSyntax: Omit the hash value.
67
+ Export::Table.from_records(results, freeze: true, exportable_only: exportable_only)
68
+ ^^^^^^^^^^^^^^^
69
+ tind/export/ods_exporter.rb:77:51: C: [Correctable] Style/HashSyntax: Omit the hash value.
70
+ styles.find_or_create_cell_style(color: color, font_weight: font_weight, wrap: wrap)
71
+ ^^^^^
72
+ tind/export/ods_exporter.rb:77:71: C: [Correctable] Style/HashSyntax: Omit the hash value.
73
+ styles.find_or_create_cell_style(color: color, font_weight: font_weight, wrap: wrap)
74
+ ^^^^^^^^^^^
75
+ tind/export/ods_exporter.rb:77:90: C: [Correctable] Style/HashSyntax: Omit the hash value.
76
+ styles.find_or_create_cell_style(color: color, font_weight: font_weight, wrap: wrap)
77
+ ^^^^
78
+ tind/export/ods_exporter.rb:128:87: C: [Correctable] Style/HashSyntax: Omit the hash value.
79
+ cell_style = find_or_create_cell_style(color: color_for(col_index), wrap: wrap)
80
+ ^^^^
81
+ tind/export/table.rb:27:65: C: [Correctable] Style/HashSyntax: Omit the hash value.
82
+ @column_groups = ColumnGroupList.new(exportable_only: exportable_only)
83
+ ^^^^^^^^^^^^^^^
84
+ tind/export/table.rb:41:40: C: [Correctable] Style/HashSyntax: Omit the hash value.
85
+ Table.new(exportable_only: exportable_only).tap do |table|
86
+ ^^^^^^^^^^^^^^^
87
+ tind/mapping.rb:1:53: W: [Correctable] Lint/RedundantDirGlobSort: Remove redundant sort.
88
+ Dir.glob(File.expand_path('mapping/*.rb', __dir__)).sort.each(&method(:require))
89
+ ^^^^
90
+ tind/mapping/tind_marc.rb:110:59: C: [Correctable] Style/HashSyntax: Omit the hash value.
91
+ add_tindfield(new_fls, f, excluding_subfield: excluding_subfield)
92
+ ^^^^^^^^^^^^^^^^^^
93
+ tind/marc.rb:1:50: W: [Correctable] Lint/RedundantDirGlobSort: Remove redundant sort.
94
+ Dir.glob(File.expand_path('marc/*.rb', __dir__)).sort.each(&method(:require))
95
+ ^^^^
96
+ tind/marc/xml_reader.rb:18:28: C: [Correctable] Style/RedundantFreeze: Do not freeze immutable objects, as freezing them has no effect.
97
+ COMMENT_TOTAL_RE = /Search-Engine-Total-Number-Of-Results: ([0-9]+)/.freeze
98
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
+ tind/marc/xml_reader.rb:66:33: C: [Correctable] Style/HashSyntax: Omit the hash value.
100
+ new(source, freeze: freeze)
101
+ ^^^^^^
102
+ tind/module_info.rb:5:17: C: [Correctable] Style/MutableConstant: Freeze mutable objects assigned to constants.
103
+ AUTHORS = ['David Moles'.freeze, 'Yucha Zhou'.freeze, 'David Zuckerman'.freeze]
104
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105
+ tind/module_info.rb:6:23: C: [Correctable] Style/MutableConstant: Freeze mutable objects assigned to constants.
106
+ AUTHOR_EMAILS = ['dmoles@berkeley.edu'.freeze, 'zhouyu@berkeley.edu'.freeze, 'dzuckerm@berkeley.edu'.freeze]
107
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108
+ util/ods/spreadsheet.rb:23:63: C: [Correctable] Style/HashSyntax: Omit the hash value.
109
+ content.document_content.add_table(name, protected: protected)
110
+ ^^^^^^^^^
111
+ util/ods/xml/content_doc.rb:20:68: C: [Correctable] Style/HashSyntax: Omit the hash value.
112
+ @document_content ||= Office::DocumentContent.new(doc: doc)
113
+ ^^^
114
+ util/ods/xml/document_node.rb:20:49: C: [Correctable] Style/HashSyntax: Omit the hash value.
115
+ return write_xml_to_string(compact: compact) unless out
116
+ ^^^^^^^
117
+ util/ods/xml/document_node.rb:21:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
118
+ return write_xml_to_stream(out, compact: compact) if out.respond_to?(:write)
119
+ ^^^^^^^
120
+ util/ods/xml/document_node.rb:23:45: C: [Correctable] Style/HashSyntax: Omit the hash value.
121
+ write_xml_to_file(out, compact: compact)
122
+ ^^^^^^^
123
+ util/ods/xml/document_node.rb:46:49: C: [Correctable] Style/HashSyntax: Omit the hash value.
124
+ write_xml_to_stream(out, compact: compact)
125
+ ^^^^^^^
126
+ util/ods/xml/document_node.rb:51:73: C: [Correctable] Style/HashSyntax: Omit the hash value.
127
+ File.open(path, 'wb') { |f| write_xml_to_stream(f, compact: compact) }
128
+ ^^^^^^^
129
+ util/ods/xml/loext/table_protection.rb:10:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
130
+ super(:loext, 'table-protection', doc: doc)
131
+ ^^^
132
+ util/ods/xml/manifest/manifest.rb:14:49: C: [Correctable] Style/HashSyntax: Omit the hash value.
133
+ super(:manifest, 'manifest', doc: doc)
134
+ ^^^
135
+ util/ods/xml/manifest_doc.rb:20:55: C: [Correctable] Style/HashSyntax: Omit the hash value.
136
+ @manifest ||= Manifest::Manifest.new(doc: doc)
137
+ ^^^
138
+ util/ods/xml/office/automatic_styles.rb:18:55: C: [Correctable] Style/HashSyntax: Omit the hash value.
139
+ super(:office, 'automatic-styles', doc: doc)
140
+ ^^^
141
+ util/ods/xml/office/automatic_styles.rb:39:83: C: [Correctable] Style/HashSyntax: Omit the hash value.
142
+ add_style(Style::CellStyle.new(name, protected, color, font_weight: font_weight, wrap: wrap, styles: self))
143
+ ^^^^^^^^^^^
144
+ util/ods/xml/office/automatic_styles.rb:39:102: C: [Correctable] Style/HashSyntax: Omit the hash value.
145
+ add_style(Style::CellStyle.new(name, protected, color, font_weight: font_weight, wrap: wrap, styles: self))
146
+ ^^^^
147
+ util/ods/xml/office/automatic_styles.rb:82:66: C: [Correctable] Style/HashSyntax: Omit the hash value.
148
+ existing_style = find_cell_style(protected, color: color, font_weight: font_weight, wrap: wrap)
149
+ ^^^^^
150
+ util/ods/xml/office/automatic_styles.rb:82:86: C: [Correctable] Style/HashSyntax: Omit the hash value.
151
+ existing_style = find_cell_style(protected, color: color, font_weight: font_weight, wrap: wrap)
152
+ ^^^^^^^^^^^
153
+ util/ods/xml/office/automatic_styles.rb:82:105: C: [Correctable] Style/HashSyntax: Omit the hash value.
154
+ existing_style = find_cell_style(protected, color: color, font_weight: font_weight, wrap: wrap)
155
+ ^^^^
156
+ util/ods/xml/office/automatic_styles.rb:85:66: C: [Correctable] Style/HashSyntax: Omit the hash value.
157
+ add_cell_style(nil, protected, color, font_weight: font_weight, wrap: wrap)
158
+ ^^^^^^^^^^^
159
+ util/ods/xml/office/automatic_styles.rb:85:85: C: [Correctable] Style/HashSyntax: Omit the hash value.
160
+ add_cell_style(nil, protected, color, font_weight: font_weight, wrap: wrap)
161
+ ^^^^
162
+ util/ods/xml/office/body.rb:10:43: C: [Correctable] Style/HashSyntax: Omit the hash value.
163
+ super(:office, 'body', doc: doc)
164
+ ^^^
165
+ util/ods/xml/office/document_content.rb:27:55: C: [Correctable] Style/HashSyntax: Omit the hash value.
166
+ super(:office, 'document-content', doc: doc)
167
+ ^^^
168
+ util/ods/xml/office/document_content.rb:37:45: C: [Correctable] Style/HashSyntax: Omit the hash value.
169
+ @scripts ||= Scripts.new(doc: doc)
170
+ ^^^
171
+ util/ods/xml/office/document_content.rb:41:67: C: [Correctable] Style/HashSyntax: Omit the hash value.
172
+ @font_face_decls ||= Office::FontFaceDecls.new(doc: doc)
173
+ ^^^
174
+ util/ods/xml/office/document_content.rb:45:70: C: [Correctable] Style/HashSyntax: Omit the hash value.
175
+ @automatic_styles ||= Office::AutomaticStyles.new(doc: doc)
176
+ ^^^
177
+ util/ods/xml/office/document_content.rb:49:105: C: [Correctable] Style/HashSyntax: Omit the hash value.
178
+ new_table = XML::Table::Table.new(name, table_style, styles: automatic_styles, protected: protected)
179
+ ^^^^^^^^^
180
+ util/ods/xml/office/document_content.rb:54:61: C: [Correctable] Style/HashSyntax: Omit the hash value.
181
+ @spreadsheet ||= Office::Spreadsheet.new(doc: doc)
182
+ ^^^
183
+ util/ods/xml/office/document_content.rb:58:39: C: [Correctable] Style/HashSyntax: Omit the hash value.
184
+ @body ||= Body.new(doc: doc).tap { |body| body.add_child(spreadsheet) }
185
+ ^^^
186
+ util/ods/xml/office/document_styles.rb:14:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
187
+ super(:office, 'document-styles', doc: doc)
188
+ ^^^
189
+ util/ods/xml/office/document_styles.rb:31:48: C: [Correctable] Style/HashSyntax: Omit the hash value.
190
+ add_child(FontFaceDecls.new(doc: doc))
191
+ ^^^
192
+ util/ods/xml/office/document_styles.rb:32:41: C: [Correctable] Style/HashSyntax: Omit the hash value.
193
+ add_child(Styles.new(doc: doc))
194
+ ^^^
195
+ util/ods/xml/office/font_face_decls.rb:11:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
196
+ super(:office, 'font-face-decls', doc: doc)
197
+ ^^^
198
+ util/ods/xml/office/font_face_decls.rb:23:49: C: [Correctable] Style/HashSyntax: Omit the hash value.
199
+ Style::FontFace.default_face(doc: doc)
200
+ ^^^
201
+ util/ods/xml/office/scripts.rb:10:46: C: [Correctable] Style/HashSyntax: Omit the hash value.
202
+ super(:office, 'scripts', doc: doc)
203
+ ^^^
204
+ util/ods/xml/office/spreadsheet.rb:11:50: C: [Correctable] Style/HashSyntax: Omit the hash value.
205
+ super(:office, 'spreadsheet', doc: doc)
206
+ ^^^
207
+ util/ods/xml/office/spreadsheet.rb:15:71: C: [Correctable] Style/HashSyntax: Omit the hash value.
208
+ @named_expressions ||= Table::NamedExpressions.new(doc: doc)
209
+ ^^^
210
+ util/ods/xml/office/styles.rb:13:45: C: [Correctable] Style/HashSyntax: Omit the hash value.
211
+ super(:office, 'styles', doc: doc)
212
+ ^^^
213
+ util/ods/xml/office/styles.rb:22:72: C: [Correctable] Style/HashSyntax: Omit the hash value.
214
+ add_child(Style::Style.new('Default', 'table-cell', doc: doc))
215
+ ^^^
216
+ util/ods/xml/office/styles.rb:27:53: C: [Correctable] Style/HashSyntax: Omit the hash value.
217
+ Style::ParagraphProperties.new(doc: doc),
218
+ ^^^
219
+ util/ods/xml/office/styles.rb:28:95: C: [Correctable] Style/HashSyntax: Omit the hash value.
220
+ Style::TextProperties.new(font_name: Style::FontFace::DEFAULT_FONT_FACE, doc: doc)
221
+ ^^^
222
+ util/ods/xml/office/styles.rb:30:58: C: [Correctable] Style/HashSyntax: Omit the hash value.
223
+ Style::DefaultStyle.new('table-cell', doc: doc).tap do |ds|
224
+ ^^^
225
+ util/ods/xml/style/cell_style.rb:50:81: C: [Correctable] Style/HashSyntax: Omit the hash value.
226
+ children << TableCellProperties.new(protected?, wrap: wrap?, doc: doc)
227
+ ^^^
228
+ util/ods/xml/style/cell_style.rb:51:53: C: [Correctable] Style/HashSyntax: Omit the hash value.
229
+ children << TextProperties.new(color: color, font_weight: font_weight, doc: doc) if custom_text_properties?
230
+ ^^^^^
231
+ util/ods/xml/style/cell_style.rb:51:73: C: [Correctable] Style/HashSyntax: Omit the hash value.
232
+ children << TextProperties.new(color: color, font_weight: font_weight, doc: doc) if custom_text_properties?
233
+ ^^^^^^^^^^^
234
+ util/ods/xml/style/cell_style.rb:51:91: C: [Correctable] Style/HashSyntax: Omit the hash value.
235
+ children << TextProperties.new(color: color, font_weight: font_weight, doc: doc) if custom_text_properties?
236
+ ^^^
237
+ util/ods/xml/style/column_style.rb:29:65: C: [Correctable] Style/HashSyntax: Omit the hash value.
238
+ children << TableColumnProperties.new(width, doc: doc)
239
+ ^^^
240
+ util/ods/xml/style/default_style.rb:14:51: C: [Correctable] Style/HashSyntax: Omit the hash value.
241
+ super(:style, 'default-style', doc: doc)
242
+ ^^^
243
+ util/ods/xml/style/font_face.rb:14:47: C: [Correctable] Style/HashSyntax: Omit the hash value.
244
+ super(:style, 'font-face', doc: doc)
245
+ ^^^
246
+ util/ods/xml/style/font_face.rb:24:113: C: [Correctable] Style/HashSyntax: Omit the hash value.
247
+ FontFace.new(FontFace::DEFAULT_FONT_FACE, family_generic: 'swiss', font_pitch: 'variable', doc: doc)
248
+ ^^^
249
+ util/ods/xml/style/paragraph_properties.rb:15:58: C: [Correctable] Style/HashSyntax: Omit the hash value.
250
+ super(:style, 'paragraph-properties', doc: doc)
251
+ ^^^
252
+ util/ods/xml/style/row_style.rb:30:63: C: [Correctable] Style/HashSyntax: Omit the hash value.
253
+ children << TableRowProperties.new(height, doc: doc)
254
+ ^^^
255
+ util/ods/xml/style/style.rb:15:43: C: [Correctable] Style/HashSyntax: Omit the hash value.
256
+ super(:style, 'style', doc: doc)
257
+ ^^^
258
+ util/ods/xml/style/table_cell_properties.rb:12:59: C: [Correctable] Style/HashSyntax: Omit the hash value.
259
+ super(:style, 'table-cell-properties', doc: doc)
260
+ ^^^
261
+ util/ods/xml/style/table_column_properties.rb:12:58: C: [Correctable] Style/HashSyntax: Omit the hash value.
262
+ super(:style, 'table-row-properties', doc: doc)
263
+ ^^^
264
+ util/ods/xml/style/table_properties.rb:10:54: C: [Correctable] Style/HashSyntax: Omit the hash value.
265
+ super(:style, 'table-properties', doc: doc)
266
+ ^^^
267
+ util/ods/xml/style/table_row_properties.rb:12:61: C: [Correctable] Style/HashSyntax: Omit the hash value.
268
+ super(:style, 'table-column-properties', doc: doc)
269
+ ^^^
270
+ util/ods/xml/style/table_style.rb:20:52: C: [Correctable] Style/HashSyntax: Omit the hash value.
271
+ children << TableProperties.new(doc: doc)
272
+ ^^^
273
+ util/ods/xml/style/text_properties.rb:11:24: C: [Correctable] Style/RedundantFreeze: Do not freeze immutable objects, as freezing them has no effect.
274
+ COLOR_RE = /^#[[:xdigit:]]{6}$/.freeze
275
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
276
+ util/ods/xml/style/text_properties.rb:17:53: C: [Correctable] Style/HashSyntax: Omit the hash value.
277
+ super(:style, 'text-properties', doc: doc)
278
+ ^^^
279
+ util/ods/xml/styles_doc.rb:20:66: C: [Correctable] Style/HashSyntax: Omit the hash value.
280
+ @document_styles ||= Office::DocumentStyles.new(doc: doc)
281
+ ^^^
282
+ util/ods/xml/table/named_expressions.rb:10:55: C: [Correctable] Style/HashSyntax: Omit the hash value.
283
+ super(:table, 'named-expressions', doc: doc)
284
+ ^^^
285
+ util/ods/xml/table/table.rb:166:57: C: [Correctable] Style/HashSyntax: Omit the hash value.
286
+ add_child(LOExt::TableProtection.new(doc: doc))
287
+ ^^^
288
+ util/ods/xml/table/table_cell.rb:14:86: C: [Correctable] Style/HashSyntax: Omit the hash value.
289
+ super('table-cell', 'number-columns-repeated', number_repeated, table: table)
290
+ ^^^^^
291
+ util/ods/xml/table/table_cell.rb:25:72: C: [Correctable] Style/HashSyntax: Omit the hash value.
292
+ TableCell.new(nil, cell_style, number_repeated, table: table)
293
+ ^^^^^
294
+ util/ods/xml/table/table_cell.rb:38:56: C: [Correctable] Style/HashSyntax: Omit the hash value.
295
+ children << XML::Text::P.new(value, doc: doc) if value
296
+ ^^^
297
+ util/ods/xml/table/table_column.rb:19:88: C: [Correctable] Style/HashSyntax: Omit the hash value.
298
+ super('table-column', 'number-columns-repeated', number_repeated, table: table)
299
+ ^^^^^
300
+ util/ods/xml/table/table_row.rb:25:82: C: [Correctable] Style/HashSyntax: Omit the hash value.
301
+ super('table-row', 'number-rows-repeated', number_repeated, table: table)
302
+ ^^^^^
303
+ util/ods/xml/table/table_row.rb:36:108: C: [Correctable] Style/HashSyntax: Omit the hash value.
304
+ explicit_cells[column_index] = TableCell.new(value, cell_style || default_cell_style, table: table)
305
+ ^^^^^
306
+ util/ods/xml/table/table_row.rb:127:91: C: [Correctable] Style/HashSyntax: Omit the hash value.
307
+ empty_cell = TableCell.repeat_empty(num_repeats, default_cell_style, table: table)
308
+ ^^^^^
309
+ util/ods/xml/text/p.rb:24:38: C: [Correctable] Style/HashSyntax: Omit the hash value.
310
+ super(:text, 'p', doc: doc)
311
+ ^^^
312
+ util/ods/xml/text/p.rb:88:33: C: [Correctable] Style/HashSyntax: Omit the hash value.
313
+ return S.new(doc: doc) if c == ' '
314
+ ^^^
315
+ util/ods/xml/text/p.rb:89:35: C: [Correctable] Style/HashSyntax: Omit the hash value.
316
+ return Tab.new(doc: doc) if c == "\t"
317
+ ^^^
318
+ util/ods/xml/text/p.rb:90:41: C: [Correctable] Style/HashSyntax: Omit the hash value.
319
+ return LineBreak.new(doc: doc) if c == "\n"
320
+ ^^^
321
+ util/ods/xml/text/p.rb:99:38: C: [Correctable] Style/HashSyntax: Omit the hash value.
322
+ super(:text, 's', doc: doc)
323
+ ^^^
324
+ util/ods/xml/text/p.rb:105:40: C: [Correctable] Style/HashSyntax: Omit the hash value.
325
+ super(:text, 'tab', doc: doc)
326
+ ^^^
327
+ util/ods/xml/text/p.rb:111:47: C: [Correctable] Style/HashSyntax: Omit the hash value.
328
+ super(:text, 'line-break', doc: doc)
329
+ ^^^
330
+
331
+ 98 files inspected, 108 offenses detected, 108 offenses autocorrectable
332
+
333
+ The following RuboCop extension libraries are installed but not loaded in config:
334
+ * rubocop-rake
335
+ * rubocop-rspec
336
+
337
+ You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
338
+ AllCops:
339
+ SuggestExtensions: false
@@ -64,7 +64,7 @@ module BerkeleyLibrary
64
64
  .with(headers: { 'Authorization' => 'Token not-a-real-api-key' })
65
65
  .to_return(status: 200, body: collections_json)
66
66
 
67
- actual_names = Collection.each_collection.each_with_object([]) { |c, arr| arr << c.name }
67
+ actual_names = Collection.each_collection.with_object([]) { |c, arr| arr << c.name }
68
68
  expect(actual_names).to contain_exactly(*expected_names)
69
69
  end
70
70
  end
@@ -45,7 +45,7 @@ module BerkeleyLibrary
45
45
  results = []
46
46
  enum = search.each_result
47
47
  expect(enum).to be_a(Enumerable)
48
- enum.each { |r| results << r }
48
+ enum.map { |r| results << r }
49
49
  expect(results.size).to eq(5)
50
50
  end
51
51
 
@@ -131,7 +131,8 @@ module BerkeleyLibrary
131
131
  results = []
132
132
  enum = search.each_result
133
133
  expect(enum).to be_a(Enumerable)
134
- enum.each { |r| results << r }
134
+ # enum.each { |r| results << r }
135
+ enum.map { |r| results << r }
135
136
  expect(results.size).to eq(expected_count)
136
137
  end
137
138
 
@@ -10,13 +10,13 @@ module BerkeleyLibrary
10
10
  @base_uri_orig = Config.instance_variable_get(:@base_uri)
11
11
  Config.instance_variable_set(:@base_uri, nil)
12
12
 
13
- @base_url_orig = ENV['LIT_TIND_BASE_URL']
13
+ @base_url_orig = ENV.fetch('LIT_TIND_BASE_URL', nil)
14
14
  ENV['LIT_TIND_BASE_URL'] = env_base_url
15
15
 
16
16
  @api_key_orig = Config.instance_variable_get(:@api_key)
17
17
  Config.instance_variable_set(:@api_key, nil)
18
18
 
19
- @api_key_env_orig = ENV['LIT_TIND_API_KEY']
19
+ @api_key_env_orig = ENV.fetch('LIT_TIND_API_KEY', nil)
20
20
  ENV['LIT_TIND_API_KEY'] = env_api_key
21
21
  end
22
22
 
@@ -41,11 +41,13 @@ module BerkeleyLibrary
41
41
  it 'returns a URI from Rails config if present' do
42
42
  expect(defined?(Rails)).to be_nil
43
43
 
44
- Object.send(:const_set, 'Rails', OpenStruct.new)
45
- Rails.application = OpenStruct.new
44
+ Object.send(:const_set, 'Rails', Struct.new(:application).new)
45
+ Rails.application = Struct.new(:config).new
46
46
 
47
47
  url = 'tind-test.example.edu'
48
- config = OpenStruct.new(tind_base_uri: url)
48
+ Conf = Struct.new(:tind_base_uri)
49
+ config = Conf.new(url)
50
+
49
51
  Rails.application.config = config
50
52
 
51
53
  ENV['LIT_TIND_BASE_URL'] = nil
@@ -68,11 +70,12 @@ module BerkeleyLibrary
68
70
  it 'returns an API key from the Rails config if present' do
69
71
  expect(defined?(Rails)).to be_nil
70
72
 
71
- Object.send(:const_set, 'Rails', OpenStruct.new)
72
- Rails.application = OpenStruct.new
73
+ Object.send(:const_set, 'Rails', Struct.new(:application).new)
74
+ Rails.application = Struct.new(:config).new
73
75
 
74
76
  api_key = 'test-api-key'
75
- config = OpenStruct.new(tind_api_key: api_key)
77
+ Conf = Struct.new(:tind_api_key)
78
+ config = Conf.new(api_key)
76
79
  Rails.application.config = config
77
80
 
78
81
  ENV['LIT_TIND_API_KEY'] = nil
@@ -31,7 +31,7 @@ module BerkeleyLibrary
31
31
  before(:each) do
32
32
  @env_orig = {}
33
33
  env_vars.each do |v|
34
- @env_orig[v] = ENV[v]
34
+ @env_orig[v] = ENV.fetch(v, nil)
35
35
  ENV[v] = nil
36
36
  end
37
37
  @inst_orig = {}
@@ -79,11 +79,11 @@ module BerkeleyLibrary
79
79
  format_digits: 'ODS_FORMAT_DIGITS_DEFAULT'
80
80
  }
81
81
 
82
- expected = env_vars_by_attr.map do |attr, var|
82
+ expected = env_vars_by_attr.to_h do |attr, var|
83
83
  value = 2 * Config.send(attr)
84
84
  ENV[var] = value.to_s
85
85
  [attr, value]
86
- end.to_h
86
+ end
87
87
 
88
88
  inst_vars.each do |v|
89
89
  Config.remove_instance_variable(v) if Config.instance_variable_defined?(v)
@@ -3,25 +3,35 @@ require 'spec_helper'
3
3
  module BerkeleyLibrary
4
4
  module TIND
5
5
  module Mapping
6
+
6
7
  describe Alma do
7
8
  let(:alma_obj) { Alma.new('spec/data/mapping/record.xml') }
9
+ let(:alma_obj_missing) { Alma.new('spec/data/mapping/record_missing_control.xml') }
8
10
 
9
11
  it 'control field value' do
10
12
  expect(alma_obj.control_field.tag).to eq '008'
11
13
  end
12
14
 
13
15
  it 'control field value' do
14
- expect(alma_obj.control_field.tag).to eq '008'
16
+ expect(alma_obj_missing.control_field).to be nil
15
17
  end
16
18
 
17
19
  it '880 field' do
18
20
  expect(alma_obj.field_880('245-01/$1')['6']).to eq '245-01/$1'
19
21
  end
20
22
 
23
+ it 'expects 880 field to be nil if no $6' do
24
+ expect(alma_obj_missing.field_880('fake_value')).to be nil
25
+ end
26
+
21
27
  it 'regular field' do
22
28
  expect(alma_obj.field('245').tag).to eq '245'
23
29
  end
24
30
 
31
+ it 'expects non mapped field to be nil' do
32
+ expect(alma_obj.field('99182')).to be nil
33
+ end
34
+
25
35
  end
26
36
  end
27
37
  end
@@ -6,8 +6,8 @@ module BerkeleyLibrary
6
6
  module Mapping
7
7
  describe CsvMapper do
8
8
  let(:dummy_class) { Class.new { extend CsvMapper } }
9
- let(:from_tag) { %w[100 110 111 242 245 246 250 255 260 264 300 351 490 500 502 505 507 520 522 524 536 541 545 546 600 610 611 630 650 651 655 700 710 711 720 752 773 907] }
10
- let(:rules_keys) { %i[tag_100 tag_110 tag_111 tag_242 tag_245 tag_246 tag_250 tag_255 tag_260 tag_264 tag_300 tag_351 tag_490 tag_500 tag_502 tag_505 tag_507 tag_520 tag_522 tag_524 tag_536 tag_541 tag_545 tag_546 tag_600 tag_610 tag_611 tag_630 tag_650 tag_651 tag_655 tag_700 tag_710 tag_711 tag_720 tag_752 tag_773 tag_907] }
9
+ let(:from_tag) { %w[100 110 111 242 245 246 250 255 260 264 300 351 490 500 502 505 507 520 522 524 536 541 545 546 561 600 610 611 630 650 651 655 700 710 711 720 752 773 907] }
10
+ let(:rules_keys) { %i[tag_100 tag_110 tag_111 tag_242 tag_245 tag_246 tag_250 tag_255 tag_260 tag_264 tag_300 tag_351 tag_490 tag_500 tag_502 tag_505 tag_507 tag_520 tag_522 tag_524 tag_536 tag_541 tag_545 tag_546 tag_561 tag_600 tag_610 tag_611 tag_630 tag_650 tag_651 tag_655 tag_700 tag_710 tag_711 tag_720 tag_752 tag_773 tag_907] }
11
11
 
12
12
  it 'get origin tags' do
13
13
  expect(dummy_class.from_tags).to eq from_tag
@@ -78,7 +78,7 @@ module BerkeleyLibrary
78
78
  selected_field_tags << '001'
79
79
  fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
80
80
  BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags = %w[255 650]
81
- expect(fields_to_map(fields).map(&:tag)).to eq %w[001 255 650 650 880] # return: Two 650 fields, one 880 field with subfield6 = '650'
81
+ expect(fields_to_map(fields).map(&:tag)).to eq %w[001 255 650 650 880] # return: Two 650 fields, one 880 field with subfield6 = '650'
82
82
  end
83
83
 
84
84
  context 'only excluding origin tags are defined ' do
@@ -14,7 +14,7 @@ module BerkeleyLibrary
14
14
  it 'Field 035 derived from mms_id' do
15
15
  f = TindField.f_035_from_alma_id('991085821143406532', 'cu_news')
16
16
  expect(f.tag).to eq '035'
17
- expect(f['a']).to eq '(cu_news)991085821143406532'
17
+ expect(f['a']).to eq '(cu_news)991085821143406532'
18
18
  end
19
19
 
20
20
  it 'Field 245$p' do
@@ -26,8 +26,8 @@ module BerkeleyLibrary
26
26
  it 'Field FFT' do
27
27
  f = TindField.f_fft('http://host/image.tif', 'news')
28
28
  expect(f.tag).to eq 'FFT'
29
- expect(f['a']).to eq 'http://host/image.tif'
30
- expect(f['d']).to eq 'news'
29
+ expect(f['a']).to eq 'http://host/image.tif'
30
+ expect(f['d']).to eq 'news'
31
31
  end
32
32
 
33
33
  it 'Field 902$d' do
@@ -40,7 +40,7 @@ module BerkeleyLibrary
40
40
  it 'Field 902$n' do
41
41
  f = TindField.f_902_n('YZ')
42
42
  expect(f.tag).to eq '902'
43
- expect(f['n']).to eq 'YZ'
43
+ expect(f['n']).to eq 'YZ'
44
44
  end
45
45
 
46
46
  it 'Field 982$p' do