ddex 0.0.1 → 0.0.2

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: c76db225ee4e588bb9465ab9801b6ee5bbe6b4dd
4
- data.tar.gz: c80d0d61497678b6973aa2f824cb7d56565ab91f
3
+ metadata.gz: f1e503ee8c9b64cdc868dfe83bba27d50c612e4d
4
+ data.tar.gz: 6c3bb7e287fdaf144f9d96f474e4698bee6af06d
5
5
  SHA512:
6
- metadata.gz: d3ca2feb13983f100d20677cd7de6953dca9e03548d9ff6fa37a8d70f45e36fda273ef1c77fd735cb40fe3a2354137d51941a95d093c53f9449d0512c1a414df
7
- data.tar.gz: 56fa38d1de3bca0de8fe49a93eb5c38d68df83c5b3bf17b9e56d2b791eff094de3936c0125dea08e02153e3c486f516f224f3c9d89c7ae99170c73592d5e1348
6
+ metadata.gz: 58a9d8c2f79818788ede896a42b56f1e82ec2b8f5d4e865fbc1d1ab67f4428a1d34d10de48d390de5d10157f410350ea4d25bb9597f864bcdd6bf4fe229fd550
7
+ data.tar.gz: a3c81b9921a50871a6a281c676e5cb0b92467b4d954c646e84a86201e3278ce042e246c708a21f6f9fbde404ca4e073dcd520b14eea82b426b4c90c60d316497
@@ -121,7 +121,7 @@ The specification version is determined by the <code>MessageSchemaVersionId</cod
121
121
 
122
122
  By default the <code>MessageSchemaVersionId</code> is assumed to be in <code>SPEC/VERSION</code> format (any leading, trailing, or duplicate slashes will be stripped),
123
123
  as this seems to be the convention used by most instance docs -though the DDEX specifications
