ddex 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +16 -8
  3. data/lib/ddex/element.rb +3 -1
  4. data/lib/ddex/ern.rb +101 -76
  5. data/lib/ddex/ern/v41.rb +11 -0
  6. data/lib/ddex/ern/v41/additional_title.rb +49 -0
  7. data/lib/ddex/ern/v41/administrating_record_company_role.rb +35 -0
  8. data/lib/ddex/ern/v41/administrating_record_company_with_reference.rb +31 -0
  9. data/lib/ddex/ern/v41/affiliation.rb +39 -0
  10. data/lib/ddex/ern/v41/all_territory_code.rb +32 -0
  11. data/lib/ddex/ern/v41/aspect_ratio.rb +32 -0
  12. data/lib/ddex/ern/v41/audio_codec_type.rb +38 -0
  13. data/lib/ddex/ern/v41/av_rating.rb +38 -0
  14. data/lib/ddex/ern/v41/bit_rate.rb +32 -0
  15. data/lib/ddex/ern/v41/c_line.rb +34 -0
  16. data/lib/ddex/ern/v41/c_line_with_default.rb +40 -0
  17. data/lib/ddex/ern/v41/carrier_type.rb +35 -0
  18. data/lib/ddex/ern/v41/catalog_number.rb +32 -0
  19. data/lib/ddex/ern/v41/chapter.rb +49 -0
  20. data/lib/ddex/ern/v41/chapter_list.rb +33 -0
  21. data/lib/ddex/ern/v41/character.rb +35 -0
  22. data/lib/ddex/ern/v41/commercial_model_type.rb +35 -0
  23. data/lib/ddex/ern/v41/condition_for_rights_claim_policy.rb +32 -0
  24. data/lib/ddex/ern/v41/container_format.rb +35 -0
  25. data/lib/ddex/ern/v41/contributor.rb +41 -0
  26. data/lib/ddex/ern/v41/contributor_role.rb +35 -0
  27. data/lib/ddex/ern/v41/core_area.rb +30 -0
  28. data/lib/ddex/ern/v41/courtesy_line_with_default.rb +38 -0
  29. data/lib/ddex/ern/v41/cue_origin.rb +35 -0
  30. data/lib/ddex/ern/v41/cue_sheet_type.rb +35 -0
  31. data/lib/ddex/ern/v41/cue_theme_type.rb +35 -0
  32. data/lib/ddex/ern/v41/cue_use_type.rb +35 -0
  33. data/lib/ddex/ern/v41/cue_visual_perception_type.rb +35 -0
  34. data/lib/ddex/ern/v41/cue_vocal_type.rb +35 -0
  35. data/lib/ddex/ern/v41/current_territory_code.rb +32 -0
  36. data/lib/ddex/ern/v41/deal.rb +36 -0
  37. data/lib/ddex/ern/v41/deal_list.rb +30 -0
  38. data/lib/ddex/ern/v41/deal_resource_reference_list.rb +29 -0
  39. data/lib/ddex/ern/v41/deal_technical_resource_details_reference_list.rb +29 -0
  40. data/lib/ddex/ern/v41/deal_terms.rb +66 -0
  41. data/lib/ddex/ern/v41/deal_terms_technical_instantiation.rb +32 -0
  42. data/lib/ddex/ern/v41/deity.rb +35 -0
  43. data/lib/ddex/ern/v41/delegated_usage_rights.rb +34 -0
  44. data/lib/ddex/ern/v41/description_with_territory.rb +38 -0
  45. data/lib/ddex/ern/v41/detailed_cue.rb +59 -0
  46. data/lib/ddex/ern/v41/detailed_cue_sheet.rb +35 -0
  47. data/lib/ddex/ern/v41/detailed_cue_sheet_list.rb +30 -0
  48. data/lib/ddex/ern/v41/detailed_hash_sum.rb +34 -0
  49. data/lib/ddex/ern/v41/detailed_party_id.rb +35 -0
  50. data/lib/ddex/ern/v41/detailed_resource_contributor.rb +44 -0
  51. data/lib/ddex/ern/v41/discoverable_use_type.rb +38 -0
  52. data/lib/ddex/ern/v41/display_artist.rb +39 -0
  53. data/lib/ddex/ern/v41/display_artist_name_with_default.rb +38 -0
  54. data/lib/ddex/ern/v41/display_artist_role.rb +35 -0
  55. data/lib/ddex/ern/v41/display_credit_party.rb +13 -0
  56. data/lib/ddex/ern/v41/display_credits.rb +29 -0
  57. data/lib/ddex/ern/v41/display_sub_title.rb +39 -0
  58. data/lib/ddex/ern/v41/display_title.rb +40 -0
  59. data/lib/ddex/ern/v41/display_title_text.rb +38 -0
  60. data/lib/ddex/ern/v41/distribution_channel_page.rb +34 -0
  61. data/lib/ddex/ern/v41/dsp.rb +35 -0
  62. data/lib/ddex/ern/v41/event_date.rb +47 -0
  63. data/lib/ddex/ern/v41/event_date_time.rb +47 -0
  64. data/lib/ddex/ern/v41/event_date_time_without_flags.rb +41 -0
  65. data/lib/ddex/ern/v41/event_date_with_default.rb +38 -0
  66. data/lib/ddex/ern/v41/event_date_without_flags.rb +41 -0
  67. data/lib/ddex/ern/v41/extent.rb +32 -0
  68. data/lib/ddex/ern/v41/external_resource_link.rb +35 -0
  69. data/lib/ddex/ern/v41/externally_linked_resource_type.rb +35 -0
  70. data/lib/ddex/ern/v41/file.rb +32 -0
  71. data/lib/ddex/ern/v41/fingerprint.rb +36 -0
  72. data/lib/ddex/ern/v41/fingerprint_algorithm_type.rb +35 -0
  73. data/lib/ddex/ern/v41/first_publication_date.rb +35 -0
  74. data/lib/ddex/ern/v41/frame_rate.rb +32 -0
  75. data/lib/ddex/ern/v41/fulfillment_date_with_territory.rb +36 -0
  76. data/lib/ddex/ern/v41/genre_with_territory.rb +39 -0
  77. data/lib/ddex/ern/v41/hash_sum_algorithm_type.rb +35 -0
  78. data/lib/ddex/ern/v41/image.rb +80 -0
  79. data/lib/ddex/ern/v41/image_codec_type.rb +38 -0
  80. data/lib/ddex/ern/v41/image_type.rb +35 -0
  81. data/lib/ddex/ern/v41/instrument_type.rb +35 -0
  82. data/lib/ddex/ern/v41/keywords_with_territory.rb +38 -0
  83. data/lib/ddex/ern/v41/linked_release_resource_reference.rb +41 -0
  84. data/lib/ddex/ern/v41/marketing_comment.rb +38 -0
  85. data/lib/ddex/ern/v41/message_audit_trail.rb +30 -0
  86. data/lib/ddex/ern/v41/message_audit_trail_event.rb +31 -0
  87. data/lib/ddex/ern/v41/message_header.rb +39 -0
  88. data/lib/ddex/ern/v41/messaging_party_without_code.rb +32 -0
  89. data/lib/ddex/ern/v41/musical_work_id.rb +36 -0
  90. data/lib/ddex/ern/v41/name.rb +32 -0
  91. data/lib/ddex/ern/v41/name_used_in_display_credit.rb +14 -0
  92. data/lib/ddex/ern/v41/new_release_message.rb +54 -0
  93. data/lib/ddex/ern/v41/operating_system_type.rb +38 -0
  94. data/lib/ddex/ern/v41/p_line.rb +37 -0
  95. data/lib/ddex/ern/v41/p_line_with_default.rb +40 -0
  96. data/lib/ddex/ern/v41/parental_warning_type_with_territory.rb +41 -0
  97. data/lib/ddex/ern/v41/party.rb +38 -0
  98. data/lib/ddex/ern/v41/party_list.rb +30 -0
  99. data/lib/ddex/ern/v41/party_name.rb +39 -0
  100. data/lib/ddex/ern/v41/party_name_with_territory.rb +51 -0
  101. data/lib/ddex/ern/v41/party_name_without_code.rb +35 -0
  102. data/lib/ddex/ern/v41/party_relationship_type.rb +35 -0
  103. data/lib/ddex/ern/v41/percentage.rb +32 -0
  104. data/lib/ddex/ern/v41/period.rb +34 -0
  105. data/lib/ddex/ern/v41/period_without_flags.rb +34 -0
  106. data/lib/ddex/ern/v41/physical_returns.rb +30 -0
  107. data/lib/ddex/ern/v41/prefix.rb +32 -0
  108. data/lib/ddex/ern/v41/preview_details.rb +31 -0
  109. data/lib/ddex/ern/v41/price.rb +32 -0
  110. data/lib/ddex/ern/v41/price_information_with_type.rb +37 -0
  111. data/lib/ddex/ern/v41/price_type.rb +32 -0
  112. data/lib/ddex/ern/v41/promotional_code.rb +32 -0
  113. data/lib/ddex/ern/v41/proprietary_id.rb +32 -0
  114. data/lib/ddex/ern/v41/purge_release_message.rb +36 -0
  115. data/lib/ddex/ern/v41/purged_release.rb +34 -0
  116. data/lib/ddex/ern/v41/purpose.rb +35 -0
  117. data/lib/ddex/ern/v41/raga.rb +35 -0
  118. data/lib/ddex/ern/v41/rating_agency.rb +35 -0
  119. data/lib/ddex/ern/v41/reason.rb +32 -0
  120. data/lib/ddex/ern/v41/related_party.rb +31 -0
  121. data/lib/ddex/ern/v41/related_release.rb +45 -0
  122. data/lib/ddex/ern/v41/related_resource.rb +34 -0
  123. data/lib/ddex/ern/v41/release.rb +89 -0
  124. data/lib/ddex/ern/v41/release_deal.rb +31 -0
  125. data/lib/ddex/ern/v41/release_id.rb +35 -0
  126. data/lib/ddex/ern/v41/release_label_reference.rb +47 -0
  127. data/lib/ddex/ern/v41/release_list.rb +32 -0
  128. data/lib/ddex/ern/v41/release_relationship_type.rb +35 -0
  129. data/lib/ddex/ern/v41/release_type_for_release_notification.rb +35 -0
  130. data/lib/ddex/ern/v41/resource_contained_resource_reference.rb +33 -0
  131. data/lib/ddex/ern/v41/resource_contained_resource_reference_list.rb +30 -0
  132. data/lib/ddex/ern/v41/resource_group.rb +51 -0
  133. data/lib/ddex/ern/v41/resource_group_content_item.rb +37 -0
  134. data/lib/ddex/ern/v41/resource_id.rb +42 -0
  135. data/lib/ddex/ern/v41/resource_list.rb +40 -0
  136. data/lib/ddex/ern/v41/resource_proprietary_id.rb +33 -0
  137. data/lib/ddex/ern/v41/resource_rights_controller.rb +42 -0
  138. data/lib/ddex/ern/v41/resource_sub_group.rb +54 -0
  139. data/lib/ddex/ern/v41/rights_claim_policy.rb +31 -0
  140. data/lib/ddex/ern/v41/sampling_rate.rb +32 -0
  141. data/lib/ddex/ern/v41/sheet_music.rb +79 -0
  142. data/lib/ddex/ern/v41/sheet_music_codec_type.rb +38 -0
  143. data/lib/ddex/ern/v41/sheet_music_id.rb +34 -0
  144. data/lib/ddex/ern/v41/sheet_music_type.rb +35 -0
  145. data/lib/ddex/ern/v41/simple_rights_type.rb +35 -0
  146. data/lib/ddex/ern/v41/software.rb +84 -0
  147. data/lib/ddex/ern/v41/software_type.rb +35 -0
  148. data/lib/ddex/ern/v41/sound_recording.rb +96 -0
  149. data/lib/ddex/ern/v41/sound_recording_id.rb +36 -0
  150. data/lib/ddex/ern/v41/sound_recording_preview_details.rb +34 -0
  151. data/lib/ddex/ern/v41/sound_recording_type.rb +35 -0
  152. data/lib/ddex/ern/v41/supplemental_document_list.rb +30 -0
  153. data/lib/ddex/ern/v41/synopsis_with_territory.rb +41 -0
  154. data/lib/ddex/ern/v41/tala.rb +35 -0
  155. data/lib/ddex/ern/v41/technical_image_details.rb +55 -0
  156. data/lib/ddex/ern/v41/technical_sheet_music_details.rb +48 -0
  157. data/lib/ddex/ern/v41/technical_software_details.rb +48 -0
  158. data/lib/ddex/ern/v41/technical_sound_recording_details.rb +57 -0
  159. data/lib/ddex/ern/v41/technical_text_details.rb +48 -0
  160. data/lib/ddex/ern/v41/technical_video_details.rb +72 -0
  161. data/lib/ddex/ern/v41/text.rb +82 -0
  162. data/lib/ddex/ern/v41/text_codec_type.rb +38 -0
  163. data/lib/ddex/ern/v41/text_id.rb +36 -0
  164. data/lib/ddex/ern/v41/text_type.rb +35 -0
  165. data/lib/ddex/ern/v41/timing.rb +30 -0
  166. data/lib/ddex/ern/v41/title.rb +36 -0
  167. data/lib/ddex/ern/v41/title_display_information.rb +38 -0
  168. data/lib/ddex/ern/v41/track_release.rb +49 -0
  169. data/lib/ddex/ern/v41/use_type.rb +35 -0
  170. data/lib/ddex/ern/v41/validity_period.rb +31 -0
  171. data/lib/ddex/ern/v41/version_type.rb +35 -0
  172. data/lib/ddex/ern/v41/video.rb +102 -0
  173. data/lib/ddex/ern/v41/video_codec_type.rb +38 -0
  174. data/lib/ddex/ern/v41/video_id.rb +39 -0
  175. data/lib/ddex/ern/v41/video_type.rb +35 -0
  176. data/lib/ddex/ern/v41/work_rights_controller.rb +37 -0
  177. data/lib/ddex/version.rb +3 -1
  178. data/spec/ern_spec.rb +7 -1
  179. data/spec/fixtures/ern/41/instance1.xml +1688 -0
  180. metadata +186 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ee6e4444850b57a563df58898f20194c3397304
