datacite-mapping 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a91f9e92cf4a42a6c6aca44d3c36e40f8510718
4
- data.tar.gz: 7de721bdcf72f3777175043bd9cf8f31d7f2c141
3
+ metadata.gz: c79053989c440d5710c31da54a67e010273171e4
4
+ data.tar.gz: 20c42a0f8f6a37acd2993b30c7b56902e51af652
5
5
  SHA512:
6
- metadata.gz: 476908576e8337442ce8e0404cd45af2e2ede7326b38316a17edae256a16b10e3ec71490490e2fd6cf6a18b31d39185b71373c7881bdf5bb330958c757202a2c
7
- data.tar.gz: a5c4abf35c4d71aef347dd975256dc2ac231c5c2fcf7709511c13f5d9da367927bcadcf5a2a31d34f54d242e28b0c9bf0b05d3cc19e46702ae7ef082de5da38d
6
+ metadata.gz: 3bc96db87aaf5b26b8ea9059633b0d50ec811678ef4a95be3940775e68955363418c2f062fc265d1ff7bc28ea9f93205186087d47a3347a0de0d0e2cebc8cb08
7
+ data.tar.gz: 2ee12cf0fc5d0d5b1cf93e3ec461992870a389d368830944c45bb3ee6911cabb3444305d41a48260a3c9e903297c7b8ec8ff216ee4f68703d179d077c5d6454c
data/CHANGES.md CHANGED
@@ -1,4 +1,9 @@
1
- ## 0.1.7 (Next)
1
+ ## 0.1.8 (Next)
2
+
3
+ ## 0.1.7 (28 March 2016)
4
+
5
+ - Stop having XML::Mapping generate accessors for fields that need validation (& stop using aliasing
6
+ to layer validation on top of generated accessors)
2
7
 
3
8
  ## 0.1.6 (24 March 2016)
4
9
 
@@ -1,16 +1,5 @@
1
1
  require 'logger'
2
2
 
3
- module XML
4
- module Mapping
5
- module ClassMethods
6
- def maybe_alias(new_name, old_name)
7
- return alias_method new_name, old_name unless method_defined?(new_name)
8
- self
9
- end
10
- end
11
- end
12
- end
13
-
14
3
  # Module for working with the [DataCite metadata schema](https://schema.datacite.org/meta/kernel-3/index.html)
15
4
  module Datacite
16
5
  # Maps DataCite XML to Ruby objects
@@ -47,4 +36,3 @@ module Datacite
47
36
  end
48
37
  end
49
38
  end
50
-
@@ -8,16 +8,6 @@ module Datacite
8
8
  class AlternateIdentifier
9
9
  include XML::Mapping
10
10
 
11
- root_element_name 'alternateIdentifier'
12
-
13
- text_node :type, '@alternateIdentifierType'
14
- text_node :value, 'text()'
15
-
16
- maybe_alias :_type=, :type=
17
- private :_type=
18
- maybe_alias :_value=, :value=
19
- private :_value=
20
-
21
11
  # Initializes a new {AlternateIdentifier}
22
12
  # @param type [String] the identifier type
23
13
  # @param value [String] the identifier value
@@ -30,16 +20,19 @@ module Datacite
30
20
  # @param val [String] the identifier type
31
21
  def type=(val)
32
22
  fail ArgumentError, 'No identifier type provided' unless val
33
- self._type = val
23
+ @type = val
34
24
  end
35
25
 
36
26
  # Sets the value. Cannot be nil.
37
27
  # @param val [String] the value
38
28
  def value=(val)
39
29
  fail ArgumentError, 'No identifier value provided' unless val
40
- self._value = val
30
+ @value = val
41
31
  end
42
32
 
33
+ root_element_name 'alternateIdentifier'
34
+ text_node :type, '@alternateIdentifierType'
35
+ text_node :value, 'text()'
43
36
  end
44
37
  end
45
38
  end
@@ -78,27 +78,6 @@ module Datacite
78
78
  class Contributor
79
79
  include XML::Mapping
80
80
 
81
- # @!attribute [rw] name
82
- # @return [String] the personal name of the contributor, in the format `Family, Given`. Cannot be empty or nil
83
- text_node :name, 'contributorName'
84
-
85
- # @!attribute [rw] identifier
86
- # @return [NameIdentifier, nil] an identifier for the contributor. Optional.
87
- object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil
88
-
89
- # @!attribute [rw] affiliations
90
- # @return [Array<String>] the contributor's affiliations. Defaults to an empty list.
91
- array_node :affiliations, 'affiliation', class: String, default_value: []
92
-
93
- # @!attribute [rw] type
94
- # @return [ContributorType] the contributor type. Cannot be nil.
95
- typesafe_enum_node :type, '@contributorType', class: ContributorType
96
-
97
- maybe_alias :_name=, :name=
98
- maybe_alias :_type=, :type=
99
- private :_name=
100
- private :_type=
101
-
102
81
  # Initializes a new {Contributor}.
