berkeley_library-marc 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25ed54f0bd91408a2bc16d7d51525e4bfe7086bf9b3a507b2e40a846432fff32
4
- data.tar.gz: 135562e29c813d72f4830bfd8413a79c6480c2f7c5c396621a14ccdc22732432
3
+ metadata.gz: 79af51b1f4eafdf2e0513feba8d3770d17f4deedbf06338d53546227946220e5
4
+ data.tar.gz: 8e75143bfa04241f2ef4cfcf5c7a3ec8e966d56d7e53acf1c699f02ae8cb4fc9
5
5
  SHA512:
6
- metadata.gz: 968f53042e1d9b390c842ecc30f2b531ac58a17b49670ede19d9458a5559d93bb7c689c3665028a5c77d80cd892112468ad20b424aac72b420850b759529d6c1
7
- data.tar.gz: d454a28e68812c807dcab0908317a566ff7949a3c66e3d22bb2374a457cee4dcb86c2cbb78ea69bcc4cd855cd74cb3b5e27a4cad016faec80276d3eec4860d03
6
+ metadata.gz: 75edae26fe5286775dd5913138a7ce67af8148d05c775c2c419aeda457a83e0cdd7f951297b0567af735b5b7c863b1d28c1348cad73e4b3761c2fcc6b8df55ac
7
+ data.tar.gz: b2f038b42bd85e7804d6163c1db865327f7f924542336e92326965319b2066bc5689649e4f3c1b527ec112b85e38e75c897811bdebf6d1fdbcf929baff11831a
data/.idea/marc.iml CHANGED
@@ -22,7 +22,7 @@
22
22
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.5) [gem]" level="application" />
23
23
  <orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
24
24
  <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.7.6, RVM: ruby-2.7.5) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.4, RVM: ruby-2.7.5) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, RVM: ruby-2.7.5) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="listen (v3.1.5, RVM: ruby-2.7.5) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="marc (v1.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
28
28
  <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.1, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -30,7 +30,7 @@
30
30
  <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
31
31
  <orderEntry type="library" scope="PROVIDED" name="parslet (v2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
32
32
  <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, RVM: ruby-2.7.5) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
34
34
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
35
35
  <orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
36
36
  <orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.10.1, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -38,7 +38,7 @@
38
38
  <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.5) [gem]" level="application" />
39
39
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
40
40
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, RVM: ruby-2.7.5) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, RVM: ruby-2.7.5) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.2, RVM: ruby-2.7.5) [gem]" level="application" />
42
42
  <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, RVM: ruby-2.7.5) [gem]" level="application" />
43
43
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.3, RVM: ruby-2.7.5) [gem]" level="application" />
44
44
  <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.11.0, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -54,7 +54,7 @@
54
54
  <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-2.7.5) [gem]" level="application" />
55
55
  <orderEntry type="library" scope="PROVIDED" name="simplecov-rcov (v0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
56
56
  <orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.3, RVM: ruby-2.7.5) [gem]" level="application" />
57
- <orderEntry type="library" scope="PROVIDED" name="thor (v1.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.5) [gem]" level="application" />
58
58
  <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.0, RVM: ruby-2.7.5) [gem]" level="application" />
59
59
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
60
60
  <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -77,7 +77,7 @@
77
77
  </RakeTaskImpl>
78
78
  <RakeTaskImpl description="Run all specs in spec directory, with coverage" fullCommand="coverage" id="coverage" />
79
79
  <RakeTaskImpl description="Run tests, check test coverage, check code style, check for vulnerabilities, build gem" fullCommand="default" id="default" />
80
- <RakeTaskImpl description="Build berkeley_library-marc.gemspec as berkeley_library-marc-0.2.2.gem" fullCommand="gem" id="gem" />
80
+ <RakeTaskImpl description="Build berkeley_library-marc.gemspec as berkeley_library-marc-0.3.1.gem" fullCommand="gem" id="gem" />
81
81
  <RakeTaskImpl description="Run RuboCop with auto-correct, and output results to console" fullCommand="ra" id="ra" />
82
82
  <RakeTaskImpl description="Run rubocop with HTML output" fullCommand="rubocop" id="rubocop" />
83
83
  <RakeTaskImpl id="rubocop">
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.3.1 (2022-01-26)
2
+
3
+ - Fixes issue where `MARC::XMLReader#new` and `MARC::XMLReader#read` would
4
+ accept keyword arguments under Ruby 2.7.x, but not under Ruby 3.x; both
5
+ methods should now accept either keyword arguments or an options hash,
6
+ under either Ruby version.
7
+
1
8
  # 0.3.0 (2022-01-25)
