datacite-mapping 0.4.1 → 0.5.0

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: 8775fcefefd2e9b7d31347a04a0495018109f239f1710c45a909c0c6a00f3a7d
4
- data.tar.gz: 2d2ff543b99b85846be3c8d322f41967038cb836b83e2d8db6dba3ff7bafb4d8
3
+ metadata.gz: 5a6ecd59de223d63f3cbdba50679fd649e3b90b5faf54ac5c5d441cfc32c8a6f
4
+ data.tar.gz: ea434e0efa6850179bd6147a95e21ce0f682d6494d950bd7184dcb5eea929cdf
5
5
  SHA512:
6
- metadata.gz: 54c5fc88e7ec891b088feff0022dcf89b8cbe8408e1fe6e2de6de76695e5c074397061210378a22c51d1db6653eccd07fe01076fea6807e49d199b8b73c98f90
7
- data.tar.gz: 419006f6182826184d8a009552aac66aa59355422e679c43c56ce6b6f399fe21507b2c170800ddc5633135f49171cba54734c3f6fe9d70fc3a741d598594afd4
6
+ metadata.gz: a2e1ffe1f08383143bea79f9dd4d48404e60ecde812e6c2b089fec7a4ea6ff385b4f6a0e95e1cfda9baee9c6f99a85790c17f7abd0b94b980c44a0e0bebc5464
7
+ data.tar.gz: 5ee1fecb57d8eb8a7ca6a94ea3c2ecc02cf7872896350328ab42a2f292b6f51e599c0c427d5b444daa189f6db645a4ee7bd585dd96989e4b557fa967c0810240
data/.rubocop.yml CHANGED
@@ -42,3 +42,9 @@ Style/ClassAndModuleChildren:
42
42
  Style/MixinUsage:
43
43
  Exclude:
44
44
  - 'examples/*'