103
82
  # @param name [String] the personal name of the contributor, in the format `Family, Given`. Cannot be empty or nil
104
83
  # @param identifier [NameIdentifier, nil] an identifier for the contributor. Optional.
@@ -113,13 +92,29 @@ module Datacite
113
92
 
114
93
  def name=(value)
115
94
  fail ArgumentError, 'Name cannot be empty or nil' unless value && !value.empty?
116
- self._name = value
95
+ @name = value
117
96
  end
118
97
 
119
98
  def type=(value)
120
99
  fail ArgumentError, 'Type cannot be nil' unless value
121
- self._type = value
100
+ @type = value
122
101
  end
102
+
103
+ # @!attribute [rw] name
104
+ # @return [String] the personal name of the contributor, in the format `Family, Given`. Cannot be empty or nil
105
+ text_node :name, 'contributorName'
106
+
107
+ # @!attribute [rw] identifier
108
+ # @return [NameIdentifier, nil] an identifier for the contributor. Optional.
109
+ object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil
110
+
111
+ # @!attribute [rw] affiliations
112
+ # @return [Array<String>] the contributor's affiliations. Defaults to an empty list.
113
+ array_node :affiliations, 'affiliation', class: String, default_value: []
114
+
115
+ # @!attribute [rw] type
116
+ # @return [ContributorType] the contributor type. Cannot be nil.
117
+ typesafe_enum_node :type, '@contributorType', class: ContributorType
123
118
  end
124
119
  end
125
120
  end
@@ -7,24 +7,6 @@ module Datacite
7
7
  class Creator
8
8
  include XML::Mapping
9
9
 
10
- # @!attribute [rw] name
11
- # @return [String] The personal name of the creator, in the format `Family, Given`. Cannot be empty or nil.
12
- text_node :name, 'creatorName'
13
-
14
- # @!attribute [rw] identifier
15
- # @return [NameIdentifier, nil] An identifier for the creator. Optional.
16
- object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil
17
-
18
- # @!attribute [rw] affiliations
19
- # @return [Array<String>, nil] The creator's affiliations. Defaults to an empty list.
20
- array_node :affiliations, 'affiliation', class: String, default_value: []
21
-
22
- maybe_alias :_name=, :name=
23
- private :_name=
24
-
25
- maybe_alias :_affiliations=, :affiliations=
26
- private :_affiliations=
27
-
28
10
  # Initializes a new {Creator}.
29
11
  # @param name [String] The personal name of the creator, in the format `Family, Given`. Cannot be empty or nil.
30
12
  # @param identifier [NameIdentifier, nil] An identifier for the creator. Optional.
@@ -37,12 +19,25 @@ module Datacite
37
19
 
38
20
  def name=(value)
39
21
  fail ArgumentError, 'Name cannot be empty or nil' unless value && !value.empty?
40
- self._name = value
22
+ @name = value
41
23
  end
42
24
 
43
25
  def affiliations=(value)
44
- self._affiliations = value || []
26
+ @affiliations = value || []
45
27
  end
28
+
29
+ # @!attribute [rw] name
30
+ # @return [String] The personal name of the creator, in the format `Family, Given`. Cannot be empty or nil.
31
+ text_node :name, 'creatorName'
32
+
33
+ # @!attribute [rw] identifier
34
+ # @return [NameIdentifier, nil] An identifier for the creator. Optional.
35
+ object_node :identifier, 'nameIdentifier', class: NameIdentifier, default_value: nil
36
+
37
+ # @!attribute [rw] affiliations
38
+ # @return [Array<String>, nil] The creator's affiliations. Defaults to an empty list.
39
+ array_node :affiliations, 'affiliation', class: String, default_value: []
40
+
46
41
  end
47
42
  end
48
43
  end
@@ -54,18 +54,6 @@ module Datacite
54
54
  class Date
55
55
  include XML::Mapping
56
56
 
57
- # @!attribute [rw] type
58
- # @return [DateType] the type of date. Cannot be nil.
59
- typesafe_enum_node :type, '@dateType', class: DateType
60
- maybe_alias :_type=, :type=
61
- private :_type=
62
-
63
- # @!method value
64
- # @return [String] The value as a string. May be any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime).
65
- text_node :value, 'text()'
66
- maybe_alias :_value=, :value=
67
- private :_value=
68
-
69
57
  attr_reader :year
70
58
  attr_reader :month
71
59
  attr_reader :day
@@ -86,7 +74,7 @@ module Datacite
86
74
 
87
75
  def type=(val)
88
76
  fail ArgumentError, 'Date type cannot be nil' unless val
89
- self._type = val
77
+ @type = val
90
78
  end
91
79
 
92
80
  # Sets the value.
@@ -107,7 +95,7 @@ module Datacite
107
95
  @nsec = @date_time.to_time.nsec if @date_time
108
96
  end
109
97
  fail ArgumentError, "Unable to parse date value '#{val}'" unless @year
110
- self._value = new_value
98
+ @value = new_value
111
99
  end
112
100
 