2
9
 
3
10
  Fixes:
@@ -24,7 +24,7 @@ module BerkeleyLibrary
24
24
  LICENSE = 'MIT'.freeze
25
25
 
26
26
  # Gem version
27
- VERSION = '0.3.0'.freeze
27
+ VERSION = '0.3.1'.freeze
28
28
 
29
29
  # Gem homepage
30
30
  HOMEPAGE = 'https://github.com/BerkeleyLibrary/marc'.freeze
@@ -14,9 +14,17 @@ module MARCExtensions
14
14
  # # => true
15
15
  # ```
16
16
  #
17
+ # @overload initialize(file, options)
18
+ # @param file [String, IO] a string file path, or an IO object
19
+ # @option options parser [String] ('rexml') which parser to use
20
+ # @option options freeze [Boolean] (false) whether to freeze records as they're created
21
+ # @overload initialize(file, parser: 'rexml', freeze: false)
22
+ # @param file [String, IO] a string file path, or an IO object
23
+ # @param parser [String] ('rexml') which parser to use
24
+ # @param freeze [Boolean] (false) whether to freeze records as they're created
17
25
  # @see MARCExtensions::RecordExtensions#freeze
18
- def initialize(file, options = {})
19
- @freeze = options[:freeze]
26
+ def initialize(*args)
27
+ file, options, @freeze = destructure_args(args)
20
28
  super(file, options)
21
29
 
22
30
  # It's surprisingly tricky to get these into the general superclass
@@ -27,16 +35,33 @@ module MARCExtensions
27
35
  class << self; prepend(MARCExtensions::BuildFrozenRecord); end
28
36
  end
29
37
  end
38
+
39
+ private
40
+
41
+ # Handle either an options hash or keyword arguments in a way
42
+ # that works under both Ruby 2.7 and Ruby 3.x
43
+ def destructure_args(args)
44
+ file = args[0]
45
+ options = args[1] || {}
46
+ freeze = options[:freeze] || false
47
+ [file, options, freeze]
48
+ end
30
49
  end
31
50
 
32
51
  # Class extensions for [MARC::XMLReader](https://rubydoc.info/gems/marc/MARC/XMLReader).
33
52
  module XMLReaderClassExtensions
34
53
  # Reads MARC records from the specified file or IO
35
54
  #
36
- # @param file [String, IO] a string file path, or an IO object
37
- # @return [MARC::XMLReader] a reader for the specified file or IO
38
- def read(file, options = {})
39
- new(file, options)
55
+ # @overload read(file, options)
56
+ # @param file [String, IO] a string file path, or an IO object
57
+ # @option parser [String] ('rexml') which parser to use
58
+ # @option freeze [Boolean] (false) whether to freeze records as they're created
59
+ # @overload read(file, parser: 'rexml', freeze: false)
60
+ # @param file [String, IO] a string file path, or an IO object
61
+ # @param parser [String] ('rexml') which parser to use
62
+ # @param freeze [Boolean] (false) whether to freeze records as they're created
63
+ def read(*args)
64
+ new(*args)
40
65
  end
41
66
  end
42
67
 
@@ -14,6 +14,24 @@ module MARC
14
14
  reader = XMLReader.new(infile_path, { parser: 'nokogiri' })
15
15
  expect(reader).to be_a(NokogiriReader)
16
16
  end
17
+
18
+ it 'accepts a hash of options' do
19
+ reader = XMLReader.new(infile_path, { parser: 'nokogiri', freeze: true })
20
+ expect(reader).to be_a(NokogiriReader)
21
+ expect(reader.instance_variable_get(:@freeze)).to eq(true)
22
+ end
23
+
24
+ it 'accepts keyword arguments' do
25
+ reader = XMLReader.new(infile_path, parser: 'nokogiri', freeze: true)
26
+ expect(reader).to be_a(NokogiriReader)
27
+ expect(reader.instance_variable_get(:@freeze)).to eq(true)
28
+ end
29
+
30
+ it 'accepts a hash of options' do
31
+ reader = XMLReader.new(infile_path, { parser: 'nokogiri', freeze: true })
32
+ expect(reader).to be_a(NokogiriReader)
33
+ expect(reader.instance_variable_get(:@freeze)).to eq(true)
34
+ end
17
35
  end
18
36
 
19
37
  describe :read do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkeley_library-marc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: marc