45
+
46
+ Style/OptionalBooleanParameter:
47
+ Enabled: false
48
+
49
+ Naming/VariableNumber:
50
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 3.0.4
data/CHANGES.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 0.4.0 (12 November 2019
1
+ ## 0.5.0 (12 November 2019)
2
+ - Update to Ruby 3.0.4
3
+ - Update to Rubocop 0.93
4
+
5
+ ## 0.4.0 (12 November 2019)
2
6
 
3
7
  - Datacite 4.3 support:
4
8
  - Added the new elements and attributes introduced in DataCite 4.1, 4.2, and 4.3.
@@ -16,9 +16,11 @@ Gem::Specification.new do |spec|
16
16
  spec.license = 'MIT'
17
17
 
18
18
  origin = `git config --get remote.origin.url`.chomp
19
- origin_uri = origin.start_with?('http') ? URI(origin) : URI(origin.gsub(%r{git@([^:]+)(.com|.org)[^\/]+}, 'http://\1\2'))
19
+ origin_uri = origin.start_with?('http') ? URI(origin) : URI(origin.gsub(%r{git@([^:]+)(.com|.org)[^/]+}, 'http://\1\2'))
20
20
  spec.homepage = URI::HTTP.build(host: origin_uri.host, path: origin_uri.path.chomp('.git')).to_s
21
21
 
22
+ spec.required_ruby_version = '>= 3.0.0'
23
+
22
24
  spec.files = `git ls-files -z`.split("\x0")
23
25
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
26
 
@@ -8,7 +8,7 @@ module Datacite
8
8
  class Affiliation
9
9
  include XML::Mapping
10
10
 
11
- def initialize(identifier: nil, identifier_scheme: nil, scheme_uri: nil, value:)
11
+ def initialize(value:, identifier: nil, identifier_scheme: nil, scheme_uri: nil)
12
12
  self.identifier = identifier
13
13
  self.identifier_scheme = identifier_scheme
14
14
  self.scheme_uri = scheme_uri
@@ -87,7 +87,7 @@ module Datacite
87
87
  # @param identifier [NameIdentifier, nil] an identifier for the contributor. Optional.
88
88
  # @param affiliations [Array<Affiliation>] the contributor's affiliations. Defaults to an empty list.
89
89
  # @param type [ContributorType] the contributor type. Cannot be nil.
90
- def initialize(name:, identifier: nil, affiliations: nil, type:)
90
+ def initialize(name:, type:, identifier: nil, affiliations: nil)
91
91
  self.name = name
92
92
  self.identifier = identifier
93
93
  self.affiliations = affiliations || []
@@ -9,7 +9,7 @@ module Datacite
9
9
  module Mapping
10
10
  class ContributorName
11
11
  include XML::Mapping
12
- def initialize(type: nil, language: nil, value:)
12
+ def initialize(value:, type: nil, language: nil)
13
13
  self.type = type
14
14
  self.language = language
15
15
  self.value = value
@@ -9,7 +9,7 @@ module Datacite
9
9
  module Mapping
10
10
  class CreatorName
11
11
  include XML::Mapping
12
- def initialize(type: nil, language: nil, value:)
12
+ def initialize(value:, type: nil, language: nil)
13
13
  self.type = type
14
14
  self.language = language
15
15
  self.value = value
@@ -60,9 +60,7 @@ module Datacite
60
60
  include Comparable
61
61
  include XML::Mapping
62
62
 
63
- attr_reader :date_value
64
- attr_reader :range_start
65
- attr_reader :range_end
63
+ attr_reader :date_value, :range_start, :range_end
66
64
 
67
65
  # Initializes a new `Date`
68
66
  #
@@ -80,12 +78,15 @@ module Datacite
80
78
  @type = val
81
79
  end
82
80
 
81
+ # rubocop:disable Metrics/MethodLength
82
+
83
83
  def value=(val) # rubocop:disable Metrics/AbcSize
84
84
  parts = val.to_s.split('/', -1) # negative limit so we don't drop trailing empty string
85
85
  @date_value, @range_start, @range_end = nil
86
- if parts.size == 1
86
+ case parts.size
87
+ when 1
87
88
  @date_value = DateValue.new(val)
88
- elsif parts.size == 2
89
+ when 2
89
90
  @range_start, @range_end = parts.map(&:strip).map { |part| DateValue.new(part) unless part == '' }
90
91
  # puts "#{val} -> [#{range_start}, #{range_end}]"
91
92
  else
@@ -93,9 +94,10 @@ module Datacite
93
94
  end
94
95
  @value = date_value ? date_value.to_s : "#{range_start}/#{range_end}"
95
96
  end
97
+ # rubocop:enable Metrics/MethodLength
96
98
 
97
99
  def <=>(other)
98
- return nil unless other.class == self.class
100
+ return nil unless other.instance_of?(self.class)
99
101
 
100
102
  %i[date_value range_start range_end type].each do |v|
101
103
  order = send(v) <=> other.send(v)
@@ -25,16 +25,7 @@ module Datacite
25
25
  class DateValue
26
26
  include Comparable
27
27
 
28
- attr_reader :year
29
- attr_reader :month
30
- attr_reader :day
31
- attr_reader :hour
32
- attr_reader :minute
33
- attr_reader :sec
34
- attr_reader :nsec
35
- attr_reader :date
36
- attr_reader :zone
37
- attr_reader :iso_value
28
+ attr_reader :year, :month, :day, :hour, :minute, :sec, :nsec, :date, :zone, :iso_value
38
29
 
39
30
  # Creates a new {DateValue}.
40
31
  #
@@ -58,7 +49,7 @@ module Datacite
58
49
  end
59
50
 
60
51
  def <=>(other)
61
- return nil unless other.class == self.class
52
+ return nil unless other.instance_of?(self.class)
62
53
 
63
54
  %i[year month day hour minute sec nsec].each do |v|
64
55
  order = send(v) <=> other.send(v)
@@ -86,7 +86,7 @@ module Datacite
86
86
  # @param type [DescriptionType] the description type.
87
87
  # @param value [String] the description itself. See {Description} for notes on special
88
88
  # handling of `<br/>` tags.
89
- def initialize(language: nil, type:, value:)
89
+ def initialize(type:, value:, language: nil)
90
90
  self.language = language
91
91
  self.type = type
92
92
  self.value = value
@@ -27,7 +27,7 @@ module Datacite
27
27
 
28
28
  # @param type [FunderIdentifierType] the identifier type. Cannot be nil.
29
29
  # @param value [String] the identifier value. Cannot be nil.
30
- def initialize(type:, scheme_uri: nil, value:)
30
+ def initialize(type:, value:, scheme_uri: nil)
31
31
  self.type = type
32
32
  self.scheme_uri = scheme_uri
33
33
  self.value = value
@@ -65,7 +65,7 @@ module Datacite
65
65
  class AwardNumber
66
66
  include XML::Mapping
67
67
 
68
- def initialize(uri: nil, value:)
68
+ def initialize(value:, uri: nil)
69
69
  self.uri = uri
70
70
  self.value = value
71
71
  end
@@ -19,10 +19,7 @@ module Datacite
19
19
  class GeoLocationBox
20
20
  include Comparable
21
21
 
22
- attr_reader :south_latitude
23
- attr_reader :west_longitude
24
- attr_reader :north_latitude
25
- attr_reader :east_longitude
22
+ attr_reader :south_latitude, :west_longitude, :north_latitude, :east_longitude
26
23
 
27
24
  # Initializes a new {GeoLocationBox}. The arguments can be provided
28
25
  # either as a named-parameter hash, or as a list of four coordinates
@@ -51,7 +48,10 @@ module Datacite
51
48
  def initialize(*args)
52
49
  case args.length
53
50
  when 1
54
- init_from_hash(args[0])
51
+ raise ArgumentError, "Can't construct GeoLocationBox from arguments: #{args}" unless args[0].respond_to?(:keys)
52
+
53
+ init_from_hash(**args[0])
54
+
55
55
  when 4
56
56
  init_from_array(args)
57
57
  else
@@ -99,7 +99,7 @@ module Datacite
99
99
  # @return [Fixnum, nil] the sort order (-1, 0, or 1), or nil if `other` is not a
100
100
  # {GeoLocationBox}
101
101
  def <=>(other)
102
- return nil unless other.class == self.class
102
+ return nil unless other.instance_of?(self.class)
103
103
 
104
104
  %i[south_latitude west_longitude north_latitude east_longitude].each do |c|
105
105
  order = send(c) <=> other.send(c)
@@ -7,8 +7,7 @@ module Datacite
7
7
  # Abstract superclass of GeoLocation parsing nodes
8
8
  class GeoLocationNode < XML::Mapping::SingleAttributeNode
9
9
 
10
- attr_reader :geom_class
11
- attr_reader :coord_elements
10
+ attr_reader :geom_class, :coord_elements
12
11
 
13
12
  def initialize(*args)
14
13
  raise 'No geometry class provided' unless @geom_class
@@ -30,7 +29,7 @@ module Datacite
30
29
  end
31
30
 
32
31
  def set_attr_value(xml, value)
33
- raise "Invalid value: expected #{geom_class} instance, was #{value || 'nil'}" unless value&.is_a?(geom_class)
32
+ raise "Invalid value: expected #{geom_class} instance, was #{value || 'nil'}" unless value.is_a?(geom_class)
34
33
 
35
34
  element = @path.first(xml, ensure_created: true)
36
35
 
@@ -15,8 +15,7 @@ module Datacite
15
15
  class GeoLocationPoint
16
16
  include Comparable
17
17
 
18
- attr_reader :latitude
19
- attr_reader :longitude
18
+ attr_reader :latitude, :longitude
20
19
 
21
20
  # Initializes a new {GeoLocationPoint}. The arguments can be provided
22
21
  # either as a named-parameter hash, or as a pair of coordinates in the
@@ -31,7 +30,10 @@ module Datacite
31
30
  def initialize(*args)
32
31
  case args.length
33
32
  when 1
34
- init_from_hash(args[0])
33
+ raise ArgumentError, "Can't construct GeoLocationPoint from arguments: #{args}" unless args[0].respond_to?(:keys)
34
+
35
+ init_from_hash(**args[0])
36
+
35
37
  when 2
36
38
  init_from_array(args)
37
39
  else
@@ -65,7 +67,7 @@ module Datacite
65
67
  # @return [Fixnum, nil] the sort order (-1, 0, or 1), or nil if `other` is not a
66
68
  # {GeoLocationPoint}
67
69
  def <=>(other)
68
- return nil unless other.class == self.class
70
+ return nil unless other.instance_of?(self.class)
69
71
 
70
72
  %i[latitude longitude].each do |c|
71
73
  order = send(c) <=> other.send(c)
@@ -25,7 +25,7 @@ module Datacite
25
25
  end
26
26
 
27
27
  def <=>(other)
28
- return nil unless other.class == self.class
28
+ return nil unless other.instance_of?(self.class)
29
29
 
30
30
  points <=> other.points
31
31
  end
@@ -5,7 +5,7 @@ require 'datacite/mapping/empty_filtering_nodes'
5
5
 
6
6
  module Datacite
7
7
  module Mapping
8
- DOI_PATTERN = %r{10\.\S+/\S+}.freeze
8
+ DOI_PATTERN = %r{10\.\S+/\S+}
9
9
 
10
10
  # The persistent identifier that identifies the resource.
11
11
  #
@@ -6,7 +6,7 @@ module Datacite
6
6
  NAME = 'datacite-mapping'
7
7
 
8
8
  # The version of this gem
9
- VERSION = '0.4.1'
9
+ VERSION = '0.5.0'
10
10
 
11
11
  # The copyright notice for this gem
12
12
  COPYRIGHT = 'Copyright (c) 2022 The Regents of the University of California'
@@ -12,7 +12,7 @@ module Datacite
12
12
  # @param scheme [Scheme] the name identifier scheme. Cannot be nil.
13
13
  # @param scheme_uri [URI, nil] the URI of the identifier scheme. Optional.
14
14
  # @param value [String] the identifier value. Cannot be nil.
15
- def initialize(scheme:, scheme_uri: nil, value:)
15
+ def initialize(scheme:, value:, scheme_uri: nil)
16
16
  self.scheme = scheme
17
17
  self.scheme_uri = scheme_uri
18
18
  self.value = value
@@ -12,7 +12,7 @@ module Datacite
12
12
  # Initializes a new {Publisher}
13
13
  # @param language [String, nil] an IETF BCP 47, ISO 639-1 language code identifying the language.
14
14
  # @param value [String] name of the publisher
15
- def initialize(language: nil, value:)
15
+ def initialize(value:, language: nil)
16
16
  self.language = language
17
17
  self.value = value
18
18
  end
@@ -39,10 +39,13 @@ module Datacite
39
39
  ReadOnlyNodes.warn(warning)
40
40
  end
41
41
 
42
+ # rubocop:disable Lint/UselessMethodDefinition
42
43
  # public to allow testing
43
44
  def self.warn(warning)
44
45
  super
45
46
  end
47
+
48
+ # rubocop:enable Lint/UselessMethodDefinition
46
49
  end
47
50
 
48
51
  class ReadOnlyTextNode < XML::Mapping::TextNode
@@ -129,7 +129,7 @@ module Datacite
129
129
  end
130
130
 
131
131
  def subjects=(value)
132
- @subjects = (value&.select(&:value)) || []
132
+ @subjects = value&.select(&:value) || []
133
133
  end
134
134
 
135
135
  def contributors=(value)
@@ -170,11 +170,11 @@ module Datacite
170
170
  end
171
171
 
172
172
  def descriptions=(value)
173
- @descriptions = (value&.select(&:value)) || []
173
+ @descriptions = value&.select(&:value) || []
174
174
  end
175
175
 
176
176
  def geo_locations=(value)
177
- @geo_locations = (value&.select(&:location?)) || []
177
+ @geo_locations = value&.select(&:location?) || []
178
178
  end
179
179
 
180
180
  # @!attribute [rw] identifier
@@ -14,7 +14,7 @@ module Datacite
14
14
  # @param scheme_uri [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
15
15
  # @param language [String, nil] an IETF BCP 47, ISO 639-1 language code identifying the language.
16
16
  # @param value [String] the subject itself.
17
- def initialize(scheme: nil, scheme_uri: nil, language: nil, value:)
17
+ def initialize(value:, scheme: nil, scheme_uri: nil, language: nil)
18
18
  self.scheme = scheme
19
19
  self.scheme_uri = scheme_uri
20
20
  self.language = language
@@ -26,7 +26,7 @@ module Datacite
26
26
  # @param language [String, nil] an IETF BCP 47, ISO 639-1 language code identifying the language.
27
27
  # @param value [String] the title itself.
28
28
  # @param type [TitleType, nil] the title type. Optional.
29
- def initialize(language: nil, value:, type: nil)
29
+ def initialize(value:, language: nil, type: nil)
30
30
  self.language = language
31
31
  self.type = type
32
32
  self.value = value
@@ -20,7 +20,7 @@ module Datacite
20
20
  iso8601_secs: '1914-08-04T11:01:06+01:00',
21
21
  iso8601_frac: '1914-08-04T11:01:06.0123+01:00'
22
22
  }