113
101
  private
@@ -148,6 +136,13 @@ module Datacite
148
136
  nil
149
137
  end
150
138
 
139
+ # @!attribute [rw] type
140
+ # @return [DateType] the type of date. Cannot be nil.
141
+ typesafe_enum_node :type, '@dateType', class: DateType
142
+
143
+ # @!method value
144
+ # @return [String] The value as a string. May be any [W3C DateTime format](http://www.w3.org/TR/NOTE-datetime).
145
+ text_node :value, 'text()'
151
146
  end
152
147
  end
153
148
  end
@@ -76,26 +76,6 @@ module Datacite
76
76
  class Description
77
77
  include XML::Mapping
78
78
 
79
- # @!attribute [rw] language
80
- # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
81
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
82
- text_node :language, '@xml:lang', default_value: nil
83
-
84
- # @!attribute [rw] type
85
- # @return [DescriptionType] the description type.
86
- typesafe_enum_node :type, '@descriptionType', class: DescriptionType
87
-
88
- # @!attribute [rw] value
89
- # @return [String] the description itself. See {Description} for notes on special
90
- # handling of `<br/>` tags.
91
- break_preserving_value_node :value, 'node()'
92
-
93
- maybe_alias :_language, :language
94
- private :_language
95
-
96
- maybe_alias :_language=, :language=
97
- private :_language=
98
-
99
79
  # Initializes a new {Description}
100
80
  # @param language [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
101
81
  # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
@@ -109,13 +89,27 @@ module Datacite
109
89
  end
110
90
 
111
91
  def language
112
- _language || 'en'
92
+ @language || 'en'
113
93
  end
114
94
 
115
95
  def language=(value)
116
- self._language = value.strip if value
96
+ @language = value.strip if value
117
97
  end
118
98
 
99
+ # @!attribute [rw] language
100
+ # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
101
+ # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
102
+ text_node :language, '@xml:lang', default_value: nil
103
+
104
+ # @!attribute [rw] type
105
+ # @return [DescriptionType] the description type.
106
+ typesafe_enum_node :type, '@descriptionType', class: DescriptionType
107
+
108
+ # @!attribute [rw] value
109
+ # @return [String] the description itself. See {Description} for notes on special
110
+ # handling of `<br/>` tags.
111
+ break_preserving_value_node :value, 'node()'
112
+
119
113
  end
120
114
  end
121
115
  end
@@ -13,6 +13,20 @@ module Datacite
13
13
  class GeoLocation
14
14
  include XML::Mapping
15
15
 
16
+ # Initializes a new {GeoLocation}
17
+ # @param point [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
18
+ # @param box [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
19
+ # @param place [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
20
+ def initialize(point: nil, box: nil, place: nil)
21
+ self.point = point
22
+ self.box = box
23
+ self.place = place
24
+ end
25
+
26
+ def place=(value)
27
+ @place = value.respond_to?(:strip) ? value.strip : value
28
+ end
29
+
16
30
  root_element_name 'geoLocation'
17
31
 
18
32
  # @!attribute [rw] point
@@ -27,23 +41,6 @@ module Datacite
27
41
  # @return [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
28
42
  text_node :place, 'geoLocationPlace', default_value: nil
29
43
 
30
- # Initializes a new {GeoLocation}
31
- # @param point [GeoLocationPoint, nil] the latitude and longitude at which the data was gathered or about which the data is focused.
32
- # @param box [GeoLocationBox, nil] the latitude-longitude quadrangle containing the area where the data was gathered or about which the data is focused.
33
- # @param place [String, nil] the spatial region or named place where the data was gathered or about which the data is focused.
34
- def initialize(point: nil, box: nil, place: nil)
35
- self.point = point
36
- self.box = box
37
- self.place = place
38
- end
39
-
40
- maybe_alias :_place=, :place=
41
- private :_place=
42
-
43
- def place=(value)
44
- self._place = value.respond_to?(:strip) ? value.strip : value
45
- end
46
-
47
44
  end
48
45
  end
49
46
  end
@@ -11,9 +11,6 @@ module Datacite
11
11
  class Identifier
12
12
  include XML::Mapping
13
13
 
14
- text_node :identifier_type, '@identifierType'
15
- text_node :value, 'text()'
16
-
17
14
  # Initializes a new {Identifier}
18
15
  # @param value [String]
19
16
  # the identifier value. Must be a valid DOI value (`10.`_registrant code_`/`_suffix_)
@@ -22,15 +19,9 @@ module Datacite
22
19
  self.value = value
23
20
  end
24
21
 
25
- maybe_alias :_value=, :value=
26
- private :_value=
27
-
28
- maybe_alias :_identifier_type=, :identifier_type=
29
- private :_identifier_type=
30
-
31
22
  def value=(v)
32
23
  fail ArgumentError, "Identifier value '#{v}' is not a valid DOI" unless v.match(%r{10\..+/.+})
33
- self._value = v
24
+ @value = v
34
25
  end
35
26
 