4
- data.tar.gz: 4d7a25eb0d5a1e59eb8c42bcfaf994f64a8f2d06
3
+ metadata.gz: 102aa60db3589a4f1306181f86b266ff6e85943e
4
+ data.tar.gz: 7e960f3dabbaa997c7b87cf8233cff520e215536
5
5
  SHA512:
6
- metadata.gz: ac8fe3c14a891dd6af4e7670f11af719f0294229cef495aeee92797c558d7c4015aa5bc16a34ebfd0f23b6b1ea3e18584c2c0936ee5d72af4f4b66f8a7d79ae3
7
- data.tar.gz: 1076cb6fb21cb0628f915b379c1b2fb624ee7a3d76e2bfb5a775553405339781d4376dbb75b53cfe5b28d1de48710455d174978757cabd51bdb0de163bc195e5
6
+ metadata.gz: 5f9a1c4b9a218be6488744766113ff4b554d9f9d1a451c1df1fddc41d7816d7b15852d28931141497ec8e05ee8f6290fc1015f634dd0b8734704662558dbfd7c
7
+ data.tar.gz: 03d5cf0e79d2ea126f3bde773f18395156275f8a9269f242484efe00fd2648951bec453847fc9bc0bab3fc922cee208607c3fa66f686392982024d30c71a3e13
@@ -114,10 +114,21 @@ element of the same name (<code>PriceInformation/PriceType</code>).
114
114
 