23
- @dates = values.map { |format, v| [format, DateValue.new(v)] }.to_h
23
+ @dates = values.transform_values { |v| DateValue.new(v) }
24
24
  end
25
25
 
26
26
  describe '#initialize' do
@@ -53,22 +53,22 @@ module Datacite
53
53
  describe '#identifier' do
54
54
  it 'requires an identifier' do
55
55
  args.delete(:identifier)
56
- expect { Resource.new(args) }.to raise_error(ArgumentError)
56
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
57
57
  end
58
58
 
59
59
  it 'requires a non-nil identifier' do
60
60
  args[:identifier] = nil
61
- expect { Resource.new(args) }.to raise_error(ArgumentError)
61
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
62
62
  end
63
63
 
64
64
  it 'can be initialized' do
65
- resource = Resource.new(args)
65
+ resource = Resource.new(**args)
66
66
  expect(resource.identifier).to eq(identifier)
67
67
  end
68
68
 
69
69
  it 'can be set' do
70
70
  new_id = Identifier.new(value: '10.1594/WDCC/CCSRNIES_SRES_B2')
71
- resource = Resource.new(args)
71
+ resource = Resource.new(**args)
72
72
  resource.identifier = new_id
73
73
  expect(resource.identifier).to eq(new_id)
74
74
  end
@@ -78,21 +78,21 @@ module Datacite
78
78
 
79
79
  it 'requires a creator list' do
80
80
  args.delete(:creators)
81
- expect { Resource.new(args) }.to raise_error(ArgumentError)
81
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
82
82
  end
83
83
 
84
84
  it 'requires a non-nil creator list' do
85
85
  args[:creators] = nil
86
- expect { Resource.new(args) }.to raise_error(ArgumentError)
86
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
87
87
  end
88
88
 
89
89
  it 'requires a non-empty creator list' do
90
90
  args[:creators] = []
91
- expect { Resource.new(args) }.to raise_error(ArgumentError)
91
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
92
92
  end
93
93
 
94
94
  it 'can be initialized' do
95
- resource = Resource.new(args)
95
+ resource = Resource.new(**args)
96
96
  expect(resource.creators).to eq(creators)
97
97
  end
98
98
 
@@ -102,7 +102,7 @@ module Datacite
102
102
  identifier: NameIdentifier.new(scheme: 'ISNI', scheme_uri: URI('http://isni.org/'), value: '0000 0001 1678 4522'),
103
103
  affiliations: ['Disney–ABC Television Group']
104
104
  )]
105
- resource = Resource.new(args)
105
+ resource = Resource.new(**args)
106
106
  resource.creators = new_creators
107
107
  expect(resource.creators).to eq(new_creators)
108
108
  end
@@ -110,7 +110,7 @@ module Datacite
110
110
  describe 'creator convenience methods' do
111
111
  describe '#creator_names' do
112
112
  it 'extracts the creator names' do