36
27
  # Sets the identifier type. Should only be called by the XML mapping engine.
@@ -38,8 +29,11 @@ module Datacite
38
29
  # the identifier type (always 'DOI')
39
30
  def identifier_type=(v)
40
31
  fail ArgumentError, "Identifier type '#{v}' must be 'DOI'" unless 'DOI' == v
41
- self._identifier_type = v
32
+ @identifier_type = v
42
33
  end
34
+
35
+ text_node :identifier_type, '@identifierType'
36
+ text_node :value, 'text()'
43
37
  end
44
38
  end
45
39
  end
@@ -4,7 +4,7 @@ module Datacite
4
4
  NAME = 'datacite-mapping'
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.1.6'
7
+ VERSION = '0.1.7'
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
@@ -6,24 +6,6 @@ module Datacite
6
6
  class NameIdentifier
7
7
  include XML::Mapping
8
8
 
9
- root_element_name 'nameIdentifier'
10
-
11
- # @!attribute [rw] scheme
12
- # @return [String] the name identifier scheme. Cannot be nil.
13
- text_node :scheme, '@nameIdentifierScheme'
14
- # @!attribute [rw] scheme_uri
15
- # @return [URI, nil] the URI of the identifier scheme. Optional.
16
- uri_node :scheme_uri, '@schemeURI', default_value: nil
17
- # @!attribute [rw] value
18
- # @return [String] the identifier value. Cannot be nil.
19
- text_node :value, 'text()'
20
-
21
- maybe_alias :_scheme=, :scheme=
22
- private :_scheme=
23
-
24
- maybe_alias :_value=, :value=
25
- private :_value=
26
-
27
9
  # Initializes a new {NameIdentifier}
28
10
  # @param scheme [Scheme] the name identifier scheme. Cannot be nil.
29
11
  # @param scheme_uri [URI, nil] the URI of the identifier scheme. Optional.
@@ -36,13 +18,26 @@ module Datacite
36
18
 
37
19
  def scheme=(v)
38
20
  fail ArgumentError, 'Scheme cannot be empty or nil' unless v && !v.empty?
39
- self._scheme = v
21
+ @scheme = v
40
22
  end
41
23
 
42
24
  def value=(v)
43
25
  fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty?
44
- self._value = v
26
+ @value = v
45
27
  end
28
+
29
+ root_element_name 'nameIdentifier'
30
+
31
+ # @!attribute [rw] scheme
32
+ # @return [String] the name identifier scheme. Cannot be nil.
33
+ text_node :scheme, '@nameIdentifierScheme'
34
+ # @!attribute [rw] scheme_uri
35
+ # @return [URI, nil] the URI of the identifier scheme. Optional.
36
+ uri_node :scheme_uri, '@schemeURI', default_value: nil
37
+ # @!attribute [rw] value
38
+ # @return [String] the identifier value. Cannot be nil.
39
+ text_node :value, 'text()'
40
+
46
41
  end
47
42
  end
48
43
  end
@@ -141,39 +141,6 @@ module Datacite
141
141
  class RelatedIdentifier
142
142
  include XML::Mapping
143
143
 
144
- root_element_name 'relatedIdentifier'
145
-
146
- # @!attribute [rw] relation_type
147
- # @return [RelationType] the relationship of the {Resource} to the related resource. Cannot be nil.
148
- typesafe_enum_node :relation_type, '@relationType', class: RelationType
149
-
150
- # @!attribute [rw] value
151
- # @return [String] the identifier value. Cannot be nil.
152
- text_node :value, 'text()'
153
-
154
- # @!attribute [rw] identifier_type
155
- # @return [RelatedIdentifierType] the type of the related identifier. Cannot be nil.
156
- typesafe_enum_node :identifier_type, '@relatedIdentifierType', class: RelatedIdentifierType
157
-
158
- # @!attribute [rw] related_metadata_scheme
159
- # @return [String, nil] the name of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
160
- text_node :related_metadata_scheme, '@relatedMetadataScheme', default_value: nil
161
-
162
- # @!attribute [rw] scheme_uri
163
- # @return [URI, nil] the URI of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
164
- uri_node :scheme_uri, '@schemeURI', default_value: nil
165
-
166
- # @!attribute [rw] scheme_type
167
- # @return [String, nil] the type of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
168
- text_node :scheme_type, '@schemeType', default_value: nil
169
-
170
- maybe_alias :_relation_type=, :relation_type=
171
- private :_relation_type=
172
- maybe_alias :_value=, :value=
173
- private :_value=
174
- maybe_alias :_identifier_type=, :identifier_type=
175
- private :_identifier_type=
176
-
177
144
  # Initializes a new {RelatedIdentifier}.
178
145
  # @param relation_type [RelationType] the relationship of the {Resource} to the related resource. Cannot be nil.
179
146
  # @param value [String] the identifier value. Cannot be nil.
@@ -192,18 +159,45 @@ module Datacite
192
159
 
193
160
  def value=(value)
