datacite-mapping 0.2.4 → 0.2.5

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
  SHA1:
3
- metadata.gz: e8d570ed19b36949ccbd477c42b99eb16decca70
4
- data.tar.gz: 3f9608fb7b9520b69bfc5a4f802d36d3cfeba96b
3
+ metadata.gz: 44bc8fb40c07e1508f27ec6da5fefe71e8c28406
4
+ data.tar.gz: 3ec5ac8144c71ea213111a9b711c61d801cf76d1
5
5
  SHA512:
6
- metadata.gz: 1a4d62507b31e9a3c3086ae9a4f2721c7e8539d0e08d49ccff037e85eaca7a2b740d3055791ba81f8df5589e01ca0ab04d90beec3881c979039a58f874a06a4a
7
- data.tar.gz: 56f0d8270aca2b12cca28998fca293490d8cb30ff89f4af1274fbb571bb81bd1a99d50f978cf42b6e1532ec4e573ebdecaf8e5b067978d5bc5dfb1b6b839cfeb
6
+ metadata.gz: 94be7b6dffca5c5ce26796e9c9149fc0fb3baa8211fd4420f32bc9a8898b931c05df37fe48b2c9fa4a234cf05949500376434511cd54a6c69b70022ab8cc2588
7
+ data.tar.gz: 0eb19b29c6e37d1c11c3ab9539e22faacbdc8427314a88837600400c22d8d3e7984379f20a0b3f2537da4f6c6e8639209eb8b2e5ce5e0efc8acc8fe734c6c138
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.5
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.5 (10 January 2017)
2
+
3
+ - Update to Ruby 2.2.5
4
+ - Treat blank or empty award number as nil when constructing a `FundingReference`.
5
+
1
6
  ## 0.2.4 (8 November 2016)
2
7
 
3
8
  - Fix issue where writing a resource in Datacite 3 would cause the Datacite 3 namespace
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 The Regents of the University of California
3
+ Copyright (c) 2017 The Regents of the University of California
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -89,11 +89,7 @@ module Datacite
89
89
  end
90
90
 
91
91
  def award_number=(value)
92
- @award_number = if value.nil? || value.is_a?(AwardNumber)
93
- value
94
- else
95
- AwardNumber.new(value: value.to_s)
96
- end
92
+ @award_number = award_number_or_nil(value)
97
93
  end
98
94
 
99
95
  def to_s
@@ -107,6 +103,16 @@ module Datacite
107
103
  text_node :award_title, 'awardTitle', default_value: nil
108
104
 
109
105
  fallback_mapping :datacite_3, :_default
106
+
107
+ private
108
+
109
+ def award_number_or_nil(value)
110
+ return nil unless value
111
+ return value if value.is_a?(AwardNumber)
112
+ new_value = value.to_s.strip
113
+ return nil if new_value.empty?
114
+ AwardNumber.new(value: new_value)
115
+ end
110
116
  end
111
117
  end
112
118
  end
@@ -4,7 +4,7 @@ module Datacite
4
4
  NAME = 'datacite-mapping'.freeze
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.2.4'.freeze
7
+ VERSION = '0.2.5'.freeze
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'.freeze
@@ -34,6 +34,16 @@ module Datacite
34
34
  expect(award_number).to be_an(AwardNumber)
35
35
  expect(award_number.value).to eq('9 3/4')
36
36
  end
37
+
38
+ it 'treats an empty award number as nil' do
39
+ fref = FundingReference.new(name: 'Ministry of Magic', award_number: '')
40
+ expect(fref.award_number).to be_nil
41
+ end
42
+
43
+ it 'treats a blank award number as nil' do
44
+ fref = FundingReference.new(name: 'Ministry of Magic', award_number: ' ')
45
+ expect(fref.award_number).to be_nil
46
+ end
37
47
  end
38
48
 
39
49
  describe '#parse_xml' do
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typesafe_enum
@@ -453,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
453
453
  version: '0'
454
454
  requirements: []
455
455
  rubyforge_project:
456
- rubygems_version: 2.6.6
456
+ rubygems_version: 2.6.8
457
457
  signing_key:
458
458
  specification_version: 4
459
459
  summary: Parses and generates Datacite XML documents