113
- resource = Resource.new(args)
113
+ resource = Resource.new(**args)
114
114
  expect(resource.creator_names)
115
115
  .to eq(['Hedy Lamarr', 'Herschlag, Natalie'])
116
116
  end
@@ -118,7 +118,7 @@ module Datacite
118
118
 
119
119
  describe '#creator_affiliations' do
120
120
  it 'extracts the creator affiliations' do
121
- resource = Resource.new(args)
121
+ resource = Resource.new(**args)
122
122
  expect(resource.creator_affiliations)
123
123
  .to eq([
124
124
  ['United Artists', 'Metro-Goldwyn-Mayer'],
@@ -132,21 +132,21 @@ module Datacite
132
132
  describe '#titles' do
133
133
  it 'requires a title list' do
134
134
  args.delete(:titles)
135
- expect { Resource.new(args) }.to raise_error(ArgumentError)
135
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
136
136
  end
137
137
 
138
138
  it 'requires a non-nil title list' do
139
139
  args[:titles] = nil
140
- expect { Resource.new(args) }.to raise_error(ArgumentError)
140
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
141
141
  end
142
142
 
143
143
  it 'requires a non-empty title list' do
144
144
  args[:titles] = []
145
- expect { Resource.new(args) }.to raise_error(ArgumentError)
145
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
146
146
  end
147
147
 
148
148
  it 'can be initialized' do
149
- resource = Resource.new(args)
149
+ resource = Resource.new(**args)
150
150
  expect(resource.titles).to eq(titles)
151
151
  end
152
152
 
@@ -156,7 +156,7 @@ module Datacite
156
156
  type: TitleType::SUBTITLE,
157
157
  value: 'Together with an Appendix of the Same, Containing an Answer to Some Objections, Made by Severall Persons against That Hypothesis'
158
158
  )]
159
- resource = Resource.new(args)
159
+ resource = Resource.new(**args)
160
160
  resource.titles = new_titles
161
161
  expect(resource.titles).to eq(new_titles)
162
162
  end
@@ -166,22 +166,22 @@ module Datacite
166
166
  describe '#publisher' do
167
167
  it 'requires a publisher' do
168
168
  args.delete(:publisher)
169
- expect { Resource.new(args) }.to raise_error(ArgumentError)
169
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
170
170
  end
171
171
  it 'requires a non-nil publisher' do
172
172
  args[:publisher] = nil
173
- expect { Resource.new(args) }.to raise_error(ArgumentError)
173
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
174
174
  end
175
175
  it 'requires a non-blank publisher' do
176
176
  expect { Publisher.new(value: ' ') }.to raise_error(ArgumentError)
177
177
  end
178
178
  it 'can be initialized' do
179
- resource = Resource.new(args)
179
+ resource = Resource.new(**args)
180
180
  expect(resource.publisher.value).to eq(publisher)
181
181
  end
182
182
  it 'can be set' do
183
183
  new_publisher = 'University of California'
184
- resource = Resource.new(args)
184
+ resource = Resource.new(**args)
185
185
  resource.publisher = new_publisher
186
186
  expect(resource.publisher.value).to eq(new_publisher)
187
187
  end
@@ -189,11 +189,11 @@ module Datacite
189
189
  args[:publisher] = Publisher.new(value: '
190
190
  University of California
191
191
  ')
192
- resource = Resource.new(args)
192
+ resource = Resource.new(**args)
193
193
  expect(resource.publisher.value).to eq('University of California')
194
194
  end
195
195
  it 'strips on set' do
196
- resource = Resource.new(args)
196
+ resource = Resource.new(**args)
197
197
  resource.publisher = Publisher.new(value: '
198
198
  University of California
199
199
  ')
@@ -204,31 +204,31 @@ module Datacite
204
204
  describe '#publication_year' do
205
205
  it 'requires a publication_year' do
206
206
  args.delete(:publication_year)
207
- expect { Resource.new(args) }.to raise_error(ArgumentError)
207
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
208
208
  end
209
209
  it 'requires a non-nil publication_year' do
210
210
  args[:publication_year] = nil
211
- expect { Resource.new(args) }.to raise_error(ArgumentError)
211
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
212
212
  end
213
213
  it 'requires a four-digit publication_year' do
214
214
  args[:publication_year] = 999
215
- expect { Resource.new(args) }.to raise_error(ArgumentError)
215
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
216
216
  args[:publication_year] = 10_000
217
- expect { Resource.new(args) }.to raise_error(ArgumentError)
217
+ expect { Resource.new(**args) }.to raise_error(ArgumentError)
218
218
  end
219
219
  it 'can be initialized' do
220
- resource = Resource.new(args)
220
+ resource = Resource.new(**args)
221
221
  expect(resource.publication_year).to eq(publication_year)
222
222
  end
223
223
  it 'can be set' do
224
224
  new_pub_year = 1963
225
- resource = Resource.new(args)
225
+ resource = Resource.new(**args)
226
226
  resource.publication_year = new_pub_year
227
227
  expect(resource.publication_year).to eq(new_pub_year)
228
228
  end
229
229
  it 'converts strings to integers' do
230
230
  new_pub_year = 1963
231
- resource = Resource.new(args)
231
+ resource = Resource.new(**args)
232
232
  resource.publication_year = new_pub_year.to_s
233
233
  expect(resource.publication_year).to eq(new_pub_year)
234
234
  end
@@ -236,7 +236,7 @@ module Datacite
236
236
 
237
237
  describe '#subjects' do
238
238
  it 'defaults to empty' do
239
- resource = Resource.new(args)
239
+ resource = Resource.new(**args)
240
240
  expect(resource.subjects).to eq([])
241
241
  end
242
242
 
@@ -257,12 +257,12 @@ module Datacite
257
257
  )
258
258
  ]
259
259
  args[:subjects] = subjects
260
- resource = Resource.new(args)
260
+ resource = Resource.new(**args)
261
261
  expect(resource.subjects).to eq(subjects)
262
262
  end
263
263
  it 'can\'t be initialized to nil' do
264
264
  args[:subjects] = nil
265
- resource = Resource.new(args)
265
+ resource = Resource.new(**args)
266
266
  expect(resource.subjects).to eq([])
267
267
  end
268
268
 
@@ -273,7 +273,7 @@ module Datacite
273
273
  Subject.allocate
274
274
  ]
275
275
  args[:subjects] = subjects
276
- resource = Resource.new(args)
276
+ resource = Resource.new(**args)
277
277
  expect(resource.subjects).to eq([subjects[1]])
278
278
  end
279
279
  end
@@ -294,12 +294,12 @@ module Datacite
294
294
  value: '571.8 Croissance, développement, reproduction biologique (fécondation, sexualité)'
295
295
  )
296
296
  ]
