berkeley_library-av-core 0.4.2 → 0.5.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +4 -4
- data/.github/workflows/gem-push.yml +2 -2
- data/.rubocop.yml +186 -2
- data/CHANGES.md +11 -1
- data/av_core.gemspec +7 -7
- data/lib/berkeley_library/av/core/module_info.rb +10 -8
- data/lib/berkeley_library/av/metadata/field.rb +1 -1
- data/lib/berkeley_library/av/metadata/fields.rb +1 -1
- data/lib/berkeley_library/av/metadata/readers/tind.rb +2 -2
- data/lib/berkeley_library/av/metadata/source.rb +6 -3
- data/lib/berkeley_library/av/track.rb +2 -2
- data/lib/berkeley_library/av/types/file_type.rb +1 -1
- data/lib/berkeley_library/av/util.rb +5 -1
- data/spec/.rubocop.yml +5 -5
- data/spec/lib/berkeley_library/av/config_spec.rb +9 -15
- data/spec/lib/berkeley_library/av/metadata/metadata_spec.rb +39 -39
- data/spec/lib/berkeley_library/av/metadata/source_spec.rb +1 -1
- data/spec/lib/berkeley_library/av/record_spec.rb +15 -11
- data/spec/lib/berkeley_library/av/track_spec.rb +8 -8
- data/spec/lib/berkeley_library/av/types/file_type_spec.rb +1 -1
- data/spec/lib/berkeley_library/av/util_spec.rb +26 -0
- metadata +20 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bda371613830dce871e6df94857ad4640047fb1ccad2dcf0f3636a20e073391
|
|
4
|
+
data.tar.gz: 8a6a032a3a4570d22a3936b2e1aacf899bb41d11e450a7479648ed95c8156dd9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 392a319af340e215892035716e27f9e0936010b478f52255c372fbb7524a0c82e606b74cc330ce9d30c6c1ba51f9279e63b37b0da510ff347fe1498d10800d67
|
|
7
|
+
data.tar.gz: 2ada9c13276b08e05d66e861a682b529389b8d32cf9e9f128ceb3c2abdfa2320ee3f90c7f9a0ac2a2e61ca3fd17dcb5d7e13ab44a44312c4d1dec17d342dbb04
|
data/.github/workflows/build.yml
CHANGED
|
@@ -6,12 +6,12 @@ jobs:
|
|
|
6
6
|
fail-fast: false
|
|
7
7
|
matrix:
|
|
8
8
|
os: [ ubuntu-latest, macos-latest ]
|
|
9
|
-
ruby: [ '3.
|
|
9
|
+
ruby: [ '3.3' ]
|
|
10
10
|
runs-on: ${{ matrix.os }}
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
13
|
- name: Check out repository
|
|
14
|
-
uses: actions/checkout@
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
15
|
|
|
16
16
|
- name: Set up Ruby
|
|
17
17
|
uses: ruby/setup-ruby@v1
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
|
|
25
25
|
- name: Upload artifacts
|
|
26
26
|
if: ${{ always() }}
|
|
27
|
-
uses: actions/upload-artifact@
|
|
27
|
+
uses: actions/upload-artifact@v4
|
|
28
28
|
with:
|
|
29
|
-
name: artifacts
|
|
29
|
+
name: artifacts-${{ matrix.os }}-${{ matrix.ruby }}
|
|
30
30
|
path: artifacts/**
|
|
@@ -13,12 +13,12 @@ jobs:
|
|
|
13
13
|
packages: write
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
17
|
|
|
18
18
|
- name: Set up Ruby
|
|
19
19
|
uses: ruby/setup-ruby@v1
|
|
20
20
|
with:
|
|
21
|
-
ruby-version: '3.
|
|
21
|
+
ruby-version: '3.3'
|
|
22
22
|
bundler-cache: true
|
|
23
23
|
|
|
24
24
|
- name: Publish to RubyGems
|
data/.rubocop.yml
CHANGED
|
@@ -102,6 +102,13 @@ Style/SingleLineBlockParams:
|
|
|
102
102
|
Style/SafeNavigation:
|
|
103
103
|
Enabled: false
|
|
104
104
|
|
|
105
|
+
# disable newer cops that require some cleanup
|
|
106
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
|
107
|
+
Enabled: false
|
|
108
|
+
|
|
109
|
+
Gemspec/DeprecatedAttributeAssignment: # (new in 1.10)
|
|
110
|
+
Enabled: false
|
|
111
|
+
|
|
105
112
|
############################################################
|
|
106
113
|
# Enable newer cops
|
|
107
114
|
|
|
@@ -187,8 +194,6 @@ Lint/TripleQuotes: # (new in 1.9)
|
|
|
187
194
|
Enabled: true
|
|
188
195
|
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
|
189
196
|
Enabled: true
|
|
190
|
-
Gemspec/DateAssignment: # (new in 1.10)
|
|
191
|
-
Enabled: true
|
|
192
197
|
Style/HashConversion: # (new in 1.10)
|
|
193
198
|
Enabled: true
|
|
194
199
|
Style/StringChars: # (new in 1.12)
|
|
@@ -239,3 +244,182 @@ Style/MapToHash: # new in 1.24
|
|
|
239
244
|
Enabled: true
|
|
240
245
|
Style/NestedFileDirname: # new in 1.26
|
|
241
246
|
Enabled: true
|
|
247
|
+
|
|
248
|
+
# newer cops
|
|
249
|
+
|
|
250
|
+
Gemspec/AddRuntimeDependency: # new in 1.65
|
|
251
|
+
Enabled: true
|
|
252
|
+
Gemspec/AttributeAssignment: # new in 1.77
|
|
253
|
+
Enabled: true
|
|
254
|
+
Layout/EmptyLinesAfterModuleInclusion: # new in 1.79
|
|
255
|
+
Enabled: true
|
|
256
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
|
257
|
+
Enabled: true
|
|
258
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
|
259
|
+
Enabled: true
|
|
260
|
+
Lint/ArrayLiteralInRegexp: # new in 1.71
|
|
261
|
+
Enabled: true
|
|
262
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
|
263
|
+
Enabled: true
|
|
264
|
+
Lint/ConstantReassignment: # new in 1.70
|
|
265
|
+
Enabled: true
|
|
266
|
+
Lint/CopDirectiveSyntax: # new in 1.72
|
|
267
|
+
Enabled: true
|
|
268
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
|
269
|
+
Enabled: true
|
|
270
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
|
271
|
+
Enabled: true
|
|
272
|
+
Lint/DuplicateSetElement: # new in 1.67
|
|
273
|
+
Enabled: true
|
|
274
|
+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
|
|
275
|
+
Enabled: true
|
|
276
|
+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
|
|
277
|
+
Enabled: true
|
|
278
|
+
Lint/LiteralAssignmentInCondition: # new in 1.58
|
|
279
|
+
Enabled: true
|
|
280
|
+
Lint/MixedCaseRange: # new in 1.53
|
|
281
|
+
Enabled: true
|
|
282
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
|
283
|
+
Enabled: true
|
|
284
|
+
Lint/NumericOperationWithConstantResult: # new in 1.69
|
|
285
|
+
Enabled: true
|
|
286
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
|
287
|
+
Enabled: true
|
|
288
|
+
Lint/RedundantTypeConversion: # new in 1.72
|
|
289
|
+
Enabled: true
|
|
290
|
+
Lint/RefinementImportMethods: # new in 1.27
|
|
291
|
+
Enabled: true
|
|
292
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
|
293
|
+
Enabled: true
|
|
294
|
+
Lint/SharedMutableDefault: # new in 1.70
|
|
295
|
+
Enabled: true
|
|
296
|
+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
|
|
297
|
+
Enabled: true
|
|
298
|
+
Lint/UnescapedBracketInRegexp: # new in 1.68
|
|
299
|
+
Enabled: true
|
|
300
|
+
Lint/UselessConstantScoping: # new in 1.72
|
|
301
|
+
Enabled: true
|
|
302
|
+
Lint/UselessDefaultValueArgument: # new in 1.76
|
|
303
|
+
Enabled: true
|
|
304
|
+
Lint/UselessDefined: # new in 1.69
|
|
305
|
+
Enabled: true
|
|
306
|
+
Lint/UselessNumericOperation: # new in 1.66
|
|
307
|
+
Enabled: true
|
|
308
|
+
Lint/UselessOr: # new in 1.76
|
|
309
|
+
Enabled: true
|
|
310
|
+
Lint/UselessRescue: # new in 1.43
|
|
311
|
+
Enabled: true
|
|
312
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
|
313
|
+
Enabled: true
|
|
314
|
+
Naming/PredicateMethod: # new in 1.76
|
|
315
|
+
Enabled: true
|
|
316
|
+
Security/CompoundHash: # new in 1.28
|
|
317
|
+
Enabled: true
|
|
318
|
+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
|
|
319
|
+
Enabled: true
|
|
320
|
+
Style/ArrayIntersect: # new in 1.40
|
|
321
|
+
Enabled: true
|
|
322
|
+
Style/ArrayIntersectWithSingleElement: # new in 1.81
|
|
323
|
+
Enabled: true
|
|
324
|
+
Style/BitwisePredicate: # new in 1.68
|
|
325
|
+
Enabled: true
|
|
326
|
+
Style/CollectionQuerying: # new in 1.77
|
|
327
|
+
Enabled: true
|
|
328
|
+
Style/CombinableDefined: # new in 1.68
|
|
329
|
+
Enabled: true
|
|
330
|
+
Style/ComparableBetween: # new in 1.74
|
|
331
|
+
Enabled: true
|
|
332
|
+
Style/ComparableClamp: # new in 1.44
|
|
333
|
+
Enabled: true
|
|
334
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
|
335
|
+
Enabled: true
|
|
336
|
+
Style/DataInheritance: # new in 1.49
|
|
337
|
+
Enabled: true
|
|
338
|
+
Style/DigChain: # new in 1.69
|
|
339
|
+
Enabled: true
|
|
340
|
+
Style/DirEmpty: # new in 1.48
|
|
341
|
+
Enabled: true
|
|
342
|
+
Style/EmptyHeredoc: # new in 1.32
|
|
343
|
+
Enabled: true
|
|
344
|
+
Style/EmptyStringInsideInterpolation: # new in 1.76
|
|
345
|
+
Enabled: true
|
|
346
|
+
Style/EnvHome: # new in 1.29
|
|
347
|
+
Enabled: true
|
|
348
|
+
Style/ExactRegexpMatch: # new in 1.51
|
|
349
|
+
Enabled: true
|
|
350
|
+
Style/FetchEnvVar: # new in 1.28
|
|
351
|
+
Enabled: true
|
|
352
|
+
Style/FileEmpty: # new in 1.48
|
|
353
|
+
Enabled: true
|
|
354
|
+
Style/FileNull: # new in 1.69
|
|
355
|
+
Enabled: true
|
|
356
|
+
Style/FileTouch: # new in 1.69
|
|
357
|
+
Enabled: true
|
|
358
|
+
Style/HashFetchChain: # new in 1.75
|
|
359
|
+
Enabled: true
|
|
360
|
+
Style/HashSlice: # new in 1.71
|
|
361
|
+
Enabled: true
|
|
362
|
+
Style/ItAssignment: # new in 1.70
|
|
363
|
+
Enabled: true
|
|
364
|
+
Style/ItBlockParameter: # new in 1.75
|
|
365
|
+
Enabled: true
|
|
366
|
+
Style/KeywordArgumentsMerging: # new in 1.68
|
|
367
|
+
Enabled: true
|
|
368
|
+
Style/MagicCommentFormat: # new in 1.35
|
|
369
|
+
Enabled: true
|
|
370
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
|
371
|
+
Enabled: true
|
|
372
|
+
Style/MapIntoArray: # new in 1.63
|
|
373
|
+
Enabled: true
|
|
374
|
+
Style/MapToSet: # new in 1.42
|
|
375
|
+
Enabled: true
|
|
376
|
+
Style/MinMaxComparison: # new in 1.42
|
|
377
|
+
Enabled: true
|
|
378
|
+
Style/ObjectThen: # new in 1.28
|
|
379
|
+
Enabled: true
|
|
380
|
+
Style/OperatorMethodCall: # new in 1.37
|
|
381
|
+
Enabled: true
|
|
382
|
+
Style/RedundantArrayConstructor: # new in 1.52
|
|
383
|
+
Enabled: true
|
|
384
|
+
Style/RedundantArrayFlatten: # new in 1.76
|
|
385
|
+
Enabled: true
|
|
386
|
+
Style/RedundantConstantBase: # new in 1.40
|
|
387
|
+
Enabled: true
|
|
388
|
+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
|
|
389
|
+
Enabled: true
|
|
390
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
|
391
|
+
Enabled: true
|
|
392
|
+
Style/RedundantEach: # new in 1.38
|
|
393
|
+
Enabled: true
|
|
394
|
+
Style/RedundantFilterChain: # new in 1.52
|
|
395
|
+
Enabled: true
|
|
396
|
+
Style/RedundantFormat: # new in 1.72
|
|
397
|
+
Enabled: true
|
|
398
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
|
399
|
+
Enabled: true
|
|
400
|
+
Style/RedundantInitialize: # new in 1.27
|
|
401
|
+
Enabled: true
|
|
402
|
+
Style/RedundantInterpolationUnfreeze: # new in 1.66
|
|
403
|
+
Enabled: true
|
|
404
|
+
Style/RedundantLineContinuation: # new in 1.49
|
|
405
|
+
Enabled: true
|
|
406
|
+
Style/RedundantRegexpArgument: # new in 1.53
|
|
407
|
+
Enabled: true
|
|
408
|
+
Style/RedundantRegexpConstructor: # new in 1.52
|
|
409
|
+
Enabled: true
|
|
410
|
+
Style/RedundantStringEscape: # new in 1.37
|
|
411
|
+
Enabled: true
|
|
412
|
+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
|
|
413
|
+
Enabled: true
|
|
414
|
+
Style/SafeNavigationChainLength: # new in 1.68
|
|
415
|
+
Enabled: true
|
|
416
|
+
Style/SendWithLiteralMethodName: # new in 1.64
|
|
417
|
+
Enabled: true
|
|
418
|
+
Style/SingleLineDoEndBlock: # new in 1.57
|
|
419
|
+
Enabled: true
|
|
420
|
+
Style/SuperArguments: # new in 1.64
|
|
421
|
+
Enabled: true
|
|
422
|
+
Style/SuperWithArgsParentheses: # new in 1.58
|
|
423
|
+
Enabled: true
|
|
424
|
+
Style/YAMLFileRead: # new in 1.53
|
|
425
|
+
Enabled: true
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# 0.5.0 (2025-11-06)
|
|
2
|
+
|
|
3
|
+
- AP-487: correctly declare mime type for mp3s
|
|
4
|
+
- dependency updates and explicit support for ruby 3.3+
|
|
5
|
+
|
|
6
|
+
# 0.4.3 (2025-11-04)
|
|
7
|
+
|
|
8
|
+
- BerkeleyLibrary::AV::Metadata::Readers:TIND now uses the /api/v1/search endpoint to retrieve records. The public /search endpoint stopped working for non-browser/human clients in the past week due to TIND changes.
|
|
9
|
+
- BerkeleyLibrary::AV::Util#do_get sources the TIND API key from ENV['LIT_TIND_API_KEY'] if it's set.
|
|
10
|
+
|
|
1
11
|
# 0.4.2 (2024-10-10)
|
|
2
12
|
|
|
3
13
|
- Add TRANSCRIPTS to `AV::METADATA::FIELDS`
|
|
@@ -18,7 +28,7 @@
|
|
|
18
28
|
- `Metadata#player_link_text`
|
|
19
29
|
- `Metadata#player_url`
|
|
20
30
|
- Remove the following constants:
|
|
21
|
-
- `AV::Constants::RESTRICTIONS_CALNET`
|
|
31
|
+
- `AV::Constants::RESTRICTIONS_CALNET`
|
|
22
32
|
- `AV::Constants::RESTRICTIONS_UCB_IP`
|
|
23
33
|
- `AV::Constants::RESTRICTIONS`
|
|
24
34
|
- `AV::Constants::RESTRICTIONS_NONE`
|
data/av_core.gemspec
CHANGED
|
@@ -10,8 +10,8 @@ require 'berkeley_library/av/core/module_info'
|
|
|
10
10
|
|
|
11
11
|
Gem::Specification.new do |spec|
|
|
12
12
|
spec.name = BerkeleyLibrary::AV::Core::ModuleInfo::NAME
|
|
13
|
-
spec.
|
|
14
|
-
spec.email = BerkeleyLibrary::AV::Core::ModuleInfo::
|
|
13
|
+
spec.authors = BerkeleyLibrary::AV::Core::ModuleInfo::AUTHORS
|
|
14
|
+
spec.email = BerkeleyLibrary::AV::Core::ModuleInfo::AUTHOR_EMAILS
|
|
15
15
|
spec.summary = BerkeleyLibrary::AV::Core::ModuleInfo::SUMMARY
|
|
16
16
|
spec.description = BerkeleyLibrary::AV::Core::ModuleInfo::DESCRIPTION
|
|
17
17
|
spec.license = BerkeleyLibrary::AV::Core::ModuleInfo::LICENSE
|
|
@@ -26,22 +26,22 @@ Gem::Specification.new do |spec|
|
|
|
26
26
|
|
|
27
27
|
spec.add_dependency 'berkeley_library-logging', '~> 0.2'
|
|
28
28
|
spec.add_dependency 'berkeley_library-marc', '~> 0.2', '>= 0.2.1'
|
|
29
|
-
spec.add_dependency 'berkeley_library-util', '~> 0.
|
|
29
|
+
spec.add_dependency 'berkeley_library-util', '~> 0.2'
|
|
30
30
|
spec.add_dependency 'ruby-marc-spec', '~> 0.1', '>= 0.1.3'
|
|
31
31
|
spec.add_dependency 'typesafe_enum', '~> 0.3'
|
|
32
32
|
|
|
33
33
|
spec.add_development_dependency 'brakeman', '~> 4.9'
|
|
34
34
|
spec.add_development_dependency 'bundle-audit', '~> 0.1'
|
|
35
35
|
spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
|
|
36
|
-
spec.add_development_dependency 'colorize', '~> 0
|
|
36
|
+
spec.add_development_dependency 'colorize', '~> 1.0'
|
|
37
37
|
spec.add_development_dependency 'dotenv', '~> 2.7'
|
|
38
38
|
spec.add_development_dependency 'irb', '~> 1.2' # workaroundfor https://github.com/bundler/bundler/issues/6929
|
|
39
39
|
spec.add_development_dependency 'listen', '>= 3.0.5', '< 3.2'
|
|
40
40
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
41
41
|
spec.add_development_dependency 'rspec-support', '~> 3.9'
|
|
42
|
-
spec.add_development_dependency 'rubocop', '1.
|
|
43
|
-
spec.add_development_dependency 'rubocop-rake', '~> 0.
|
|
44
|
-
spec.add_development_dependency 'rubocop-rspec', '~>
|
|
42
|
+
spec.add_development_dependency 'rubocop', '1.81.7'
|
|
43
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.7.1'
|
|
44
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 3.7.0'
|
|
45
45
|
spec.add_development_dependency 'simplecov', '~> 0.21'
|
|
46
46
|
spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
|
|
47
47
|
spec.add_development_dependency 'webmock', '~> 3.8'
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module BerkeleyLibrary
|
|
2
4
|
module AV
|
|
3
5
|
module Core
|
|
4
6
|
class ModuleInfo
|
|
5
|
-
NAME = 'berkeley_library-av-core'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SUMMARY = 'UC Berkeley Library audio/video core code'
|
|
9
|
-
DESCRIPTION = 'Gem for UC Berkeley Library shared audio/video code'
|
|
10
|
-
LICENSE = 'MIT'
|
|
11
|
-
VERSION = '0.
|
|
12
|
-
HOMEPAGE = 'https://github.com/BerkeleyLibrary/av-core'
|
|
7
|
+
NAME = 'berkeley_library-av-core'
|
|
8
|
+
AUTHORS = ['David Moles', 'maría a. matienzo'].freeze
|
|
9
|
+
AUTHOR_EMAILS = ['dmoles@berkeley.edu', 'matienzo@berkeley.edu'].freeze
|
|
10
|
+
SUMMARY = 'UC Berkeley Library audio/video core code'
|
|
11
|
+
DESCRIPTION = 'Gem for UC Berkeley Library shared audio/video code'
|
|
12
|
+
LICENSE = 'MIT'
|
|
13
|
+
VERSION = '0.5.0'
|
|
14
|
+
HOMEPAGE = 'https://github.com/BerkeleyLibrary/av-core'
|
|
13
15
|
|
|
14
16
|
private_class_method :new
|
|
15
17
|
end
|
|
@@ -48,7 +48,7 @@ module BerkeleyLibrary
|
|
|
48
48
|
raise ArgumentError, "Not a #{class_name(self)}: #{other}" unless other.is_a?(Field)
|
|
49
49
|
|
|
50
50
|
%i[tag query subfields_separator subfield_order].all? do |attr|
|
|
51
|
-
|
|
51
|
+
other.respond_to?(attr) && send(attr) == other.send(attr)
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -75,7 +75,7 @@ module BerkeleyLibrary
|
|
|
75
75
|
label: json_field['labels']['en'],
|
|
76
76
|
tag:,
|
|
77
77
|
spec: marc_spec,
|
|
78
|
-
subfields_separator:
|
|
78
|
+
subfields_separator: params['subfields_separator'] || ' ',
|
|
79
79
|
subfield_order: params['subfield_order'].to_s.split(',')
|
|
80
80
|
)
|
|
81
81
|
end
|
|
@@ -22,9 +22,9 @@ module BerkeleyLibrary
|
|
|
22
22
|
id_field = id_field_for(record_id)
|
|
23
23
|
query_string = URI.encode_www_form(
|
|
24
24
|
'p' => "#{id_field}:\"#{record_id}\"",
|
|
25
|
-
'
|
|
25
|
+
'format' => 'xml'
|
|
26
26
|
)
|
|
27
|
-
URIs.append(base_uri, 'search', '?', query_string)
|
|
27
|
+
URIs.append(base_uri, 'api/v1/search', '?', query_string)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
protected
|
|
@@ -34,7 +34,8 @@ module BerkeleyLibrary
|
|
|
34
34
|
|
|
35
35
|
def catalog_link_text
|
|
36
36
|
return LINK_TEXT_ALMA if self == ALMA
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
LINK_TEXT_TIND if self == TIND
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def display_uri_for(metadata)
|
|
@@ -46,7 +47,8 @@ module BerkeleyLibrary
|
|
|
46
47
|
|
|
47
48
|
def find_bib_number(metadata)
|
|
48
49
|
return alma_bib_number(metadata.marc_record) if self == Source::ALMA
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
tind_bib_number(metadata.marc_record) if self == Source::TIND
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
private
|
|
@@ -58,7 +60,8 @@ module BerkeleyLibrary
|
|
|
58
60
|
|
|
59
61
|
def canonical_record_id_accessor
|
|
60
62
|
return :alma_id if self == ALMA
|
|
61
|
-
|
|
63
|
+
|
|
64
|
+
:tind_id if self == TIND
|
|
62
65
|
end
|
|
63
66
|
|
|
64
67
|
def tind_bib_number(marc_record)
|
|
@@ -35,7 +35,7 @@ module BerkeleyLibrary
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def inspect
|
|
38
|
-
"
|
|
38
|
+
"#<#{self.class.name} #{self}>"
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# @return [Array<MARC::Subfield>]
|
|
@@ -90,7 +90,7 @@ module BerkeleyLibrary
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def group_subfields(subfields)
|
|
93
|
-
single_track = subfields.lazy.
|
|
93
|
+
single_track = subfields.lazy.one? { |sf| sf.code.to_sym == SUBFIELD_CODE_PATH }
|
|
94
94
|
return [group_together(subfields)] if single_track
|
|
95
95
|
|
|
96
96
|
group_on_paths(subfields)
|
|
@@ -56,7 +56,7 @@ module BerkeleyLibrary
|
|
|
56
56
|
# ############################################################
|
|
57
57
|
# Enum members
|
|
58
58
|
|
|
59
|
-
new(:MP3, 'audio', '
|
|
59
|
+
new(:MP3, 'audio', 'audio/mpeg', extensions: MP3_EXTENSIONS)
|
|
60
60
|
new(:MP4, 'video', 'video/mp4', extensions: MP4_EXTENSIONS)
|
|
61
61
|
new(:UNKNOWN, 'object', 'application/octet-stream', label: 'Unknown')
|
|
62
62
|
|
|
@@ -12,7 +12,11 @@ module BerkeleyLibrary
|
|
|
12
12
|
DEFAULT_USER_AGENT = "#{Core::ModuleInfo::NAME} #{Core::ModuleInfo::VERSION} (#{Core::ModuleInfo::HOMEPAGE})".freeze
|
|
13
13
|
|
|
14
14
|
def do_get(uri, ignore_errors: false)
|
|
15
|
-
|
|
15
|
+
headers = { user_agent: DEFAULT_USER_AGENT }
|
|
16
|
+
if uri.to_s.start_with?(BerkeleyLibrary::AV::Config.tind_base_uri.to_s) && ENV['LIT_TIND_API_KEY']
|
|
17
|
+
headers[:authorization] = "Token #{ENV['LIT_TIND_API_KEY']}"
|
|
18
|
+
end
|
|
19
|
+
body = URIs.get(uri, headers:)
|
|
16
20
|
body && body.scrub
|
|
17
21
|
rescue RestClient::Exception
|
|
18
22
|
raise unless ignore_errors
|
data/spec/.rubocop.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
inherit_from: ../.rubocop.yml
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
plugins:
|
|
4
4
|
- rubocop-rspec
|
|
5
5
|
|
|
6
6
|
Layout/LineLength:
|
|
@@ -65,7 +65,10 @@ RSpec/ExpectInHook:
|
|
|
65
65
|
Enabled: false
|
|
66
66
|
|
|
67
67
|
# your naming scheme is not in possession of all the facts
|
|
68
|
-
RSpec/
|
|
68
|
+
RSpec/SpecFilePathFormat:
|
|
69
|
+
Enabled: false
|
|
70
|
+
|
|
71
|
+
RSpec/SpecFilePathSuffix:
|
|
69
72
|
Enabled: false
|
|
70
73
|
|
|
71
74
|
# explicit >>> implicit
|
|
@@ -111,6 +114,3 @@ RSpec/VerifiedDoubles:
|
|
|
111
114
|
|
|
112
115
|
RSpec/IdenticalEqualityAssertion: # new in 2.4
|
|
113
116
|
Enabled: true
|
|
114
|
-
|
|
115
|
-
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
|
116
|
-
Enabled: true
|
|
@@ -11,7 +11,7 @@ module BerkeleyLibrary
|
|
|
11
11
|
|
|
12
12
|
describe :configured? do
|
|
13
13
|
it 'defaults to false' do
|
|
14
|
-
expect(AV.configured?).to
|
|
14
|
+
expect(AV.configured?).to be(false)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'returns true if and only if all values are configured' do
|
|
@@ -25,12 +25,12 @@ module BerkeleyLibrary
|
|
|
25
25
|
wowza_base_uri: 'http://wowza.example.edu'
|
|
26
26
|
}
|
|
27
27
|
settings.each { |setting, value| Config.send("#{setting}=", value) }
|
|
28
|
-
expect(AV.configured?).to
|
|
28
|
+
expect(AV.configured?).to be(true)
|
|
29
29
|
|
|
30
30
|
aggregate_failures do
|
|
31
31
|
settings.each do |setting, value|
|
|
32
|
-
Config.instance_variable_set("@#{setting}"
|
|
33
|
-
expect(AV.configured?).to
|
|
32
|
+
Config.instance_variable_set(:"@#{setting}", nil)
|
|
33
|
+
expect(AV.configured?).to be(false), "Clearing #{setting} did not set configured? to false"
|
|
34
34
|
Config.send("#{setting}=", value)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -49,8 +49,7 @@ module BerkeleyLibrary
|
|
|
49
49
|
rails_config = Struct.new(*settings.keys, keyword_init: true).new(**settings)
|
|
50
50
|
|
|
51
51
|
# Mock Rails config
|
|
52
|
-
|
|
53
|
-
Object.send(:const_set, 'Rails', Struct.new(:application).new)
|
|
52
|
+
stub_const('Rails', Struct.new(:application).new)
|
|
54
53
|
Rails.application = Struct.new(:config).new
|
|
55
54
|
Rails.application.config = rails_config
|
|
56
55
|
|
|
@@ -60,9 +59,8 @@ module BerkeleyLibrary
|
|
|
60
59
|
end
|
|
61
60
|
end
|
|
62
61
|
|
|
63
|
-
expect(AV.configured?).to
|
|
64
|
-
|
|
65
|
-
Object.send(:remove_const, 'Rails')
|
|
62
|
+
expect(AV.configured?).to be(true)
|
|
63
|
+
|
|
66
64
|
end
|
|
67
65
|
end
|
|
68
66
|
|
|
@@ -100,7 +98,7 @@ module BerkeleyLibrary
|
|
|
100
98
|
|
|
101
99
|
expected = []
|
|
102
100
|
settings.each_key do |setting|
|
|
103
|
-
Config.instance_variable_set("@#{setting}"
|
|
101
|
+
Config.instance_variable_set(:"@#{setting}", nil)
|
|
104
102
|
expected << setting
|
|
105
103
|
expect(Config.missing).to eq(expected)
|
|
106
104
|
end
|
|
@@ -246,11 +244,7 @@ module BerkeleyLibrary
|
|
|
246
244
|
rails = double(Object)
|
|
247
245
|
allow(rails).to receive(:application).and_return(application)
|
|
248
246
|
|
|
249
|
-
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
after do
|
|
253
|
-
Object.send(:remove_const, :Rails)
|
|
247
|
+
stub_const('Rails', rails)
|
|
254
248
|
end
|
|
255
249
|
|
|
256
250
|
describe :avplayer_base_uri do
|
|
@@ -44,28 +44,28 @@ module BerkeleyLibrary
|
|
|
44
44
|
bib_number = 'b18538031'
|
|
45
45
|
stub_sru_request(bib_number)
|
|
46
46
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
47
|
-
expect(metadata.calnet_or_ip?).to
|
|
47
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it 'detects restricted video' do
|
|
51
51
|
bib_number = 'b25207857'
|
|
52
52
|
stub_sru_request(bib_number)
|
|
53
53
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
54
|
-
expect(metadata.calnet_or_ip?).to
|
|
54
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'detects CalNet restrictions' do
|
|
58
58
|
bib_number = 'b24659129'
|
|
59
59
|
stub_sru_request(bib_number)
|
|
60
60
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
61
|
-
expect(metadata.calnet_or_ip?).to
|
|
61
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it 'detects unrestricted audio' do
|
|
65
65
|
bib_number = 'b23161018'
|
|
66
66
|
stub_sru_request(bib_number)
|
|
67
67
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
68
|
-
expect(metadata.calnet_or_ip?).to
|
|
68
|
+
expect(metadata.calnet_or_ip?).to be(false)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -75,89 +75,89 @@ module BerkeleyLibrary
|
|
|
75
75
|
bib_number = 'b18538031'
|
|
76
76
|
stub_sru_request(bib_number)
|
|
77
77
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
78
|
-
expect(metadata.calnet_or_ip?).to
|
|
78
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it 'finds "UCB Access" (capitalized)' do
|
|
82
82
|
bib_number = 'b25716973'
|
|
83
83
|
stub_sru_request(bib_number)
|
|
84
84
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
85
|
-
expect(metadata.calnet_or_ip?).to
|
|
86
|
-
expect(metadata.calnet_only?).to
|
|
85
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
86
|
+
expect(metadata.calnet_only?).to be(false)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it 'returns "Requires CalNet"' do
|
|
90
90
|
bib_number = 'b24659129'
|
|
91
91
|
stub_sru_request(bib_number)
|
|
92
92
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
93
|
-
expect(metadata.calnet_or_ip?).to
|
|
94
|
-
expect(metadata.calnet_only?).to
|
|
93
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
94
|
+
expect(metadata.calnet_only?).to be(true)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it 'returns "Freely available" for unrestricted audio' do
|
|
98
98
|
bib_number = 'b23161018'
|
|
99
99
|
stub_sru_request(bib_number)
|
|
100
100
|
metadata = Metadata.for_record(record_id: bib_number)
|
|
101
|
-
expect(metadata.calnet_or_ip?).to
|
|
102
|
-
expect(metadata.calnet_only?).to
|
|
101
|
+
expect(metadata.calnet_or_ip?).to be(false)
|
|
102
|
+
expect(metadata.calnet_only?).to be(false)
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
it 'extracts UCB restrictions from a TIND 856' do
|
|
106
106
|
marc_record = MARC::XMLReader.new('spec/data/record-(cityarts)00002.xml').first
|
|
107
107
|
metadata = Metadata.new(record_id: 'record-(cityarts)00002', source: Metadata::Source::TIND, marc_record:)
|
|
108
|
-
expect(metadata.calnet_or_ip?).to
|
|
109
|
-
expect(metadata.calnet_only?).to
|
|
108
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
109
|
+
expect(metadata.calnet_only?).to be(false)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
it 'extracts UCB restrictions from an Alma 956' do
|
|
113
113
|
marc_record = MARC::XMLReader.new('spec/data/alma/991054360089706532-sru.xml').first
|
|
114
114
|
metadata = Metadata.new(record_id: '991047179369706532', source: Metadata::Source::ALMA, marc_record:)
|
|
115
|
-
expect(metadata.calnet_or_ip?).to
|
|
116
|
-
expect(metadata.calnet_only?).to
|
|
115
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
116
|
+
expect(metadata.calnet_only?).to be(false)
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it 'extracts CalNet restrictions from an Alma 956' do
|
|
120
120
|
marc_record = MARC::XMLReader.new('spec/data/alma/991047179369706532-sru.xml').first
|
|
121
121
|
metadata = Metadata.new(record_id: '991054360089706532', source: Metadata::Source::ALMA, marc_record:)
|
|
122
|
-
expect(metadata.calnet_or_ip?).to
|
|
123
|
-
expect(metadata.calnet_only?).to
|
|
122
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
123
|
+
expect(metadata.calnet_only?).to be(true)
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it 'extracts restrictions from a 998$r' do
|
|
127
127
|
marc_record = MARC::XMLReader.new('spec/data/alma/991005939359706532-sru.xml').first
|
|
128
128
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
129
|
-
expect(metadata.calnet_or_ip?).to
|
|
130
|
-
expect(metadata.calnet_only?).to
|
|
129
|
+
expect(metadata.calnet_or_ip?).to be(false) # just to be sure
|
|
130
|
+
expect(metadata.calnet_only?).to be(false) # just to be sure
|
|
131
131
|
|
|
132
132
|
marc_record['998'].append(MARC::Subfield.new('r', 'UCB access. Requires CalNet.'))
|
|
133
133
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
134
|
-
expect(metadata.calnet_or_ip?).to
|
|
135
|
-
expect(metadata.calnet_only?).to
|
|
134
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
135
|
+
expect(metadata.calnet_only?).to be(true)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it 'extracts restrictions from multiple subfields 998$r' do
|
|
139
139
|
marc_record = MARC::XMLReader.new('spec/data/alma/991005939359706532-sru.xml').first
|
|
140
140
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
141
|
-
expect(metadata.calnet_or_ip?).to
|
|
142
|
-
expect(metadata.calnet_only?).to
|
|
141
|
+
expect(metadata.calnet_or_ip?).to be(false) # just to be sure
|
|
142
|
+
expect(metadata.calnet_only?).to be(false) # just to be sure
|
|
143
143
|
|
|
144
144
|
marc_record['998'].append(MARC::Subfield.new('r', 'UCB access.'))
|
|
145
145
|
marc_record['998'].append(MARC::Subfield.new('r', 'Requires CalNet.'))
|
|
146
146
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
147
|
-
expect(metadata.calnet_or_ip?).to
|
|
148
|
-
expect(metadata.calnet_only?).to
|
|
147
|
+
expect(metadata.calnet_or_ip?).to be(true)
|
|
148
|
+
expect(metadata.calnet_only?).to be(true)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
it 'accepts "CalNet" anywhere in the 998$r' do
|
|
152
152
|
marc_record = MARC::XMLReader.new('spec/data/alma/991005939359706532-sru.xml').first
|
|
153
153
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
154
|
-
expect(metadata.calnet_or_ip?).to
|
|
155
|
-
expect(metadata.calnet_only?).to
|
|
154
|
+
expect(metadata.calnet_or_ip?).to be(false) # just to be sure
|
|
155
|
+
expect(metadata.calnet_only?).to be(false) # just to be sure
|
|
156
156
|
|
|
157
157
|
marc_record['998'].append(MARC::Subfield.new('r', 'some string with CalNet in it somewhere'))
|
|
158
158
|
metadata = Metadata.new(record_id: '991005939359706532', source: Metadata::Source::ALMA, marc_record:)
|
|
159
|
-
expect(metadata.calnet_only?).to
|
|
160
|
-
expect(metadata.calnet_or_ip?).to
|
|
159
|
+
expect(metadata.calnet_only?).to be(true)
|
|
160
|
+
expect(metadata.calnet_or_ip?).to be(false) # just to be sure
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -177,13 +177,13 @@ module BerkeleyLibrary
|
|
|
177
177
|
body: AV::Metadata::Source::ALMA.catalog_link_text
|
|
178
178
|
)
|
|
179
179
|
]
|
|
180
|
-
expect(catalog_value.entries).to
|
|
180
|
+
expect(catalog_value.entries).to match_array(expected_links)
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
it 'injects a TIND URL if not present (1/2)' do
|
|
184
184
|
tind_035 = '(miscmat)00615'
|
|
185
185
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
186
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
186
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
187
187
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
188
188
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
189
189
|
|
|
@@ -194,13 +194,13 @@ module BerkeleyLibrary
|
|
|
194
194
|
body: Metadata::Source::TIND.catalog_link_text
|
|
195
195
|
)
|
|
196
196
|
]
|
|
197
|
-
expect(catalog_value.entries).to
|
|
197
|
+
expect(catalog_value.entries).to match_array(expected_links)
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
it 'injects a TIND URL if not present (2/2)' do
|
|
201
201
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
202
202
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
203
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
203
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
204
204
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
205
205
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
206
206
|
|
|
@@ -211,14 +211,14 @@ module BerkeleyLibrary
|
|
|
211
211
|
body: Metadata::Source::TIND.catalog_link_text
|
|
212
212
|
)
|
|
213
213
|
]
|
|
214
|
-
expect(catalog_value.entries).to
|
|
214
|
+
expect(catalog_value.entries).to match_array(expected_links)
|
|
215
215
|
end
|
|
216
216
|
|
|
217
217
|
# TODO: suppress these?
|
|
218
218
|
it 'works for TIND records with OskiCat URLs' do
|
|
219
219
|
tind_035 = '(pacradio)00107'
|
|
220
220
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
221
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
221
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
222
222
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
223
223
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
224
224
|
|
|
@@ -233,13 +233,13 @@ module BerkeleyLibrary
|
|
|
233
233
|
body: Metadata::Source::TIND.catalog_link_text
|
|
234
234
|
)
|
|
235
235
|
]
|
|
236
|
-
expect(catalog_value.entries).to
|
|
236
|
+
expect(catalog_value.entries).to match_array(expected_links)
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
it 'works for TIND-only records' do
|
|
240
240
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
241
241
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
242
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
242
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
243
243
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
244
244
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
245
245
|
|
|
@@ -250,7 +250,7 @@ module BerkeleyLibrary
|
|
|
250
250
|
url: 'https://digicoll.lib.berkeley.edu/record/21937'
|
|
251
251
|
)
|
|
252
252
|
]
|
|
253
|
-
expect(catalog_value.entries).to
|
|
253
|
+
expect(catalog_value.entries).to match_array(expected_links)
|
|
254
254
|
end
|
|
255
255
|
|
|
256
256
|
end
|
|
@@ -259,7 +259,7 @@ module BerkeleyLibrary
|
|
|
259
259
|
it 'returns the values' do
|
|
260
260
|
tind_035 = 'physcolloquia-bk00169017b'
|
|
261
261
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
262
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
262
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
263
263
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
264
264
|
metadata = Metadata.for_record(record_id: tind_035)
|
|
265
265
|
|
|
@@ -161,7 +161,7 @@ module BerkeleyLibrary
|
|
|
161
161
|
|
|
162
162
|
before do
|
|
163
163
|
AV::Config.tind_base_uri = 'https://digicoll.lib.berkeley.edu'
|
|
164
|
-
@record_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2900107%22&
|
|
164
|
+
@record_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2900107%22&format=xml'
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
after do
|
|
@@ -46,7 +46,7 @@ module BerkeleyLibrary
|
|
|
46
46
|
it 'returns a player URI based on the record ID for TIND records' do
|
|
47
47
|
tind_035 = '(pacradio)01469'
|
|
48
48
|
marc_xml = File.read("spec/data/record-#{tind_035}.xml")
|
|
49
|
-
search_url = "https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&
|
|
49
|
+
search_url = "https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22#{CGI.escape(tind_035)}%22&format=xml"
|
|
50
50
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
51
51
|
|
|
52
52
|
collection = 'Pacifica'
|
|
@@ -145,7 +145,7 @@ module BerkeleyLibrary
|
|
|
145
145
|
|
|
146
146
|
it 'returns the TIND ID for TIND records' do
|
|
147
147
|
marc_xml = File.read('spec/data/record-(pacradio)01469.xml')
|
|
148
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
148
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
149
149
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
150
150
|
|
|
151
151
|
record = Record.from_metadata(
|
|
@@ -168,7 +168,7 @@ module BerkeleyLibrary
|
|
|
168
168
|
it 'returns nil for TIND records with no bib number' do
|
|
169
169
|
tind_id = '(clir)00020'
|
|
170
170
|
marc_xml = File.read('spec/data/record-(clir)00020.xml')
|
|
171
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28clir%2900020%22&
|
|
171
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28clir%2900020%22&format=xml'
|
|
172
172
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
173
173
|
|
|
174
174
|
record = Record.from_metadata(collection: 'Video-Public-Bancroft', record_id: tind_id)
|
|
@@ -177,9 +177,10 @@ module BerkeleyLibrary
|
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
describe :from_metadata do
|
|
180
|
+
# rubocop:disable RSpec/ExampleLength
|
|
180
181
|
it 'loads the metadata' do
|
|
181
182
|
marc_xml = File.read('spec/data/record-(pacradio)01469.xml')
|
|
182
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
183
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
183
184
|
stub_request(:get, search_url).to_return(status: 200, body: marc_xml)
|
|
184
185
|
|
|
185
186
|
record = Record.from_metadata(collection: 'Pacifica', record_id: '(pacradio)01469')
|
|
@@ -220,10 +221,11 @@ module BerkeleyLibrary
|
|
|
220
221
|
expect(record.title).to eq(metadata.title)
|
|
221
222
|
expect(record.bib_number).to eq(metadata.bib_number)
|
|
222
223
|
end
|
|
224
|
+
# rubocop:enable RSpec/ExampleLength
|
|
223
225
|
end
|
|
224
226
|
|
|
225
227
|
it "raises #{AV::RecordNotFound} if the record cannot be found" do
|
|
226
|
-
search_url = 'https://digicoll.lib.berkeley.edu/search?p=035__a%3A%22%28pacradio%2901469%22&
|
|
228
|
+
search_url = 'https://digicoll.lib.berkeley.edu/api/v1/search?p=035__a%3A%22%28pacradio%2901469%22&format=xml'
|
|
227
229
|
stub_request(:get, search_url).to_return(status: 404)
|
|
228
230
|
expect do
|
|
229
231
|
Record.from_metadata(
|
|
@@ -234,6 +236,7 @@ module BerkeleyLibrary
|
|
|
234
236
|
end
|
|
235
237
|
end
|
|
236
238
|
|
|
239
|
+
# rubocop:disable RSpec/ExampleLength
|
|
237
240
|
describe :calnet_or_ip? do
|
|
238
241
|
it 'returns true for restricted, false for unrestricted' do
|
|
239
242
|
restricted = %w[b18538031 b24071548 (cityarts)00002 (cityarts)00773]
|
|
@@ -251,32 +254,33 @@ module BerkeleyLibrary
|
|
|
251
254
|
aggregate_failures 'restrictions' do
|
|
252
255
|
restricted.each do |record_id|
|
|
253
256
|
record = Record.from_metadata(collection: 'test', record_id:)
|
|
254
|
-
expect(record.calnet_or_ip?).to
|
|
257
|
+
expect(record.calnet_or_ip?).to be(true), "Expected #{record_id} to be restricted, was not"
|
|
255
258
|
end
|
|
256
259
|
|
|
257
260
|
unrestricted.each do |record_id|
|
|
258
261
|
record = Record.from_metadata(collection: 'test', record_id:)
|
|
259
|
-
expect(record.calnet_or_ip?).to
|
|
262
|
+
expect(record.calnet_or_ip?).to be(false), "Expected #{record_id} not to be restricted, was"
|
|
260
263
|
end
|
|
261
264
|
end
|
|
262
265
|
end
|
|
263
266
|
end
|
|
267
|
+
# rubocop:enable RSpec/ExampleLength
|
|
264
268
|
|
|
265
269
|
describe :calnet_only? do
|
|
266
270
|
it 'returns true for CalNet-only records' do
|
|
267
271
|
mms_id = '991047179369706532'
|
|
268
272
|
stub_sru_request(mms_id)
|
|
269
273
|
record = Record.from_metadata(collection: 'test', record_id: mms_id)
|
|
270
|
-
expect(record.calnet_or_ip?).to
|
|
271
|
-
expect(record.calnet_only?).to
|
|
274
|
+
expect(record.calnet_or_ip?).to be(true)
|
|
275
|
+
expect(record.calnet_only?).to be(true)
|
|
272
276
|
end
|
|
273
277
|
|
|
274
278
|
it 'returns false for records open to UCB IP addresses' do
|
|
275
279
|
mms_id = '991054360089706532'
|
|
276
280
|
stub_sru_request(mms_id)
|
|
277
281
|
record = Record.from_metadata(collection: 'test', record_id: mms_id)
|
|
278
|
-
expect(record.calnet_or_ip?).to
|
|
279
|
-
expect(record.calnet_only?).to
|
|
282
|
+
expect(record.calnet_or_ip?).to be(true)
|
|
283
|
+
expect(record.calnet_only?).to be(false)
|
|
280
284
|
end
|
|
281
285
|
end
|
|
282
286
|
end
|
|
@@ -26,34 +26,34 @@ module BerkeleyLibrary
|
|
|
26
26
|
describe :<=> do
|
|
27
27
|
it 'treats object as equal to itself' do
|
|
28
28
|
track = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
29
|
-
expect(track == track).to
|
|
29
|
+
expect(track == track).to be(true)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it 'treats object as equal to identical object' do
|
|
33
33
|
t1 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
34
34
|
t2 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
35
|
-
expect(t1 == t2).to
|
|
35
|
+
expect(t1 == t2).to be(true)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'sorts by sort order' do
|
|
39
39
|
t1 = Track.new(sort_order: 3, title: 'Part 2', path: 'frost-read2.mp3')
|
|
40
40
|
t2 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
41
|
-
expect(t1 > t2).to
|
|
42
|
-
expect(t2 < t1).to
|
|
41
|
+
expect(t1 > t2).to be(true)
|
|
42
|
+
expect(t2 < t1).to be(true)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'sorts by title' do
|
|
46
46
|
t1 = Track.new(sort_order: 2, title: 'Part 3', path: 'frost-read2.mp3')
|
|
47
47
|
t2 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
48
|
-
expect(t1 > t2).to
|
|
49
|
-
expect(t2 < t1).to
|
|
48
|
+
expect(t1 > t2).to be(true)
|
|
49
|
+
expect(t2 < t1).to be(true)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it 'sorts by path' do
|
|
53
53
|
t1 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp4')
|
|
54
54
|
t2 = Track.new(sort_order: 2, title: 'Part 2', path: 'frost-read2.mp3')
|
|
55
|
-
expect(t1 > t2).to
|
|
56
|
-
expect(t2 < t1).to
|
|
55
|
+
expect(t1 > t2).to be(true)
|
|
56
|
+
expect(t2 < t1).to be(true)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it 'returns nil for nil' do
|
|
@@ -24,6 +24,32 @@ module BerkeleyLibrary
|
|
|
24
24
|
result = AV::Util.do_get(url, ignore_errors: true)
|
|
25
25
|
expect(result).to be_nil
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
it 'includes authorization header for TIND requests if LIT_TIND_API_KEY is set' do
|
|
29
|
+
expected_ua = Util::DEFAULT_USER_AGENT
|
|
30
|
+
expected_auth = 'Token some-long-api-token-value'
|
|
31
|
+
|
|
32
|
+
# expect do_get to call URIs.get with the correct headers
|
|
33
|
+
# but we don't need to actually perform the request
|
|
34
|
+
allow(BerkeleyLibrary::Util::URIs).to receive(:get).and_return('<response></response>')
|
|
35
|
+
allow(AV::Config).to receive(:tind_base_uri).and_return(URI('https://tind.example.edu/'))
|
|
36
|
+
url = "#{AV::Config.tind_base_uri}/some/api/endpoint"
|
|
37
|
+
ENV['LIT_TIND_API_KEY'] = 'some-long-api-token-value'
|
|
38
|
+
AV::Util.do_get(url)
|
|
39
|
+
expect(BerkeleyLibrary::Util::URIs).to have_received(:get).with(url, headers: { user_agent: expected_ua, authorization: expected_auth })
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'does not include authorization header for non-TIND requests' do
|
|
43
|
+
expected_ua = Util::DEFAULT_USER_AGENT
|
|
44
|
+
|
|
45
|
+
# expect do_get to call URIs.get with the correct headers
|
|
46
|
+
# but we don't need to actually perform the request
|
|
47
|
+
allow(BerkeleyLibrary::Util::URIs).to receive(:get).and_return('<response></response>')
|
|
48
|
+
url = URI('https://alma.example.edu/some/api/endpoint')
|
|
49
|
+
ENV['LIT_TIND_API_KEY'] = nil
|
|
50
|
+
AV::Util.do_get(url)
|
|
51
|
+
expect(BerkeleyLibrary::Util::URIs).to have_received(:get).with(url, headers: { user_agent: expected_ua })
|
|
52
|
+
end
|
|
27
53
|
end
|
|
28
54
|
end
|
|
29
55
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: berkeley_library-av-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Moles
|
|
8
|
-
|
|
8
|
+
- maría a. matienzo
|
|
9
|
+
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2025-11-06 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: berkeley_library-logging
|
|
@@ -50,20 +51,14 @@ dependencies:
|
|
|
50
51
|
requirements:
|
|
51
52
|
- - "~>"
|
|
52
53
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.1.1
|
|
54
|
+
version: '0.2'
|
|
57
55
|
type: :runtime
|
|
58
56
|
prerelease: false
|
|
59
57
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
58
|
requirements:
|
|
61
59
|
- - "~>"
|
|
62
60
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: '0.
|
|
64
|
-
- - ">="
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: 0.1.1
|
|
61
|
+
version: '0.2'
|
|
67
62
|
- !ruby/object:Gem::Dependency
|
|
68
63
|
name: ruby-marc-spec
|
|
69
64
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -146,14 +141,14 @@ dependencies:
|
|
|
146
141
|
requirements:
|
|
147
142
|
- - "~>"
|
|
148
143
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '0
|
|
144
|
+
version: '1.0'
|
|
150
145
|
type: :development
|
|
151
146
|
prerelease: false
|
|
152
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
153
148
|
requirements:
|
|
154
149
|
- - "~>"
|
|
155
150
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '0
|
|
151
|
+
version: '1.0'
|
|
157
152
|
- !ruby/object:Gem::Dependency
|
|
158
153
|
name: dotenv
|
|
159
154
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -236,42 +231,42 @@ dependencies:
|
|
|
236
231
|
requirements:
|
|
237
232
|
- - '='
|
|
238
233
|
- !ruby/object:Gem::Version
|
|
239
|
-
version: 1.
|
|
234
|
+
version: 1.81.7
|
|
240
235
|
type: :development
|
|
241
236
|
prerelease: false
|
|
242
237
|
version_requirements: !ruby/object:Gem::Requirement
|
|
243
238
|
requirements:
|
|
244
239
|
- - '='
|
|
245
240
|
- !ruby/object:Gem::Version
|
|
246
|
-
version: 1.
|
|
241
|
+
version: 1.81.7
|
|
247
242
|
- !ruby/object:Gem::Dependency
|
|
248
243
|
name: rubocop-rake
|
|
249
244
|
requirement: !ruby/object:Gem::Requirement
|
|
250
245
|
requirements:
|
|
251
246
|
- - "~>"
|
|
252
247
|
- !ruby/object:Gem::Version
|
|
253
|
-
version: 0.
|
|
248
|
+
version: 0.7.1
|
|
254
249
|
type: :development
|
|
255
250
|
prerelease: false
|
|
256
251
|
version_requirements: !ruby/object:Gem::Requirement
|
|
257
252
|
requirements:
|
|
258
253
|
- - "~>"
|
|
259
254
|
- !ruby/object:Gem::Version
|
|
260
|
-
version: 0.
|
|
255
|
+
version: 0.7.1
|
|
261
256
|
- !ruby/object:Gem::Dependency
|
|
262
257
|
name: rubocop-rspec
|
|
263
258
|
requirement: !ruby/object:Gem::Requirement
|
|
264
259
|
requirements:
|
|
265
260
|
- - "~>"
|
|
266
261
|
- !ruby/object:Gem::Version
|
|
267
|
-
version:
|
|
262
|
+
version: 3.7.0
|
|
268
263
|
type: :development
|
|
269
264
|
prerelease: false
|
|
270
265
|
version_requirements: !ruby/object:Gem::Requirement
|
|
271
266
|
requirements:
|
|
272
267
|
- - "~>"
|
|
273
268
|
- !ruby/object:Gem::Version
|
|
274
|
-
version:
|
|
269
|
+
version: 3.7.0
|
|
275
270
|
- !ruby/object:Gem::Dependency
|
|
276
271
|
name: simplecov
|
|
277
272
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -315,7 +310,9 @@ dependencies:
|
|
|
315
310
|
- !ruby/object:Gem::Version
|
|
316
311
|
version: '3.8'
|
|
317
312
|
description: Gem for UC Berkeley Library shared audio/video code
|
|
318
|
-
email:
|
|
313
|
+
email:
|
|
314
|
+
- dmoles@berkeley.edu
|
|
315
|
+
- matienzo@berkeley.edu
|
|
319
316
|
executables: []
|
|
320
317
|
extensions: []
|
|
321
318
|
extra_rdoc_files: []
|
|
@@ -428,7 +425,7 @@ licenses:
|
|
|
428
425
|
- MIT
|
|
429
426
|
metadata:
|
|
430
427
|
rubygems_mfa_required: 'true'
|
|
431
|
-
post_install_message:
|
|
428
|
+
post_install_message:
|
|
432
429
|
rdoc_options: []
|
|
433
430
|
require_paths:
|
|
434
431
|
- lib
|
|
@@ -443,8 +440,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
443
440
|
- !ruby/object:Gem::Version
|
|
444
441
|
version: '0'
|
|
445
442
|
requirements: []
|
|
446
|
-
rubygems_version: 3.
|
|
447
|
-
signing_key:
|
|
443
|
+
rubygems_version: 3.5.22
|
|
444
|
+
signing_key:
|
|
448
445
|
specification_version: 4
|
|
449
446
|
summary: UC Berkeley Library audio/video core code
|
|
450
447
|
test_files:
|