194
161
  fail ArgumentError, 'Value cannot be empty or nil' unless value && !value.empty?
195
- self._value = value
162
+ @value = value
196
163
  end
197
164
 
198
165
  def identifier_type=(value)
199
166
  fail ArgumentError, 'Identifier type cannot be empty or nil' unless value
200
- self._identifier_type = value
167
+ @identifier_type = value
201
168
  end
202
169
 
203
170
  def relation_type=(value)
204
171
  fail ArgumentError, 'Relation type cannot be nil' unless value
205
- self._relation_type = value
172
+ @relation_type = value
206
173
  end
174
+
175
+ root_element_name 'relatedIdentifier'
176
+
177
+ # @!attribute [rw] relation_type
178
+ # @return [RelationType] the relationship of the {Resource} to the related resource. Cannot be nil.
179
+ typesafe_enum_node :relation_type, '@relationType', class: RelationType
180
+
181
+ # @!attribute [rw] value
182
+ # @return [String] the identifier value. Cannot be nil.
183
+ text_node :value, 'text()'
184
+
185
+ # @!attribute [rw] identifier_type
186
+ # @return [RelatedIdentifierType] the type of the related identifier. Cannot be nil.
187
+ typesafe_enum_node :identifier_type, '@relatedIdentifierType', class: RelatedIdentifierType
188
+
189
+ # @!attribute [rw] related_metadata_scheme
190
+ # @return [String, nil] the name of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
191
+ text_node :related_metadata_scheme, '@relatedMetadataScheme', default_value: nil
192
+
193
+ # @!attribute [rw] scheme_uri
194
+ # @return [URI, nil] the URI of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
195
+ uri_node :scheme_uri, '@schemeURI', default_value: nil
196
+
197
+ # @!attribute [rw] scheme_type
198
+ # @return [String, nil] the type of the metadata scheme. Used only with `HasMetadata`/`IsMetadataFor`. Optional.
199
+ text_node :scheme_type, '@schemeType', default_value: nil
200
+
207
201
  end
208
202
  end
209
203
  end
@@ -17,79 +17,6 @@ module Datacite
17
17
  class Resource
18
18
  include XML::Mapping
19
19
 
20
- # @!attribute [rw] identifier
21
- # @return [Identifier] a persistent identifier that identifies a resource.
22
- object_node :identifier, 'identifier', class: Identifier
23
-
24
- # @!attribute [rw] creators
25
- # @return [Array<Creator>] the main researchers involved working on the data, or the authors of the publication in priority order.
26
- array_node :creators, 'creators', 'creator', class: Creator
27
-
28
- # @!attribute [rw] titles
29
- # @return [Array<Title>] the names or titles by which a resource is known.
30
- array_node :titles, 'titles', 'title', class: Title
31
-
32
- # @!attribute [rw] publisher
33
- # @return [String] the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.
34
- text_node :publisher, 'publisher'
35
-
36
- # @!attribute [rw] publication_year
37
- # @return [Integer] year when the resource is made publicly available.
38
- numeric_node :publication_year, 'publicationYear'
39
-
40
- # @!attribute [rw] subjects
41
- # @return [Array<Subject>] subjects, keywords, classification codes, or key phrases describing the resource.
42
- array_node :subjects, 'subjects', 'subject', class: Subject, default_value: []
43
-
44
- # @!attribute [rw] contributors
45
- # @return [Array<Contributor>] institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.
46
- array_node :contributors, 'contributors', 'contributor', class: Contributor, default_value: []
47
-
48
- # @!attribute [rw] dates
49
- # @return [Array<Date>] different dates relevant to the work.
50
- array_node :dates, 'dates', 'date', class: Date, default_value: []
51
-
52
- # @!attribute [rw] language
53
- # @return [String] Primary language of the resource: an IETF BCP 47, ISO 639-1 language code.
54
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
55
- text_node :language, 'language', default_value: nil
56
-
57
- # @!attribute [rw] resource_type
58
- # @return [ResourceType, nil] the type of the resource. Optional.
59
- object_node :resource_type, 'resourceType', class: ResourceType, default_value: nil
60
-
61
- # @!attribute [rw] alternate_identifiers
62
- # @return [Array<AlternateIdentifier>] an identifier or identifiers other than the primary {Identifier} applied to the resource being registered.
63
- array_node :alternate_identifiers, 'alternateIdentifiers', 'alternateIdentifier', class: AlternateIdentifier, default_value: []
64
-
65
- # @!attribute [rw] related_identifiers
66
- # @return [Array<RelatedIdentifier>] identifiers of related resources.
67
- array_node :related_identifiers, 'relatedIdentifiers', 'relatedIdentifier', class: RelatedIdentifier, default_value: []
68
-
69
- # @!attribute [rw] sizes
70
- # @return [Array<String>] unstructured size information about the resource.
71
- array_node :sizes, 'sizes', 'size', class: String, default_value: []
72
-
73
- # @!attribute [rw] formats
74
- # @return [Array<String>] technical format of the resource, e.g. file extension or MIME type.
75
- array_node :formats, 'formats', 'format', class: String, default_value: []
76
-
77
- # @!attribute [rw] version
78
- # @return [String] version number of the resource. Optional.
79
- text_node :version, 'version', default_value: nil
80
-
81
- # @!attribute [rw] rights_list
82
- # @return [Array<Rights>] rights information for this resource.
83
- array_node :rights_list, 'rightsList', 'rights', class: Rights, default_value: []
84
-
85
- # @!attribute [rw] descriptions
86
- # @return [Array<Description>] all additional information that does not fit in any of the other categories.
87
- array_node :descriptions, 'descriptions', 'description', class: Description, default_value: []
88
-
89
- # @!attribute [rw] geo_locations
90
- # @return [Array<GeoLocations>] spatial region or named place where the data was gathered or about which the data is focused.
91
- array_node :geo_locations, 'geoLocations', 'geoLocation', class: GeoLocation, default_value: []
92
-
93
20
  # Initialies a new {Resource}