297
- resource = Resource.new(args)
297
+ resource = Resource.new(**args)
298
298
  resource.subjects = subjects
299
299
  expect(resource.subjects).to eq(subjects)
300
300
  end
301
301
  it 'can\'t be set to nil' do
302
- resource = Resource.new(args)
302
+ resource = Resource.new(**args)
303
303
  resource.subjects = nil
304
304
  expect(resource.subjects).to eq([])
305
305
  end
@@ -309,7 +309,7 @@ module Datacite
309
309
  Subject.new(value: 'Mammals--Embryology'),
310
310
  Subject.allocate
311
311
  ]
312
- resource = Resource.new(args)
312
+ resource = Resource.new(**args)
313
313
  resource.subjects = subjects
314
314
  expect(resource.subjects).to eq([subjects[1]])
315
315
  end
@@ -318,7 +318,7 @@ module Datacite
318
318
 
319
319
  describe '#funding_references' do
320
320
  it 'defaults to empty' do
321
- resource = Resource.new(args)
321
+ resource = Resource.new(**args)
322
322
  expect(resource.funding_references).to eq([])
323
323
  end
324
324
 
@@ -329,19 +329,19 @@ module Datacite
329
329
  FundingReference.new(name: 'НИИЧАВО', award_number: '164070')
330
330
  ]
331
331
  args[:funding_references] = funding_references
332
- resource = Resource.new(args)
332
+ resource = Resource.new(**args)
333
333
  expect(resource.funding_references).to eq(funding_references)
334
334
  end
335
335
  it 'can\'t be initialized to nil' do
336
336
  args[:funding_references] = nil
337
- resource = Resource.new(args)
337
+ resource = Resource.new(**args)
338
338
  expect(resource.funding_references).to eq([])
339
339
  end
340
340
  end
341
341
 
342
342
  describe '#funding_references=' do
343
343
  it 'can be set' do
344
- resource = Resource.new(args)
344
+ resource = Resource.new(**args)
345
345
  funding_references = [
346
346
  FundingReference.new(name: 'Ministry of Magic', award_number: '9¾'),
347
347
  FundingReference.new(name: 'НИИЧАВО', award_number: '164070')
@@ -350,7 +350,7 @@ module Datacite
350
350
  expect(resource.funding_references).to eq(funding_references)
351
351
  end
352
352
  it 'can\'t be set to nil' do
353
- resource = Resource.new(args)
353
+ resource = Resource.new(**args)
354
354
  resource.funding_references = nil
355
355
  expect(resource.funding_references).to eq([])
356
356
  end
@@ -359,18 +359,18 @@ module Datacite
359
359
 
360
360
  describe '#language' do
361
361
  it 'defaults to nil' do
362
- resource = Resource.new(args)
362
+ resource = Resource.new(**args)
363
363
  expect(resource.language).to be_nil
364
364
  end
365
365
 
366
366
  it 'can be initialized' do
367
367
  args[:language] = 'en-emodeng'
368
- resource = Resource.new(args)
368
+ resource = Resource.new(**args)
369
369
  expect(resource.language).to eq('en-emodeng')
370
370
  end
371
371
 
372
372
  it 'can be set' do
373
- resource = Resource.new(args)
373
+ resource = Resource.new(**args)
374
374
  resource.language = 'en-emodeng'
375
375
  expect(resource.language).to eq('en-emodeng')
376
376
  end
@@ -379,7 +379,7 @@ module Datacite
379
379
  describe '#contributors' do
380
380
 
381
381
  it 'defaults to empty' do
382
- resource = Resource.new(args)
382
+ resource = Resource.new(**args)
383
383
  expect(resource.funding_references).to eq([])
384
384
  end
385
385
 
@@ -390,19 +390,19 @@ module Datacite
390
390
  Contributor.new(name: 'Hedy Lamarr', type: ContributorType::RESEARCHER)
391
391
  ]
392
392
  args[:contributors] = contributors
393
- resource = Resource.new(args)
393
+ resource = Resource.new(**args)
394
394
  expect(resource.contributors).to eq(contributors)
395
395
  end
396
396
  it 'can\'t be initialized to nil' do
397
397
  args[:contributors] = nil
398
- resource = Resource.new(args)
398
+ resource = Resource.new(**args)
399
399
  expect(resource.contributors).to eq([])
400
400
  end
401
401
  end
402
402
 
403
403
  describe '#contributors=' do
404
404
  it 'can be set' do
