ddex 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +16 -8
- data/lib/ddex/element.rb +3 -1
- data/lib/ddex/ern.rb +101 -76
- data/lib/ddex/ern/v41.rb +11 -0
- data/lib/ddex/ern/v41/additional_title.rb +49 -0
- data/lib/ddex/ern/v41/administrating_record_company_role.rb +35 -0
- data/lib/ddex/ern/v41/administrating_record_company_with_reference.rb +31 -0
- data/lib/ddex/ern/v41/affiliation.rb +39 -0
- data/lib/ddex/ern/v41/all_territory_code.rb +32 -0
- data/lib/ddex/ern/v41/aspect_ratio.rb +32 -0
- data/lib/ddex/ern/v41/audio_codec_type.rb +38 -0
- data/lib/ddex/ern/v41/av_rating.rb +38 -0
- data/lib/ddex/ern/v41/bit_rate.rb +32 -0
- data/lib/ddex/ern/v41/c_line.rb +34 -0
- data/lib/ddex/ern/v41/c_line_with_default.rb +40 -0
- data/lib/ddex/ern/v41/carrier_type.rb +35 -0
- data/lib/ddex/ern/v41/catalog_number.rb +32 -0
- data/lib/ddex/ern/v41/chapter.rb +49 -0
- data/lib/ddex/ern/v41/chapter_list.rb +33 -0
- data/lib/ddex/ern/v41/character.rb +35 -0
- data/lib/ddex/ern/v41/commercial_model_type.rb +35 -0
- data/lib/ddex/ern/v41/condition_for_rights_claim_policy.rb +32 -0
- data/lib/ddex/ern/v41/container_format.rb +35 -0
- data/lib/ddex/ern/v41/contributor.rb +41 -0
- data/lib/ddex/ern/v41/contributor_role.rb +35 -0
- data/lib/ddex/ern/v41/core_area.rb +30 -0
- data/lib/ddex/ern/v41/courtesy_line_with_default.rb +38 -0
- data/lib/ddex/ern/v41/cue_origin.rb +35 -0
- data/lib/ddex/ern/v41/cue_sheet_type.rb +35 -0
- data/lib/ddex/ern/v41/cue_theme_type.rb +35 -0
- data/lib/ddex/ern/v41/cue_use_type.rb +35 -0
- data/lib/ddex/ern/v41/cue_visual_perception_type.rb +35 -0
- data/lib/ddex/ern/v41/cue_vocal_type.rb +35 -0
- data/lib/ddex/ern/v41/current_territory_code.rb +32 -0
- data/lib/ddex/ern/v41/deal.rb +36 -0
- data/lib/ddex/ern/v41/deal_list.rb +30 -0
- data/lib/ddex/ern/v41/deal_resource_reference_list.rb +29 -0
- data/lib/ddex/ern/v41/deal_technical_resource_details_reference_list.rb +29 -0
- data/lib/ddex/ern/v41/deal_terms.rb +66 -0
- data/lib/ddex/ern/v41/deal_terms_technical_instantiation.rb +32 -0
- data/lib/ddex/ern/v41/deity.rb +35 -0
- data/lib/ddex/ern/v41/delegated_usage_rights.rb +34 -0
- data/lib/ddex/ern/v41/description_with_territory.rb +38 -0
- data/lib/ddex/ern/v41/detailed_cue.rb +59 -0
- data/lib/ddex/ern/v41/detailed_cue_sheet.rb +35 -0
- data/lib/ddex/ern/v41/detailed_cue_sheet_list.rb +30 -0
- data/lib/ddex/ern/v41/detailed_hash_sum.rb +34 -0
- data/lib/ddex/ern/v41/detailed_party_id.rb +35 -0
- data/lib/ddex/ern/v41/detailed_resource_contributor.rb +44 -0
- data/lib/ddex/ern/v41/discoverable_use_type.rb +38 -0
- data/lib/ddex/ern/v41/display_artist.rb +39 -0
- data/lib/ddex/ern/v41/display_artist_name_with_default.rb +38 -0
- data/lib/ddex/ern/v41/display_artist_role.rb +35 -0
- data/lib/ddex/ern/v41/display_credit_party.rb +13 -0
- data/lib/ddex/ern/v41/display_credits.rb +29 -0
- data/lib/ddex/ern/v41/display_sub_title.rb +39 -0
- data/lib/ddex/ern/v41/display_title.rb +40 -0
- data/lib/ddex/ern/v41/display_title_text.rb +38 -0
- data/lib/ddex/ern/v41/distribution_channel_page.rb +34 -0
- data/lib/ddex/ern/v41/dsp.rb +35 -0
- data/lib/ddex/ern/v41/event_date.rb +47 -0
- data/lib/ddex/ern/v41/event_date_time.rb +47 -0
- data/lib/ddex/ern/v41/event_date_time_without_flags.rb +41 -0
- data/lib/ddex/ern/v41/event_date_with_default.rb +38 -0
- data/lib/ddex/ern/v41/event_date_without_flags.rb +41 -0
- data/lib/ddex/ern/v41/extent.rb +32 -0
- data/lib/ddex/ern/v41/external_resource_link.rb +35 -0
- data/lib/ddex/ern/v41/externally_linked_resource_type.rb +35 -0
- data/lib/ddex/ern/v41/file.rb +32 -0
- data/lib/ddex/ern/v41/fingerprint.rb +36 -0
- data/lib/ddex/ern/v41/fingerprint_algorithm_type.rb +35 -0
- data/lib/ddex/ern/v41/first_publication_date.rb +35 -0
- data/lib/ddex/ern/v41/frame_rate.rb +32 -0
- data/lib/ddex/ern/v41/fulfillment_date_with_territory.rb +36 -0
- data/lib/ddex/ern/v41/genre_with_territory.rb +39 -0
- data/lib/ddex/ern/v41/hash_sum_algorithm_type.rb +35 -0
- data/lib/ddex/ern/v41/image.rb +80 -0
- data/lib/ddex/ern/v41/image_codec_type.rb +38 -0
- data/lib/ddex/ern/v41/image_type.rb +35 -0
- data/lib/ddex/ern/v41/instrument_type.rb +35 -0
- data/lib/ddex/ern/v41/keywords_with_territory.rb +38 -0
- data/lib/ddex/ern/v41/linked_release_resource_reference.rb +41 -0
- data/lib/ddex/ern/v41/marketing_comment.rb +38 -0
- data/lib/ddex/ern/v41/message_audit_trail.rb +30 -0
- data/lib/ddex/ern/v41/message_audit_trail_event.rb +31 -0
- data/lib/ddex/ern/v41/message_header.rb +39 -0
- data/lib/ddex/ern/v41/messaging_party_without_code.rb +32 -0
- data/lib/ddex/ern/v41/musical_work_id.rb +36 -0
- data/lib/ddex/ern/v41/name.rb +32 -0
- data/lib/ddex/ern/v41/name_used_in_display_credit.rb +14 -0
- data/lib/ddex/ern/v41/new_release_message.rb +54 -0
- data/lib/ddex/ern/v41/operating_system_type.rb +38 -0
- data/lib/ddex/ern/v41/p_line.rb +37 -0
- data/lib/ddex/ern/v41/p_line_with_default.rb +40 -0
- data/lib/ddex/ern/v41/parental_warning_type_with_territory.rb +41 -0
- data/lib/ddex/ern/v41/party.rb +38 -0
- data/lib/ddex/ern/v41/party_list.rb +30 -0
- data/lib/ddex/ern/v41/party_name.rb +39 -0
- data/lib/ddex/ern/v41/party_name_with_territory.rb +51 -0
- data/lib/ddex/ern/v41/party_name_without_code.rb +35 -0
- data/lib/ddex/ern/v41/party_relationship_type.rb +35 -0
- data/lib/ddex/ern/v41/percentage.rb +32 -0
- data/lib/ddex/ern/v41/period.rb +34 -0
- data/lib/ddex/ern/v41/period_without_flags.rb +34 -0
- data/lib/ddex/ern/v41/physical_returns.rb +30 -0
- data/lib/ddex/ern/v41/prefix.rb +32 -0
- data/lib/ddex/ern/v41/preview_details.rb +31 -0
- data/lib/ddex/ern/v41/price.rb +32 -0
- data/lib/ddex/ern/v41/price_information_with_type.rb +37 -0
- data/lib/ddex/ern/v41/price_type.rb +32 -0
- data/lib/ddex/ern/v41/promotional_code.rb +32 -0
- data/lib/ddex/ern/v41/proprietary_id.rb +32 -0
- data/lib/ddex/ern/v41/purge_release_message.rb +36 -0
- data/lib/ddex/ern/v41/purged_release.rb +34 -0
- data/lib/ddex/ern/v41/purpose.rb +35 -0
- data/lib/ddex/ern/v41/raga.rb +35 -0
- data/lib/ddex/ern/v41/rating_agency.rb +35 -0
- data/lib/ddex/ern/v41/reason.rb +32 -0
- data/lib/ddex/ern/v41/related_party.rb +31 -0
- data/lib/ddex/ern/v41/related_release.rb +45 -0
- data/lib/ddex/ern/v41/related_resource.rb +34 -0
- data/lib/ddex/ern/v41/release.rb +89 -0
- data/lib/ddex/ern/v41/release_deal.rb +31 -0
- data/lib/ddex/ern/v41/release_id.rb +35 -0
- data/lib/ddex/ern/v41/release_label_reference.rb +47 -0
- data/lib/ddex/ern/v41/release_list.rb +32 -0
- data/lib/ddex/ern/v41/release_relationship_type.rb +35 -0
- data/lib/ddex/ern/v41/release_type_for_release_notification.rb +35 -0
- data/lib/ddex/ern/v41/resource_contained_resource_reference.rb +33 -0
- data/lib/ddex/ern/v41/resource_contained_resource_reference_list.rb +30 -0
- data/lib/ddex/ern/v41/resource_group.rb +51 -0
- data/lib/ddex/ern/v41/resource_group_content_item.rb +37 -0
- data/lib/ddex/ern/v41/resource_id.rb +42 -0
- data/lib/ddex/ern/v41/resource_list.rb +40 -0
- data/lib/ddex/ern/v41/resource_proprietary_id.rb +33 -0
- data/lib/ddex/ern/v41/resource_rights_controller.rb +42 -0
- data/lib/ddex/ern/v41/resource_sub_group.rb +54 -0
- data/lib/ddex/ern/v41/rights_claim_policy.rb +31 -0
- data/lib/ddex/ern/v41/sampling_rate.rb +32 -0
- data/lib/ddex/ern/v41/sheet_music.rb +79 -0
- data/lib/ddex/ern/v41/sheet_music_codec_type.rb +38 -0
- data/lib/ddex/ern/v41/sheet_music_id.rb +34 -0
- data/lib/ddex/ern/v41/sheet_music_type.rb +35 -0
- data/lib/ddex/ern/v41/simple_rights_type.rb +35 -0
- data/lib/ddex/ern/v41/software.rb +84 -0
- data/lib/ddex/ern/v41/software_type.rb +35 -0
- data/lib/ddex/ern/v41/sound_recording.rb +96 -0
- data/lib/ddex/ern/v41/sound_recording_id.rb +36 -0
- data/lib/ddex/ern/v41/sound_recording_preview_details.rb +34 -0
- data/lib/ddex/ern/v41/sound_recording_type.rb +35 -0
- data/lib/ddex/ern/v41/supplemental_document_list.rb +30 -0
- data/lib/ddex/ern/v41/synopsis_with_territory.rb +41 -0
- data/lib/ddex/ern/v41/tala.rb +35 -0
- data/lib/ddex/ern/v41/technical_image_details.rb +55 -0
- data/lib/ddex/ern/v41/technical_sheet_music_details.rb +48 -0
- data/lib/ddex/ern/v41/technical_software_details.rb +48 -0
- data/lib/ddex/ern/v41/technical_sound_recording_details.rb +57 -0
- data/lib/ddex/ern/v41/technical_text_details.rb +48 -0
- data/lib/ddex/ern/v41/technical_video_details.rb +72 -0
- data/lib/ddex/ern/v41/text.rb +82 -0
- data/lib/ddex/ern/v41/text_codec_type.rb +38 -0
- data/lib/ddex/ern/v41/text_id.rb +36 -0
- data/lib/ddex/ern/v41/text_type.rb +35 -0
- data/lib/ddex/ern/v41/timing.rb +30 -0
- data/lib/ddex/ern/v41/title.rb +36 -0
- data/lib/ddex/ern/v41/title_display_information.rb +38 -0
- data/lib/ddex/ern/v41/track_release.rb +49 -0
- data/lib/ddex/ern/v41/use_type.rb +35 -0
- data/lib/ddex/ern/v41/validity_period.rb +31 -0
- data/lib/ddex/ern/v41/version_type.rb +35 -0
- data/lib/ddex/ern/v41/video.rb +102 -0
- data/lib/ddex/ern/v41/video_codec_type.rb +38 -0
- data/lib/ddex/ern/v41/video_id.rb +39 -0
- data/lib/ddex/ern/v41/video_type.rb +35 -0
- data/lib/ddex/ern/v41/work_rights_controller.rb +37 -0
- data/lib/ddex/version.rb +3 -1
- data/spec/ern_spec.rb +7 -1
- data/spec/fixtures/ern/41/instance1.xml +1688 -0
- metadata +186 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102aa60db3589a4f1306181f86b266ff6e85943e
|
4
|
+
data.tar.gz: 7e960f3dabbaa997c7b87cf8233cff520e215536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f9a1c4b9a218be6488744766113ff4b554d9f9d1a451c1df1fddc41d7816d7b15852d28931141497ec8e05ee8f6290fc1015f634dd0b8734704662558dbfd7c
|
7
|
+
data.tar.gz: 03d5cf0e79d2ea126f3bde773f18395156275f8a9269f242484efe00fd2648951bec453847fc9bc0bab3fc922cee208607c3fa66f686392982024d30c71a3e13
|
data/README.rdoc
CHANGED
@@ -114,10 +114,21 @@ element of the same name (<code>PriceInformation/PriceType</code>).
|
|
114
114
|
|
115
115
|
=== Specification Version Detection
|
116
116
|
|
117
|
-
|
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
|
-
|
120
|
-
|
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 (
|
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
|
|
data/lib/ddex/element.rb
CHANGED
data/lib/ddex/ern.rb
CHANGED
@@ -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
|
-
|
107
|
-
|
108
|
-
|
113
|
+
class << self
|
114
|
+
def supported_versions
|
115
|
+
config.values.map { |cfg| cfg[:version].dup }.sort
|
116
|
+
end
|
109
117
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
136
|
-
|
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
|
-
|
139
|
-
raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
|
149
|
+
xmlopts = options.reject { |k, _| k == :schema }
|
140
150
|
|
141
|
-
|
151
|
+
node = object.to_xml
|
152
|
+
return node.to_xml(xmlopts) unless object.class.name.demodulize == ROOT_ELEMENT
|
142
153
|
|
143
|
-
|
144
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
-
|
172
|
-
|
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
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
-
|
187
|
-
|
191
|
+
return unless version
|
192
|
+
version[:message_schema_version_id]
|
193
|
+
end
|
188
194
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
data/lib/ddex/ern/v41.rb
ADDED
@@ -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
|