94
21
  #
95
22
  # @param identifier [Identifier] a persistent identifier that identifies a resource.
@@ -132,58 +59,37 @@ module Datacite
132
59
  self.geo_locations = geo_locations
133
60
  end
134
61
 
135
- maybe_alias :_language, :language
136
- private :_language
137
-
138
- maybe_alias :_language=, :language=
139
- private :_language=
140
-
141
62
  def language
142
- _language || 'en'
63
+ @language || 'en'
143
64
  end
144
65
 
145
66
  def language=(value)
146
- self._language = value.strip if value
67
+ @language = value.strip if value
147
68
  end
148
69
 
149
- maybe_alias :_identifier=, :identifier=
150
- private :_identifier=
151
-
152
70
  def identifier=(value)
153
71
  fail ArgumentError, 'Resource must have an identifier' unless value
154
- self._identifier = value
72
+ @identifier = value
155
73
  end
156
74
 
157
- maybe_alias :_creators=, :creators=
158
- private :_creators=
159
-
160
75
  def creators=(value)
161
76
  fail ArgumentError, 'Resource must have at least one creator' unless value && value.size > 0
162
- self._creators = value
77
+ @creators = value
163
78
  end
164
79
 
165
- maybe_alias :_titles=, :titles=
166
- private :_titles=
167
-
168
80
  def titles=(value)
169
81
  fail ArgumentError, 'Resource must have at least one title' unless value && value.size > 0
170
- self._titles = value
82
+ @titles = value
171
83
  end
172
84
 
173
- maybe_alias :_publisher=, :publisher=
174
- private :_publisher=
175
-
176
85
  def publisher=(value)
177
86
  fail ArgumentError, 'Resource must have at least one publisher' unless value && value.size > 0
178
- self._publisher = value.strip
87
+ @publisher = value.strip
179
88
  end
180
89
 
181
- maybe_alias :_publication_year=, :publication_year=
182
- private :_publication_year=
183
-
184
90
  def publication_year=(value)
185
91
  fail ArgumentError, 'Resource must have a four-digit publication year' unless value && value.to_i.between?(1000, 9999)
186
- self._publication_year = value.to_i
92
+ @publication_year = value.to_i
187
93
  end
188
94
 
189
95
  # Overrides +::XML::Mapping.pre_save+ to write namespace information.
@@ -196,6 +102,79 @@ module Datacite
196
102
  xml
197
103
  end
198
104
 