405
- resource = Resource.new(args)
405
+ resource = Resource.new(**args)
406
406
  contributors = [
407
407
  Contributor.new(name: 'Hershlag, Natalie', type: ContributorType::PROJECT_MEMBER),
408
408
  Contributor.new(name: 'Hedy Lamarr', type: ContributorType::RESEARCHER)
@@ -411,7 +411,7 @@ module Datacite
411
411
  expect(resource.contributors).to eq(contributors)
412
412
  end
413
413
  it 'can\'t be set to nil' do
414
- resource = Resource.new(args)
414
+ resource = Resource.new(**args)
415
415
  resource.contributors = nil
416
416
  expect(resource.contributors).to eq([])
417
417
  end
@@ -419,7 +419,7 @@ module Datacite
419
419
 
420
420
  describe 'contributor convenience methods' do
421
421
  before(:each) do
422
- @resource = Resource.new(args)
422
+ @resource = Resource.new(**args)
423
423
  @funder = Contributor.new(
424
424
  name: 'The Ministry of Magic',
425
425
  identifier: NameIdentifier.new(
@@ -460,7 +460,7 @@ module Datacite
460
460
 
461
461
  describe '#dates' do
462
462
  it 'defaults to empty' do
463
- resource = Resource.new(args)
463
+ resource = Resource.new(**args)
464
464
  expect(resource.funding_references).to eq([])
465
465
  end
466
466
 
@@ -471,19 +471,19 @@ module Datacite
471
471
  Date.new(value: '1914-08-04T11:01:06.0123+01:00', type: DateType::AVAILABLE)
472
472
  ]
473
473
  args[:dates] = dates
474
- resource = Resource.new(args)
474
+ resource = Resource.new(**args)
475
475
  expect(resource.dates).to eq(dates)
476
476
  end
477
477
  it 'can\'t be initialized to nil' do
478
478
  args[:dates] = nil
479
- resource = Resource.new(args)
479
+ resource = Resource.new(**args)
480
480
  expect(resource.dates).to eq([])
481
481
  end
482
482
  end
483
483
 
484
484
  describe '#dates=' do
485
485
  it 'can be set' do
486
- resource = Resource.new(args)
486
+ resource = Resource.new(**args)
487
487
  dates = [
488
488
  Date.new(value: DateTime.new(1914, 8, 4, 11, 0o1, 6.0123, '+1'), type: DateType::AVAILABLE),
489
489
  Date.new(value: '1914-08-04T11:01:06.0123+01:00', type: DateType::AVAILABLE)
@@ -492,7 +492,7 @@ module Datacite
492
492
  expect(resource.dates).to eq(dates)
493
493
  end
494
494
  it 'can\'t be set to nil' do
495
- resource = Resource.new(args)
495
+ resource = Resource.new(**args)
496
496
  resource.dates = nil
497
497
  expect(resource.dates).to eq([])
498
498
  end
@@ -503,13 +503,13 @@ module Datacite
503
503
  it 'can be initialized' do
504
504
  resource_type = ResourceType.new(resource_type_general: ResourceTypeGeneral::DATASET, value: 'Dataset')
505
505
  args[:resource_type] = resource_type
506
- resource = Resource.new(args)
506
+ resource = Resource.new(**args)
507
507
  expect(resource.resource_type).to eq(resource_type)
508
508
  end
509
509
 
510
510
  it 'can be set' do
511
511
  resource_type = ResourceType.new(resource_type_general: ResourceTypeGeneral::DATASET, value: 'Dataset')
512
- resource = Resource.new(args)
512
+ resource = Resource.new(**args)
513
513
  resource.resource_type = resource_type
514
514
  expect(resource.resource_type).to eq(resource_type)
515
515
  end
@@ -517,7 +517,7 @@ module Datacite
517
517
 
518
518
  describe '#alternate_identifiers' do
519
519
  it 'defaults to empty' do
520
- resource = Resource.new(args)
520
+ resource = Resource.new(**args)
521
521
  expect(resource.alternate_identifiers).to eq([])
522
522
  end
523
523
 
@@ -528,19 +528,19 @@ module Datacite
528
528
  AlternateIdentifier.new(type: 'URL', value: 'http://example.com')
529
529
  ]
530
530
  args[:alternate_identifiers] = alternate_identifiers
531
- resource = Resource.new(args)
531
+ resource = Resource.new(**args)
532
532
  expect(resource.alternate_identifiers).to eq(alternate_identifiers)
533
533
  end
534
534
  it 'can\'t be initialized to nil' do
535
535
  args[:alternate_identifiers] = nil
536
- resource = Resource.new(args)
536
+ resource = Resource.new(**args)
537
537
  expect(resource.alternate_identifiers).to eq([])
538
538
  end
539
539
  end
540
540
 
541
541
  describe '#alternate_identifiers=' do
542
542
  it 'can be set' do
543
- resource = Resource.new(args)
543
+ resource = Resource.new(**args)
544
544
  alternate_identifiers = [
545
545
  AlternateIdentifier.new(type: 'URL', value: 'http://example.org'),
546
546
  AlternateIdentifier.new(type: 'URL', value: 'http://example.com')
@@ -549,7 +549,7 @@ module Datacite
549
549
  expect(resource.alternate_identifiers).to eq(alternate_identifiers)
550
550
  end
551
551
  it 'can\'t be set to nil' do
552
- resource = Resource.new(args)
552
+ resource = Resource.new(**args)
553
553
  resource.alternate_identifiers = nil
554
554
  expect(resource.alternate_identifiers).to eq([])
555
555
  end
@@ -558,7 +558,7 @@ module Datacite
558
558
 
559
559
  describe '#related_identifiers' do
560
560
  it 'defaults to empty' do
561
- resource = Resource.new(args)
561
+ resource = Resource.new(**args)
562
562
  expect(resource.related_identifiers).to eq([])
563
563
  end
564
564
 
@@ -580,19 +580,19 @@ module Datacite
580
580
  )
581
581
  ]
582
582
  args[:related_identifiers] = related_identifiers
583
- resource = Resource.new(args)
583
+ resource = Resource.new(**args)
584
584
  expect(resource.related_identifiers).to eq(related_identifiers)
585
585
  end
586
586
  it 'can\'t be initialized to nil' do
587
587
  args[:related_identifiers] = nil
588
- resource = Resource.new(args)
588
+ resource = Resource.new(**args)
589
589
  expect(resource.related_identifiers).to eq([])
590
590
  end
591
591
  end
592
592
 
593
593
  describe '#related_identifiers=' do
594
594
  it 'can be set' do
595
- resource = Resource.new(args)
595
+ resource = Resource.new(**args)
596
596
  related_identifiers = [
597
597
  RelatedIdentifier.new(
598
598
  identifier_type: RelatedIdentifierType::URL,
@@ -612,7 +612,7 @@ module Datacite
612
612
  expect(resource.related_identifiers).to eq(related_identifiers)
613
613
  end
614
614
  it 'can\'t be set to nil' do
615
- resource = Resource.new(args)
615
+ resource = Resource.new(**args)
616
616
  resource.related_identifiers = nil
617
617
  expect(resource.related_identifiers).to eq([])
618
618
  end
@@ -621,7 +621,7 @@ module Datacite
621
621
 
622
622
  describe '#sizes' do
623
623
  it 'defaults to empty' do
624
- resource = Resource.new(args)
624
+ resource = Resource.new(**args)
625
625
  expect(resource.sizes).to eq([])
626
626
  end
627
627
 
@@ -629,12 +629,12 @@ module Datacite
629
629
  it 'can be initialized' do
630
630
  sizes = %w[48K 128K]
631
631
  args[:sizes] = sizes
632
- resource = Resource.new(args)
632
+ resource = Resource.new(**args)
633
633
  expect(resource.sizes).to eq(sizes)
634
634
  end
635
635
  it 'can\'t be initialized to nil' do
636
636
  args[:sizes] = nil
637
- resource = Resource.new(args)
637
+ resource = Resource.new(**args)
638
638
  expect(resource.sizes).to eq([])
639
639
  end
640
640
  end
@@ -642,12 +642,12 @@ module Datacite
642
642
  describe '#sizes=' do
643
643
  it 'can be set' do
644
644
  sizes = %w[48K 128K]
645
- resource = Resource.new(args)
645
+ resource = Resource.new(**args)
646
646
  resource.sizes = sizes
647
647
  expect(resource.sizes).to eq(sizes)
648
648
  end
649
649
  it 'can\'t be set to nil' do
650
- resource = Resource.new(args)
650
+ resource = Resource.new(**args)
651
651
  resource.sizes = nil
652
652
  expect(resource.sizes).to eq([])
653
653
  end
@@ -656,7 +656,7 @@ module Datacite
656
656
 
657
657
  describe '#formats' do
658
658
  it 'defaults to empty' do
659
- resource = Resource.new(args)
659
+ resource = Resource.new(**args)
660
660
  expect(resource.formats).to eq([])
661
661
  end
662
662
 
@@ -664,12 +664,12 @@ module Datacite
664
664
  it 'can be initialized' do
665
665
  formats = %w[D64 DSK]
666
666
  args[:formats] = formats
667
- resource = Resource.new(args)
667
+ resource = Resource.new(**args)
668
668
  expect(resource.formats).to eq(formats)
669
669
  end
670
670
  it 'can\'t be initialized to nil' do
671
671
  args[:formats] = nil
672
- resource = Resource.new(args)
672
+ resource = Resource.new(**args)
673
673
  expect(resource.formats).to eq([])
674
674
  end
675
675
  end
@@ -677,12 +677,12 @@ module Datacite
677
677
  describe '#formats=' do
678
678
  it 'can be set' do
679
679
  formats = %w[D64 DSK]
680
- resource = Resource.new(args)
680
+ resource = Resource.new(**args)
681
681
  resource.formats = formats
682
682
  expect(resource.formats).to eq(formats)
683
683
  end
684
684
  it 'can\'t be set to nil' do
685
- resource = Resource.new(args)
685
+ resource = Resource.new(**args)
686
686
  resource.formats = nil
687
687
  expect(resource.formats).to eq([])
688
688
  end
@@ -691,17 +691,17 @@ module Datacite
691
691
 
692
692
  describe '#version' do
693
693
  it 'defaults to nil' do
694
- resource = Resource.new(args)
694
+ resource = Resource.new(**args)
695
695
  expect(resource.version).to be_nil
696
696
  end
697
697
  it 'can be initialized' do
698
698
  args[:version] = '9.2.2'
699
- resource = Resource.new(args)
699
+ resource = Resource.new(**args)
700
700
  expect(resource.version).to eq('9.2.2')
701
701
  end
702
702
  it 'can be set' do
703
703
  new_version = '9.2.2'
704
- resource = Resource.new(args)
704
+ resource = Resource.new(**args)
705
705
  resource.version = new_version
706
706
  expect(resource.version).to eq(new_version)
707
707
  end
@@ -709,34 +709,34 @@ module Datacite
709
709
  args[:version] = '
710
710
  9.2.2
711
711
  '
712
- resource = Resource.new(args)
712
+ resource = Resource.new(**args)
713
713
  expect(resource.version).to eq('9.2.2')
714
714
  end
715
715
  it 'strips on set' do
716
- resource = Resource.new(args)
716
+ resource = Resource.new(**args)
717
717
  resource.version = '
718
718
  9.2.2
719
719
  '
720
720
  expect(resource.version).to eq('9.2.2')
721
721
  end
722
722
  it 'accepts a float' do
723
- resource = Resource.new(args)
723
+ resource = Resource.new(**args)
724
724
  resource.version = 9.2
725
725
  expect(resource.version).to eq('9.2')
726
726
  end
727
727
  it 'accepts an integer' do
728
- resource = Resource.new(args)
728
+ resource = Resource.new(**args)
729
729
  resource.version = 9
730
730
  expect(resource.version).to eq('9')
731
731
  end
732
732
  it 'can be initialized' do
733
733
  args[:version] = '9.2.2'
734
- resource = Resource.new(args)
734
+ resource = Resource.new(**args)
735
735
  expect(resource.version).to eq('9.2.2')
736
736
  end
737
737
  it 'can be set to nil' do
738
738
  args[:version] = '9.2.2'
739
- resource = Resource.new(args)
739
+ resource = Resource.new(**args)
740
740
  resource.version = nil
741
741
  expect(resource.version).to be_nil
742
742
  end
@@ -744,7 +744,7 @@ module Datacite
744
744
 
745
745
  describe '#rights_list' do
746
746
  it 'defaults to empty' do
747
- resource = Resource.new(args)
747
+ resource = Resource.new(**args)
748
748
  expect(resource.rights_list).to eq([])
749
749
  end
750
750
 
@@ -755,19 +755,19 @@ module Datacite
755
755
  Rights.new(value: 'This work is free of known copyright restrictions.', uri: URI('http://creativecommons.org/publicdomain/mark/1.0/'))
756
756
  ]
757
757
  args[:rights_list] = rights_list
758
- resource = Resource.new(args)
758
+ resource = Resource.new(**args)
759
759
  expect(resource.rights_list).to eq(rights_list)
760
760
  end
761
761
  it 'can\'t be initialized to nil' do
762
762
  args[:rights_list] = nil
763
- resource = Resource.new(args)
763
+ resource = Resource.new(**args)
764
764
  expect(resource.rights_list).to eq([])
765
765
  end
766
766
  end
767
767
 
768
768
  describe '#rights_list=' do
769
769
  it 'can be set' do
770
- resource = Resource.new(args)
770
+ resource = Resource.new(**args)
771
771
  rights_list = [
772
772
  Rights.new(value: 'CC0 1.0 Universal', uri: URI('http://creativecommons.org/publicdomain/zero/1.0/')),
773
773
  Rights.new(value: 'This work is free of known copyright restrictions.', uri: URI('http://creativecommons.org/publicdomain/mark/1.0/'))
@@ -777,7 +777,7 @@ module Datacite
777
777
  end
778
778
 
779
779
  it 'can\'t be set to nil' do
780
- resource = Resource.new(args)
780
+ resource = Resource.new(**args)
781
781
  resource.rights_list = nil
782
782
  expect(resource.rights_list).to eq([])
783
783
  end
@@ -787,7 +787,7 @@ module Datacite
787
787
 
788
788
  describe '#descriptions' do
789
789
  it 'defaults to empty' do
790
- resource = Resource.new(args)
790
+ resource = Resource.new(**args)
791
791
  expect(resource.descriptions).to eq([])
792
792
  end
793
793
 
@@ -798,12 +798,12 @@ module Datacite
798
798
  Description.new(language: 'en-us', type: DescriptionType::METHODS, value: 'unsound')
799
799
  ]
800
800
  args[:descriptions] = descriptions
801
- resource = Resource.new(args)
801
+ resource = Resource.new(**args)
802
802
  expect(resource.descriptions).to eq(descriptions)
803
803
  end
804
804
  it 'can\'t be initialized to nil' do
805
805
  args[:descriptions] = nil
806
- resource = Resource.new(args)
806
+ resource = Resource.new(**args)
807
807
  expect(resource.descriptions).to eq([])
808
808
  end
809
809
 
@@ -814,7 +814,7 @@ module Datacite
814
814
  Description.allocate
815
815
  ]
816
816
  args[:descriptions] = descriptions
817
- resource = Resource.new(args)
817
+ resource = Resource.new(**args)
818
818
  expect(resource.descriptions).to eq([descriptions[1]])
819
819
  end
820
820
  end
@@ -825,12 +825,12 @@ module Datacite
825
825
  Description.new(language: 'en-us', type: DescriptionType::ABSTRACT, value: 'Exterminate all the brutes!'),
826
826
  Description.new(language: 'en-us', type: DescriptionType::METHODS, value: 'unsound')
827
827
  ]