115
115
  === Specification Version Detection
116
116
 
117
- The specification version is determined by the <code>MessageSchemaVersionId</code>, which can be:
117
+ An attempt is made to detect the version. How this is done varies by spec and version. See below for details.
118
118
 
119
- 1. Detected based on the root element's value i.e., <code>/node()/@MessageSchemaVersionId</code> (the root element varies by specification)
120
- 2. Explicitly given to DDEX.read via the <code>:version</code> option
119
+ The version can always be explicitly given to <code>DDEX.read</code> via the <code>:version</code> option.
120
+
121
+ ==== ERN >= 4
122
+
123
+ Version is determined by the DDEX XML namespace associated with the doc.
124
+
125
+ For example, given a namespace of: <code>http://ddex.net/xml/ern/41</code> we'll try to match the end, either
126
+ <code>"ern/41"</code> or <code>"ern/41/"</code>. The values used to match the come from
127
+ <code>DDEX::ERN.config[V][:message_schema_version_id]</code> where <code>V</code> is a version string, e.g., <code>"V41"</code>.
128
+
129
+ ==== ERN < 4
130
+
131
+ The version is detected based on the root element's value i.e., <code>/node()/@MessageSchemaVersionId</code>.
121
132
 
122
133
  By default the <code>MessageSchemaVersionId</code> is assumed to be in <code>SPEC/VERSION</code> or <code>VERSION</code> format