105
+ # @!attribute [rw] identifier
106
+ # @return [Identifier] a persistent identifier that identifies a resource.
107
+ object_node :identifier, 'identifier', class: Identifier
108
+
109
+ # @!attribute [rw] creators
110
+ # @return [Array<Creator>] the main researchers involved working on the data, or the authors of the publication in priority order.
111
+ array_node :creators, 'creators', 'creator', class: Creator
112
+
113
+ # @!attribute [rw] titles
114
+ # @return [Array<Title>] the names or titles by which a resource is known.
115
+ array_node :titles, 'titles', 'title', class: Title
116
+
117
+ # @!attribute [rw] publisher
118
+ # @return [String] the name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource.
119
+ text_node :publisher, 'publisher'
120
+
121
+ # @!attribute [rw] publication_year
122
+ # @return [Integer] year when the resource is made publicly available.
123
+ numeric_node :publication_year, 'publicationYear'
124
+
125
+ # @!attribute [rw] subjects
126
+ # @return [Array<Subject>] subjects, keywords, classification codes, or key phrases describing the resource.
127
+ array_node :subjects, 'subjects', 'subject', class: Subject, default_value: []
128
+
129
+ # @!attribute [rw] contributors
130
+ # @return [Array<Contributor>] institutions or persons responsible for collecting, creating, or otherwise contributing to the developement of the dataset.
131
+ array_node :contributors, 'contributors', 'contributor', class: Contributor, default_value: []
132
+
133
+ # @!attribute [rw] dates
134
+ # @return [Array<Date>] different dates relevant to the work.
135
+ array_node :dates, 'dates', 'date', class: Date, default_value: []
136
+
137
+ # @!attribute [rw] language
138
+ # @return [String] Primary language of the resource: an IETF BCP 47, ISO 639-1 language code.
139
+ # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
140
+ text_node :language, 'language', default_value: nil
141
+
142
+ # @!attribute [rw] resource_type
143
+ # @return [ResourceType, nil] the type of the resource. Optional.
144
+ object_node :resource_type, 'resourceType', class: ResourceType, default_value: nil
145
+
146
+ # @!attribute [rw] alternate_identifiers
147
+ # @return [Array<AlternateIdentifier>] an identifier or identifiers other than the primary {Identifier} applied to the resource being registered.
148
+ array_node :alternate_identifiers, 'alternateIdentifiers', 'alternateIdentifier', class: AlternateIdentifier, default_value: []
149
+
150
+ # @!attribute [rw] related_identifiers
151
+ # @return [Array<RelatedIdentifier>] identifiers of related resources.
152
+ array_node :related_identifiers, 'relatedIdentifiers', 'relatedIdentifier', class: RelatedIdentifier, default_value: []
153
+
154
+ # @!attribute [rw] sizes
155
+ # @return [Array<String>] unstructured size information about the resource.
156
+ array_node :sizes, 'sizes', 'size', class: String, default_value: []
157
+
158
+ # @!attribute [rw] formats
159
+ # @return [Array<String>] technical format of the resource, e.g. file extension or MIME type.
160
+ array_node :formats, 'formats', 'format', class: String, default_value: []
161
+
162
+ # @!attribute [rw] version
163
+ # @return [String] version number of the resource. Optional.
164
+ text_node :version, 'version', default_value: nil
165
+
166
+ # @!attribute [rw] rights_list
167
+ # @return [Array<Rights>] rights information for this resource.
168
+ array_node :rights_list, 'rightsList', 'rights', class: Rights, default_value: []
169
+
170
+ # @!attribute [rw] descriptions
171
+ # @return [Array<Description>] all additional information that does not fit in any of the other categories.
172
+ array_node :descriptions, 'descriptions', 'description', class: Description, default_value: []
173
+
174
+ # @!attribute [rw] geo_locations
175
+ # @return [Array<GeoLocations>] spatial region or named place where the data was gathered or about which the data is focused.
176
+ array_node :geo_locations, 'geoLocations', 'geoLocation', class: GeoLocation, default_value: []
177
+
199
178
  end
200
179
  end
201
180
  end
@@ -53,19 +53,6 @@ module Datacite
53
53
  class ResourceType
54
54
  include XML::Mapping
55
55
 
56
- root_element_name 'resourceType'
57
-
58
- # @!attribute [rw] resource_type_general
59
- # @return [ResourceTypeGeneral] the general resource type
60
- typesafe_enum_node :resource_type_general, '@resourceTypeGeneral', class: ResourceTypeGeneral
61
-
62
- # @!attribute [rw] value
63
- # @return [String] additional free text description of the resource type. Optional.
64
- text_node :value, 'text()', default_value: nil
65
-
66
- maybe_alias :_resource_type_general=, :resource_type_general=
67
- private :_resource_type_general=
68
-
69
56
  # Initializes a new {ResourceType}
70
57
  # @param resource_type_general [ResourceTypeGeneral] the general resource type
71
58
  # @param value [String] additional free text description of the resource type.
@@ -76,8 +63,18 @@ module Datacite
76
63
 
77
64
  def resource_type_general=(val)
78
65
  fail ArgumentError, 'General resource type cannot be nil' unless val
79
- self._resource_type_general = val
66
+ @resource_type_general = val
80
67
  end
68
+
69
+ root_element_name 'resourceType'
70
+
71
+ # @!attribute [rw] resource_type_general
72
+ # @return [ResourceTypeGeneral] the general resource type
73
+ typesafe_enum_node :resource_type_general, '@resourceTypeGeneral', class: ResourceTypeGeneral
74
+
75
+ # @!attribute [rw] value
76
+ # @return [String] additional free text description of the resource type. Optional.
77
+ text_node :value, 'text()', default_value: nil
81
78
  end
82
79
  end
83
80
  end
@@ -7,14 +7,6 @@ module Datacite
7
7
  class Rights
8
8
  include XML::Mapping
9
9
 
10
- # @!attribute [rw] uri
11
- # @return [URI, nil] a URI for the license. Optional.
12
- uri_node :uri, '@rightsURI', default_value: nil
13
-
14
- # @!attribute [rw] value
15
- # @return [String] the rights statement. Cannot be empty or nil.
16
- text_node :value, 'text()'
17
-
18
10
  # Initializes a new {Rights} object
19
11
  #
20
12
  # @param uri [URI, nil] a URI for the license. Optional.
@@ -24,13 +16,18 @@ module Datacite
24
16
  self.value = value
25
17
  end
26
18
 