828
- resource = Resource.new(args)
828
+ resource = Resource.new(**args)
829
829
  resource.descriptions = descriptions
830
830
  expect(resource.descriptions).to eq(descriptions)
831
831
  end
832
832
  it 'can\'t be set to nil' do
833
- resource = Resource.new(args)
833
+ resource = Resource.new(**args)
834
834
  resource.descriptions = nil
835
835
  expect(resource.descriptions).to eq([])
836
836
  end
@@ -841,7 +841,7 @@ module Datacite
841
841
  Description.new(language: 'en-us', type: DescriptionType::METHODS, value: 'unsound'),
842
842
  Description.allocate
843
843
  ]
844
- resource = Resource.new(args)
844
+ resource = Resource.new(**args)
845
845
  resource.descriptions = descriptions
846
846
  expect(resource.descriptions).to eq([descriptions[1]])
847
847
  end
@@ -850,7 +850,7 @@ module Datacite
850
850
 
851
851
  describe '#geo_locations' do
852
852
  it 'defaults to empty' do
853
- resource = Resource.new(args)
853
+ resource = Resource.new(**args)
854
854
  expect(resource.geo_locations).to eq([])
855
855
  end
856
856
 
@@ -861,12 +861,12 @@ module Datacite
861
861
  GeoLocation.new(box: GeoLocationBox.new(-33.45, -122.33, 47.61, -70.67))