124
- {are not strict about this}[http://www.ddex.net/content/format-messageschemaversionid]. If you're dealing with <code>MessageSchemaVersionId</code>s
124
+ {are not strict about this}[http://www.ddex.net/format-messageschemaversionid]. If you're dealing with <code>MessageSchemaVersionId</code>s
125
125
  that vary from this format, and explicitly setting the version is not practical, you can set the global default(s):
126
126
 
127
127
  DDEX::ERN.config["V35"][:message_schema_version_id] = "ern tray_fever!"
@@ -137,6 +137,37 @@ be modified to accommodate something more than <code>SPEC/VERSION</code> out of
137
137
 
138
138
  Not yet!
139
139
 
140
+ === DDEX Parsing Service (Rack Endpoint)
141
+
142
+ If you want to parse DDEX metadata but don't want to use Ruby to process the results you can setup a parsing service
143
+ using <code>Rack::DDEX</code>. <code>Rack::DDEX</code> is a {Rack endpoint}[http://rack.github.io] that parses a DDEX file
144
+ and returns JSON.
145
+
146
+ For example, from the repository's root:
147
+
148
+ ~/code/ruby/ddex >cat etc/config.ru
149
+ require "rack/ddex"
150
+
151
+ run Rack::DDEX.new
152
+
153
+ ~/code/ruby/ddex >rackup -I lib etc/config.ru # Note that -D has problems with autoloading
154
+ [2014-12-15 20:35:40] INFO WEBrick 1.3.1
155
+ [2014-12-15 20:35:40] INFO ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0]
156
+ [2014-12-15 20:35:40] INFO WEBrick::HTTPServer#start: pid=76385 port=9292
157
+
158
+ Then, from another terminal
159
+
160
+ ~/code/ruby/ddex >curl -d @spec/fixtures/ern/36/instance1.xml http://localhost:9292
161
+ {"message_header":{"message_thread_id":"Bu._UcZLsNbTVitjYnci","message_id":"DbVn-iuUB-SiHl05B2IqW3_","message_file_name":"wz9RHX_Eu1d"
162
+ ...
163
+
164
+ ~/code/ruby/ddex >curl http://localhost:9292 # HTTP 400
165
+ {"error":"XML parsing error: Start tag expected, '<' not found"}
166
+
167
+ === Contributing
168
+
169
+ See CONTRIBUTING.md
170
+
140
171
  === More Info
141
172
 
142
173
  * {Source code}[https://github.com/sshaw/ddex]
@@ -156,7 +187,7 @@ Not yet!
156
187
  xml_accessor :x, :as => AnotherClass
157
188
 
158
189
  # Then
159
- x = SomeClass.new(:x => "123")
190
+ x = SomeClass.new(:x => "123")
160
191
  x.to_xml # undefined method `to_xml' for "123":String
161
192
 
162
193
  Raised here: https://github.com/Empact/roxml/blob/v2.5.1/lib/roxml/xml/references.rb#L262
@@ -146,7 +146,9 @@ module DDEX
146
146
 
147
147
  # Some normalization
148
148
  v = version.strip.gsub(%r{//+}, "/").gsub(%r{\A/|/\Z}, "")
149
- klass, _ = config.find { |name, cfg| cfg[:message_schema_version_id] == v }
149
+ klass, _ = config.find do |name, cfg|
150
+ cfg[:message_schema_version_id] == v || cfg[:version] == v
151
+ end
150
152
  raise_unknown_version(version) unless klass
151
153
 
152
154
  # >= 2.0 allows for one call
@@ -1,3 +1,3 @@
1
1
  module DDEX
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,23 @@
1
+ require "rack"
2
+ require "json"
3
+ require "ddex"
4
+
5
+ module Rack
6
+ class DDEX
7
+ HEADERS = {"Content-Type" => "application/json"}.freeze
8
+
9
+ def call(env)
10
+ begin
11
+ obj = ::DDEX.read(env["rack.input"])
12
+ json = JSON.dump(obj.to_hash)
13
+
14
+ [200, HEADERS.merge("Content-Length" => Rack::Utils.bytesize(json)), [json]]
15
+ rescue => e
16
+ code = e.is_a?(::DDEX::DDEXError) ? 400 : 500
17
+ json = JSON.dump(:error => e.message)
18
+
19
+ [code, HEADERS, [json]]
20
+ end
21
+ end
22
+ end
23
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -83,7 +83,7 @@ describe DDEX::ERN do
83
83
 
84
84
  describe ".read" do
85
85
  describe "MessageSchemaVersionId detection" do
86
- %w[/ern/35 ern/35/ //ern/35//].each do |v|
86
+ %w[/ern/35 ern/35/ //ern/35// 3.5].each do |v|
87
87
  it "parses #{v} as ERN 3.5" do
88
88
  doc = load_fixture("ern/35/instance1")
89
89
  doc.root["MessageSchemaVersionId"] = v
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -87,7 +87,11 @@ extensions: []
87
87
  extra_rdoc_files:
88
88
  - README.rdoc
89
89
  files:
90
+ - README.rdoc
91
+ - lib/ddex.rb
90
92
  - lib/ddex/element.rb
93
+ - lib/ddex/ern.rb
94
+ - lib/ddex/ern/v33.rb
91
95
  - lib/ddex/ern/v33/catalog_item.rb
92
96
  - lib/ddex/ern/v33/catalog_list_message.rb
93
97
  - lib/ddex/ern/v33/catalog_release_reference_list.rb
@@ -145,7 +149,7 @@ files:
145
149
  - lib/ddex/ern/v33/user_defined_resource_details_by_territory.rb
146
150
  - lib/ddex/ern/v33/video.rb
147
151
  - lib/ddex/ern/v33/video_details_by_territory.rb
148
- - lib/ddex/ern/v33.rb
152
+ - lib/ddex/ern/v34.rb
149
153
  - lib/ddex/ern/v34/catalog_item.rb
150
154
  - lib/ddex/ern/v34/catalog_list_message.rb
151
155
  - lib/ddex/ern/v34/catalog_release_reference_list.rb
@@ -204,7 +208,7 @@ files:
204
208
  - lib/ddex/ern/v34/video.rb
205
209
  - lib/ddex/ern/v34/video_details_by_territory.rb
206
210
  - lib/ddex/ern/v34/web_policy.rb
207
- - lib/ddex/ern/v34.rb
211
+ - lib/ddex/ern/v341.rb
208
212
  - lib/ddex/ern/v341/catalog_item.rb
209
213
  - lib/ddex/ern/v341/catalog_list_message.rb
210
214
  - lib/ddex/ern/v341/catalog_release_reference_list.rb
@@ -263,7 +267,7 @@ files:
263
267
  - lib/ddex/ern/v341/video.rb
264
268
  - lib/ddex/ern/v341/video_details_by_territory.rb
265
269
  - lib/ddex/ern/v341/web_policy.rb
266
- - lib/ddex/ern/v341.rb
270
+ - lib/ddex/ern/v35.rb
267
271
  - lib/ddex/ern/v35/catalog_item.rb
268
272
  - lib/ddex/ern/v35/catalog_list_message.rb
269
273
  - lib/ddex/ern/v35/catalog_release_reference_list.rb
@@ -324,7 +328,7 @@ files:
324
328
  - lib/ddex/ern/v35/video.rb
325
329
  - lib/ddex/ern/v35/video_details_by_territory.rb
326
330
  - lib/ddex/ern/v35/web_policy.rb
327
- - lib/ddex/ern/v35.rb
331
+ - lib/ddex/ern/v351.rb
328
332
  - lib/ddex/ern/v351/catalog_item.rb
329
333
  - lib/ddex/ern/v351/catalog_list_message.rb
330
334
  - lib/ddex/ern/v351/catalog_release_reference_list.rb
@@ -385,7 +389,7 @@ files:
385
389
  - lib/ddex/ern/v351/video.rb
386
390
  - lib/ddex/ern/v351/video_details_by_territory.rb
387
391
  - lib/ddex/ern/v351/web_policy.rb
388
- - lib/ddex/ern/v351.rb
392
+ - lib/ddex/ern/v36.rb
389
393
  - lib/ddex/ern/v36/administrating_record_company.rb
390
394
  - lib/ddex/ern/v36/artist.rb
391
395
  - lib/ddex/ern/v36/artist_delegated_usage_rights.rb
@@ -593,7 +597,7 @@ files:
593
597
  - lib/ddex/ern/v36/web_page.rb
594
598
  - lib/ddex/ern/v36/web_policy.rb
595
599
  - lib/ddex/ern/v36/work_list.rb
596
- - lib/ddex/ern/v36.rb
600
+ - lib/ddex/ern/v37.rb
597
601
  - lib/ddex/ern/v37/administrating_record_company.rb
598
602
  - lib/ddex/ern/v37/all_territory_code.rb
599
603
  - lib/ddex/ern/v37/artist.rb
@@ -803,8 +807,6 @@ files:
803
807
  - lib/ddex/ern/v37/web_page.rb
804
808
  - lib/ddex/ern/v37/web_policy.rb
805
809
  - lib/ddex/ern/v37/work_list.rb
806
- - lib/ddex/ern/v37.rb
807
- - lib/ddex/ern.rb
808
810
  - lib/ddex/v20110630/ddexc/additional_information.rb
809
811
  - lib/ddex/v20110630/ddexc/administrating_record_company.rb
810
812
  - lib/ddex/v20110630/ddexc/amount_by_use_and_distribution_channel_type.rb
@@ -1849,7 +1851,7 @@ files:
1849
1851
  - lib/ddex/v20121219/ddexc/work_list.rb
1850
1852
  - lib/ddex/v20121219/ddexc/ws_message_status.rb
1851
1853
  - lib/ddex/version.rb
1852
- - lib/ddex.rb
1854
+ - lib/rack/ddex.rb
1853
1855
  - spec/element_spec.rb
1854
1856
  - spec/ern/341_spec.rb~
1855
1857
  - spec/ern/34_spec.rb~
@@ -1871,7 +1873,6 @@ files:
1871
1873
  - spec/fixtures/ern36.xml~
1872
1874
  - spec/spec_helper.rb
1873
1875
  - spec/support/ddex_element.rb
1874
- - README.rdoc
1875
1876
  homepage: http://github.com/sshaw/ddex
1876
1877
  licenses:
1877
1878
  - MIT
@@ -1892,7 +1893,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1892
1893
  version: '0'
1893
1894
  requirements: []
1894
1895
  rubyforge_project:
1895
- rubygems_version: 2.1.11
1896
+ rubygems_version: 2.4.3
1896
1897
  signing_key:
1897
1898
  specification_version: 4
1898
1899
  summary: DDEX metadata serialization