27
- maybe_alias :_value=, :value=
28
- private :_value=
29
-
30
19
  def value=(v)
31
20
  fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty?
32
- self._value = v.strip
21
+ @value = v.strip
33
22
  end
23
+
24
+ # @!attribute [rw] uri
25
+ # @return [URI, nil] a URI for the license. Optional.
26
+ uri_node :uri, '@rightsURI', default_value: nil
27
+
28
+ # @!attribute [rw] value
29
+ # @return [String] the rights statement. Cannot be empty or nil.
30
+ text_node :value, 'text()'
34
31
  end
35
32
  end
36
33
  end
@@ -7,29 +7,6 @@ module Datacite
7
7
  class Subject
8
8
  include XML::Mapping
9
9
 
10
- # @!attribute [rw] scheme
11
- # @return [String, nil] the subject scheme or classification code or authority if one is used. Optional.
12
- text_node :scheme, '@subjectScheme', default_value: nil
13
-
14
- # @!attribute [rw] scheme_uri
15
- # @return [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
16
- uri_node :scheme_uri, '@schemeURI', default_value: nil
17
-
18
- # @!attribute [rw] language
19
- # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
20
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
21
- text_node :language, '@xml:lang', default_value: nil
22
-
23
- # @!attribute [rw] value
24
- # @return [String] the subject itself.
25
- text_node :value, 'text()'
26
-
27
- maybe_alias :_language, :language
28
- private :_language
29
-
30
- maybe_alias :_language=, :language=
31
- private :_language=
32
-
33
10
  # Initializes a new {Subject}
34
11
  # @param scheme [String, nil] the subject scheme or classification code or authority if one is used. Optional.
35
12
  # @param scheme_uri [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
@@ -44,12 +21,30 @@ module Datacite
44
21
  end
45
22
 
46
23
  def language
47
- _language || 'en'
24
+ @language || 'en'
48
25
  end
49
26
 
50
27
  def language=(value)
51
- self._language = value.strip if value
28
+ @language = value.strip if value
52
29
  end
30
+
31
+ # @!attribute [rw] scheme
32
+ # @return [String, nil] the subject scheme or classification code or authority if one is used. Optional.
33
+ text_node :scheme, '@subjectScheme', default_value: nil
34
+
35
+ # @!attribute [rw] scheme_uri
36
+ # @return [URI, nil] the URI of the subject scheme or classification code or authority if one is used. Optional.
37
+ uri_node :scheme_uri, '@schemeURI', default_value: nil
38
+
39
+ # @!attribute [rw] language
40
+ # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
41
+ # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
42
+ text_node :language, '@xml:lang', default_value: nil
43
+
44
+ # @!attribute [rw] value
45
+ # @return [String] the subject itself.
46
+ text_node :value, 'text()'
47
+
53
48
  end
54
49
  end
55
50
  end
@@ -20,25 +20,6 @@ module Datacite
20
20
  class Title
21
21
  include XML::Mapping
22
22
 
23
- # @!attribute [rw] language
24
- # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
25
- # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
26
- text_node :language, '@xml:lang', default_value: nil
27
-
28
- # @!attribute [rw] type
29
- # @return [TitleType, nil] the title type. Optional.
30
- typesafe_enum_node :type, '@titleType', class: TitleType, default_value: nil
31
-
32
- # @!attribute [rw] value
33
- # @return [String] the title itself.
34
- text_node :value, 'text()'
35
-
36
- maybe_alias :_language, :language
37
- private :_language
38
-
39
- maybe_alias :_language=, :language=
40
- private :_language=
41
-
42
23
  # Initializes a new {Title}.
43
24
  # @param language [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
44
25
  # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
@@ -51,19 +32,31 @@ module Datacite
51
32
  end
52
33
 
53
34
  def language
54
- _language || 'en'
35
+ @language || 'en'
55
36
  end
56
37
 
57
38
  def language=(value)
58
- self._language = value.strip if value
39
+ @language = value.strip if value
59
40
  end
60
41
 
61
- maybe_alias :_value=, :value=
62
-
63
42
  def value=(v)
64
43
  fail ArgumentError, 'Value cannot be empty or nil' unless v && !v.empty?
65
- self._value = v.strip
44
+ @value = v.strip
66
45
  end
46
+
47
+ # @!attribute [rw] language
48
+ # @return [String] an IETF BCP 47, ISO 639-1 language code identifying the language.
49
+ # It's unclear from the spec whether language is required; to play it safe, if it's missing, we default to 'en'.
50
+ text_node :language, '@xml:lang', default_value: nil
51
+
52
+ # @!attribute [rw] type
53
+ # @return [TitleType, nil] the title type. Optional.
54
+ typesafe_enum_node :type, '@titleType', class: TitleType, default_value: nil
55
+
56
+ # @!attribute [rw] value
57
+ # @return [String] the title itself.
58
+ text_node :value, 'text()'
59
+
67
60
  end
68
61
  end
69
62
  end
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.1.6
4
+ version: 0.1.7
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-03-25 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typesafe_enum