862
862
  ]
863
863
  args[:geo_locations] = geo_locations
864
- resource = Resource.new(args)
864
+ resource = Resource.new(**args)
865
865
  expect(resource.geo_locations).to eq(geo_locations)
866
866
  end
867
867
  it 'can\'t be initialized to nil' do
868
868
  args[:geo_locations] = nil
869
- resource = Resource.new(args)
869
+ resource = Resource.new(**args)
870
870
  expect(resource.geo_locations).to eq([])
871
871
  end
872
872
  it 'ignores empty locations' do
@@ -876,14 +876,14 @@ module Datacite
876
876
  GeoLocation.new
877
877
  ]
878
878
  args[:geo_locations] = geo_locations
879
- resource = Resource.new(args)
879
+ resource = Resource.new(**args)
880
880
  expect(resource.geo_locations).to eq([geo_locations[1]])
881
881
  end
882
882
  end
883
883
 
884
884
  describe '#geo_locations=' do
885
885
  it 'can be set' do
886
- resource = Resource.new(args)
886
+ resource = Resource.new(**args)
887
887
  geo_locations = [
888
888
  GeoLocation.new(point: GeoLocationPoint.new(47.61, -122.33)),
889
889
  GeoLocation.new(box: GeoLocationBox.new(-33.45, -122.33, 47.61, -70.67))
@@ -892,12 +892,12 @@ module Datacite
892
892
  expect(resource.geo_locations).to eq(geo_locations)
893
893
  end
894
894
  it 'can\'t be set to nil' do
895
- resource = Resource.new(args)
895
+ resource = Resource.new(**args)
896
896
  resource.geo_locations = nil
897
897
  expect(resource.geo_locations).to eq([])
898
898
  end
899
899
  it 'ignores empty locations' do
900
- resource = Resource.new(args)
900
+ resource = Resource.new(**args)
901
901
  geo_locations = [
902
902
  GeoLocation.new,
903
903
  GeoLocation.new(point: GeoLocationPoint.new(47.61, -122.33)),
@@ -945,14 +945,13 @@ module Datacite
945
945
  r3 = r2.gsub(/<resource (xmlns:xsi="[^"]+")\s+(xsi:schemaLocation="[^"]+")>/, '<resource \\2 \\1 xmlns="http://datacite.org/schema/kernel-3">') # fix missing namespace
946
946
  r4 = r3.gsub(%r{(<identifier[^>]+>)\s*([^ ]+)\s*(</identifier>)}, '\\1\\2\\3') # trim identifiers
947
947
  r5 = r4.gsub(%r{<([^>]+tude)>([0-9.-]+?)(0?)0+</\1>}, '<\\1>\\2\\3</\\1>') # strip trailing coordinate zeroes
948
- r6 = r5.gsub(%r{<(geoLocation[^>]+)>[^<]+</\1>}) { |loc| loc.gsub(/([0-9\-]+\.[0-9]+?)0+([^0-9])/, '\\1\\2') } # strip trailing coordinate zeroes
948
+ r6 = r5.gsub(%r{<(geoLocation[^>]+)>[^<]+</\1>}) { |loc| loc.gsub(/([0-9-]+\.[0-9]+?)0+([^0-9])/, '\\1\\2') } # strip trailing coordinate zeroes
949
949
  r7 = r6.gsub(%r{<([A-Za-z]*)[^>]*>\s*</\1>}, '') # remove empty tag pairs
950
- r8 = to_pretty(r7)
950
+ to_pretty(r7)
951
951
  # if r8.include?('&lt;br')
952
952
  # trace = [r0, r1, r2, r3, r4, r5, r6, r7, r8].map { |r| r.include?('&lt;br') }
953
953
  # puts trace
954
954
  # end
955
- r8
956
955
  end
957
956
 
958
957
  def to_pretty(xml_text)
@@ -977,7 +976,7 @@ module Datacite
977
976
  r3.gsub(%r{(<contributor[^>/]+>\s*)<contributor>([^<]+)</contributor>(\s*</contributor>)}, '\\1<contributorName>\\2</contributorName>\\3') # fix broken contributors
978
977
  end
979
978
 
980
- def it_round_trips(file:, mapping: :_default, fix_dash1: false) # rubocop:disable Metrics/AbcSize
979
+ def it_round_trips(file:, mapping: :_default, fix_dash1: false)
981
980
  options = { mapping: mapping }
982
981
  basename = File.basename(file)
983
982
  xml_text = xml_text_from(file, fix_dash1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datacite-mapping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
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-26 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typesafe_enum
@@ -455,14 +455,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
455
455
  requirements:
456
456
  - - ">="
457
457
  - !ruby/object:Gem::Version
458
- version: '0'
458
+ version: 3.0.0
459
459
  required_rubygems_version: !ruby/object:Gem::Requirement
460
460
  requirements:
461
461
  - - ">="
462
462
  - !ruby/object:Gem::Version
463
463
  version: '0'
464
464
  requirements: []
465
- rubygems_version: 3.1.4
465
+ rubygems_version: 3.2.33
466
466
  signing_key:
467
467
  specification_version: 4
468
468
  summary: Parses and generates Datacite XML documents