123
134
  (any leading, trailing, or duplicate slashes will be stripped), as this seems to be the convention used by most instance docs -though the DDEX specifications
@@ -130,9 +141,6 @@ that vary from this format, and explicitly setting the version is not practical,
130
141
 
131
142
  Note that the version key must match the version's module name.
132
143
 
133
- Feel free to {open an issue}[https://github.com/sshaw/ddex/issues] if you feel this arrangement is problematic or should
134
- be modified to accommodate something else.
135
-
136
144
  === Validation
137
145
 
138
146
  Not yet!
@@ -195,7 +203,7 @@ See CONTRIBUTING.md
195
203
  === See Also
196
204
 
197
205
  * {grid-number}[https://github.com/ScreenStaring/grid-number] - Class for managing Global Release Identifiers
198
- * {iTunes Store Transporter: GUI}[http://transportergui.com] - GUI and workflow automation for the iTunes Store’s Transporter (`iTMSTransporter`)
206
+ * {iTunes Store Transporter: GUI}[http://transportergui.com] - GUI and workflow automation for the iTunes Store’s Transporter (+iTMSTransporter+)
199
207
 
200
208
  === Author
201
209
 
@@ -203,7 +211,7 @@ Skye Shaw [skye.shaw {AT} gmail.com]
203
211
 
204
212
  === License
205
213
 
206
- Copyright (c) 2013 Skye Shaw. Released under the {MIT License}[www.opensource.org/licenses/MIT].
214
+ Copyright (c) 2013-2020 Skye Shaw. Released under the {MIT License}[www.opensource.org/licenses/MIT].
207
215
 
208
216
  ---
209
217
 
@@ -89,7 +89,9 @@ module DDEX
89
89
  eql?(other)
90
90
  end
91
91
 
92
- # TODO: hash()
92
+ def hash
93
+ to_hash.hash
94
+ end
93
95
 
94
96
  private
95
97
  def roxml_attributes
@@ -16,11 +16,18 @@ module DDEX
16
16
  autoload :V38, "ddex/ern/v38"
17
17
  autoload :V381, "ddex/ern/v381"
18
18
  autoload :V382, "ddex/ern/v382"
19
+ autoload :V41, "ddex/ern/v41"
19
20
 
20
21
  ROOT_ELEMENT = "NewReleaseMessage".freeze
21
22
  VERSION_ATTR = "MessageSchemaVersionId".freeze
22
23
 
23
24
  DEFAULT_CONFIG = {
25
+ "V41" => {
26
+ :schema => "http://service.ddex.net/xml/ern/41/release-notification.xsd",
27
+ :version => "4.1",
28
+ :message_schema_version_id => "ern/41"
29
+ },
30
+
24
31
  "V382" => {
25
32
  :schema => "http://ddex.net/xml/ern/382/release-notification.xsd",
26
33
  :version => "3.8.2",
@@ -103,100 +110,118 @@ module DDEX
103
110
  mattr_reader :config
104
111
  @@config = DEFAULT_CONFIG
105
112
 
106
- def self.supported_versions
107
- config.values.map { |cfg| cfg[:version].dup }.sort
108
- end
113
+ class << self
114
+ def supported_versions
115
+ config.values.map { |cfg| cfg[:version].dup }.sort
116
+ end
109
117
 
110
- def self.supports?(version)
111
- version = version.downcase.strip
112
- config.any? { |name,cfg| name == version || cfg[:version] == version || cfg[:message_schema_version_id] == version }
113
- end
118
+ def supports?(version)
119
+ version = version.downcase.strip
120
+ config.any? { |name,cfg| name == version || cfg[:version] == version || cfg[:message_schema_version_id] == version }
121
+ end
114
122
 
115
- # options[:validate] ???
116
- def self.read(xml, options = nil)
117
- options ||= {}
118
- raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
119
-
120
- doc = parse(xml, options)
121
- ver = options[:version] || doc.root[VERSION_ATTR]
122
- klass = load_version(ver)
123
-
124
- begin
125
- klass.from_xml(doc)
126
- rescue NoMethodError => e # Yes, fo real... this is from ROXML
127
- raise unless e.name == :root # It's legit
128
- raise XMLLoadError, "XML is not well-formed"
129
- # This is a subclass of Exception(!) so we must name it
130
- rescue ROXML::RequiredElementMissing => e
131
- raise XMLLoadError, "missing required element: #{e}"
123
+ # options[:validate] ???
124
+ def read(xml, options = nil)
125
+ options ||= {}
126
+ raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
127
+
128
+ doc = parse(xml, options)
129
+ ver = options[:version] || find_version(doc)
130
+ klass = load_version(ver)
131
+
132
+ begin
133
+ klass.from_xml(doc)
134
+ rescue NoMethodError => e # Yes, fo real... this is from ROXML
135
+ raise unless e.name == :root # It's legit
136
+ raise XMLLoadError, "XML is not well-formed"
137
+ # This is a subclass of Exception(!) so we must name it
138
+ rescue ROXML::RequiredElementMissing => e
139
+ raise XMLLoadError, "missing required element: #{e}"
140
+ end
132
141
  end
133
- end
134
142
 
135
- def self.write(object, options = nil)
136
- raise ArgumentError, "not a DDEX object" unless object.is_a?(DDEX::Element)
143
+ def write(object, options = nil)
144
+ raise ArgumentError, "not a DDEX object" unless object.is_a?(DDEX::Element)
145
+
146
+ options ||= {}
147
+ raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
137
148
 
138
- options ||= {}
139
- raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
149
+ xmlopts = options.reject { |k, _| k == :schema }
140
150
 
141
- xmlopts = options.reject { |k, _| k == :schema }
151
+ node = object.to_xml
152
+ return node.to_xml(xmlopts) unless object.class.name.demodulize == ROOT_ELEMENT
142
153
 
143
- node = object.to_xml
144
- return node.to_xml(xmlopts) unless object.respond_to?(:message_schema_version_id) # Is it the root element?
154
+ schema = schema_location(object, options[:schema])
155
+ if schema
156
+ node.add_namespace_definition(XML_SCHEMA_INSTANCE_PREFIX, XML_SCHEMA_INSTANCE_NS)
157
+ node[XML_SCHEMA_INSTANCE_ATTR] = schema
158
+ end
145
159
 
146
- schema = schema_location(object, options[:schema])
147
- if schema
148
- node.add_namespace_definition(XML_SCHEMA_INSTANCE_PREFIX, XML_SCHEMA_INSTANCE_NS)
149
- node[XML_SCHEMA_INSTANCE_ATTR] = schema
160
+ doc = Nokogiri::XML::Document.new
161
+ doc.root = node
162
+ doc.to_xml(xmlopts)
150
163
  end
151
164
 
152
- doc = Nokogiri::XML::Document.new
153
- doc.root = node
154
- doc.to_xml(xmlopts)
155
- end
165
+ private
166
+
167
+ def schema_location(object, schema)
168
+ # extract version from namespace e.g., DDEX::ERN::V36::NewReleaseMessage
169
+ ver = object.class.name.split("::")[-2]
170
+ return unless schema or config.include?(ver)
156
171
 
157
- private
158
- def self.schema_location(object, schema)
159
- # extract version from namespace e.g., DDEX::ERN::V36::NewReleaseMessage
160
- ver = object.class.name.split("::")[-2]
161
- return unless schema or config.include?(ver)
162
-
163
- # Check if it's "NS schema"
164
- if schema && schema.strip.include?(" ")
165
- schema
166
- else
167
- sprintf "%s %s", object.class.ns[1], schema || config[ver][:schema]
172
+ # Check if it's "NS schema"
173
+ if schema && schema.strip.include?(" ")
174
+ schema
175
+ else
176
+ sprintf "%s %s", object.class.ns[1], schema || config[ver][:schema]
177
+ end
168
178
  end
169
- end
170
179
 
171
- def self.parse(xml, options)
172
- xml = File.read(xml) if xml.is_a?(String) and xml !~ /\A\s*<[?\w]/
173
- Nokogiri::XML(xml, nil, options[:encoding]) { |cfg| cfg.strict }
174
- # ArgumentError means there was a problem with types, expected an int, got a str
175
- rescue IOError, SystemCallError, ArgumentError => e
176
- raise XMLLoadError, "cannot load XML: #{e}"
177
- rescue Nokogiri::XML::SyntaxError => e
178
- raise XMLLoadError, "XML parsing error: #{e}"
179
- end
180
+ def find_version(doc)
181
+ return doc.root[VERSION_ATTR] if doc.root[VERSION_ATTR]
180
182
 
181
- def self.raise_unknown_version(version)
182
- message = "ERN version %s" % (version ? "'#{version}'" : "attribute missing")
183
- raise UnknownVersionError, message
184
- end
183
+ # Versions >= 4 don't have VERSION_ATTR so we resort to looking at namespaces.
184
+ # For example, given: http://ddex.net/xml/ern/41
185
+ # We'll try to match the end: "ern/41" or "ern/41/"
186
+ names = doc.collect_namespaces.values
187
+ version = config.values.find do |cfg|
188
+ names.any? { |name| name =~ %r|#{ Regexp.quote(cfg[:message_schema_version_id]) }/?\z|i }
189
+ end
185
190
 
186
- def self.load_version(version)
187
- raise_unknown_version(version) if version.nil?
191
+ return unless version
192
+ version[:message_schema_version_id]
193
+ end
188
194
 
189
- # Some normalization
190
- v = version.strip.gsub(%r{//+}, "/").gsub(%r{\A/|/\Z}, "")
191
- klass, _ = config.find do |name, cfg|
192
- cfg[:message_schema_version_id] == v || cfg[:version] == v
195
+ def parse(xml, options)
196
+ xml = File.read(xml) if xml.is_a?(String) and xml !~ /\A\s*<[?\w]/
197
+ Nokogiri::XML(xml, nil, options[:encoding]) { |cfg| cfg.strict }
198
+ # ArgumentError means there was a problem with types, expected an int, got a str
199
+ rescue IOError, SystemCallError, ArgumentError => e
200
+ raise XMLLoadError, "cannot load XML: #{e}"
201
+ rescue Nokogiri::XML::SyntaxError => e
202
+ raise XMLLoadError, "XML parsing error: #{e}"
193
203
  end
194
- raise_unknown_version(version) unless klass
195
204
 
196
- # >= 2.0 allows for one call
197
- DDEX::ERN.const_get(klass).const_get(ROOT_ELEMENT)
198
- rescue LoadError, NameError => e
199
- raise_unknown_version(version)
205
+ def raise_unknown_version(version)
206
+ message = "ERN version %s" % (version ? "'#{version}' is unsupported" : "attribute missing")
207
+ raise UnknownVersionError, message
208
+ end
209
+
210
+ def load_version(version)
211
+ raise_unknown_version(version) if version.nil?
212
+
213
+ # Some normalization
214
+ v = version.strip.gsub(%r{//+}, "/").gsub(%r{\A/|/\Z}, "")
215
+ klass, _ = config.find do |name, cfg|
216
+ cfg[:message_schema_version_id] == v || cfg[:version] == v
217
+ end
218
+ raise_unknown_version(version) unless klass
219
+
220
+ # >= 2.0 allows for one call
221
+ DDEX::ERN.const_get(klass).const_get(ROOT_ELEMENT)
222
+ rescue LoadError, NameError => e
223
+ raise_unknown_version(version)
224
+ end
200
225
  end
201
226
  end
202
227
  end
@@ -0,0 +1,11 @@
1
+ #
2
+ # Do not edit. Automatically generated by `rake generate:main`.
3
+ #
4
+ module DDEX
5
+ module ERN
6
+ module V41
7
+ extend DDEX
8
+ require_standard("ern", "41")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Auto-generated by jaxb2ruby v0.0.1 on 2020-07-27 20:26:15 -0400
3
+ # https://github.com/sshaw/jaxb2ruby
4
+ #
5
+ #
6
+ # DO NOT MODIFY
7
+ # Automatically generated by jaxb2ruby v0.0.1 (https://github.com/sshaw/jaxb2ruby)
8
+ #
9
+
10
+ require "roxml"
11
+ require "ddex/element"
12
+
13
+ require "ddex/ern/v41/display_sub_title"
14
+
15
+ module DDEX module ERN module V41 # :nodoc: all
16
+
17
+ class DDEX::ERN::V41::AdditionalTitle < Element
18
+ include ROXML
19
+
20
+
21
+ xml_name "AdditionalTitle"
22
+
23
+ xml_accessor :title_text, :from => "TitleText", :required => true
24
+ xml_accessor :sub_titles, :as => [DDEX::ERN::V41::DisplaySubTitle], :from => "SubTitle", :required => false
25
+
26
+
27
+
28
+ xml_accessor :language_and_script_code, :from => "@LanguageAndScriptCode", :required => false
29
+
30
+
31
+ xml_accessor :applicable_territory_code, :from => "@ApplicableTerritoryCode", :required => false
32
+
33
+
34
+ xml_accessor :title_type, :from => "@TitleType", :required => false
35
+
36
+
37
+ xml_accessor :namespace, :from => "@Namespace", :required => false
38
+
39
+
40
+ xml_accessor :user_defined_value, :from => "@UserDefinedValue", :required => false
41
+
42
+
43
+ xml_accessor :default?, :from => "@IsDefault", :required => false
44
+
45
+
46
+
47
+ end
48
+
49
+ end end end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Auto-generated by jaxb2ruby v0.0.1 on 2020-07-27 20:26:15 -0400
3
+ # https://github.com/sshaw/jaxb2ruby
4
+ #
5
+ #
6
+ # DO NOT MODIFY
7
+ # Automatically generated by jaxb2ruby v0.0.1 (https://github.com/sshaw/jaxb2ruby)
8
+ #
9
+
10
+ require "roxml"
11
+ require "ddex/element"
12
+
13
+
14
+ module DDEX module ERN module V41 # :nodoc: all
15
+
16
+ class DDEX::ERN::V41::AdministratingRecordCompanyRole < Element
17
+ include ROXML
18
+
19
+
20
+ xml_name "AdministratingRecordCompanyRole"
21
+
22
+
23
+ xml_accessor :value, :from => ".", :required => false
24
+
25
+
26
+ xml_accessor :namespace, :from => "@Namespace", :required => false
27
+
28
+
29
+ xml_accessor :user_defined_value, :from => "@UserDefinedValue", :required => false
30
+
31
+
32
+
33
+ end
34
+
35
+ end end end
@@ -0,0 +1,31 @@
1
+ #
2
+ # Auto-generated by jaxb2ruby v0.0.1 on 2020-07-27 20:26:15 -0400
3
+ # https://github.com/sshaw/jaxb2ruby
4
+ #
5
+ #
6
+ # DO NOT MODIFY
7
+ # Automatically generated by jaxb2ruby v0.0.1 (https://github.com/sshaw/jaxb2ruby)
8
+ #
9
+
10
+ require "roxml"
11
+ require "ddex/element"
12
+
13
+ require "ddex/ern/v41/administrating_record_company_role"
14
+
15
+ module DDEX module ERN module V41 # :nodoc: all
16
+
17
+ class DDEX::ERN::V41::AdministratingRecordCompanyWithReference < Element
18
+ include ROXML
19
+
20
+
21
+ xml_name "AdministratingRecordCompanyWithReference"
22
+
23
+ xml_accessor :record_company_party_reference, :from => "RecordCompanyPartyReference", :required => true
24
+ xml_accessor :role, :as => DDEX::ERN::V41::AdministratingRecordCompanyRole, :from => "Role", :required => true
25
+
26
+
27
+
28
+
29
+ end
30
+
31
+ end end end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Auto-generated by jaxb2ruby v0.0.1 on 2020-07-27 20:26:15 -0400
3
+ # https://github.com/sshaw/jaxb2ruby
4
+ #
5
+ #
6
+ # DO NOT MODIFY
7
+ # Automatically generated by jaxb2ruby v0.0.1 (https://github.com/sshaw/jaxb2ruby)
8
+ #
9
+
10
+ require "roxml"
11
+ require "ddex/element"
12
+
13
+ require "ddex/ern/v41/current_territory_code"
14
+ require "ddex/ern/v41/simple_rights_type"
15
+ require "ddex/ern/v41/validity_period"
16
+
17
+ module DDEX module ERN module V41 # :nodoc: all
18
+
19
+ class DDEX::ERN::V41::Affiliation < Element
20
+ include ROXML
21
+
22
+
23
+ xml_name "Affiliation"
24
+
25
+ xml_accessor :party_affiliate_reference, :from => "PartyAffiliateReference", :required => false
26
+ xml_accessor :company_name, :from => "CompanyName", :required => false
27
+ xml_accessor :type, :from => "Type", :required => true
28
+ xml_accessor :excluded_territory_codes, :as => [DDEX::ERN::V41::CurrentTerritoryCode], :from => "ExcludedTerritoryCode", :required => false
29
+ xml_accessor :territory_codes, :as => [DDEX::ERN::V41::CurrentTerritoryCode], :from => "TerritoryCode", :required => false
30
+ xml_accessor :validity_period, :as => DDEX::ERN::V41::ValidityPeriod, :from => "ValidityPeriod", :required => false
31
+ xml_accessor :rights_types, :as => [DDEX::ERN::V41::SimpleRightsType], :from => "RightsType", :required => false
32
+ xml_accessor :percentage_of_rights_assignment, :as => Float, :from => "PercentageOfRightsAssignment", :required => false
33
+
34
+
35
+
36
+
37
+ end
38
+
39
+ end end end