im_onix 1.0.2 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE.md +7 -0
  6. data/README.md +3 -3
  7. data/Rakefile +10 -0
  8. data/bin/html_codelist_to_yml.rb +14 -15
  9. data/bin/onix_bench.rb +1 -0
  10. data/bin/onix_pp.rb +4 -8
  11. data/bin/onix_serialize.rb +27 -0
  12. data/doc-src/handlers.rb +154 -0
  13. data/im_onix.gemspec +32 -0
  14. data/lib/im_onix.rb +0 -1
  15. data/lib/onix/addressee.rb +10 -0
  16. data/lib/onix/code.rb +108 -282
  17. data/lib/onix/collateral_detail.rb +24 -17
  18. data/lib/onix/collection.rb +38 -0
  19. data/lib/onix/collection_sequence.rb +7 -0
  20. data/lib/onix/contributor.rb +40 -39
  21. data/lib/onix/date.rb +73 -109
  22. data/lib/onix/descriptive_detail.rb +90 -417
  23. data/lib/onix/discount_coded.rb +3 -16
  24. data/lib/onix/entity.rb +28 -62
  25. data/lib/onix/epub_usage_constraint.rb +7 -0
  26. data/lib/onix/epub_usage_limit.rb +6 -0
  27. data/lib/onix/extent.rb +39 -0
  28. data/lib/onix/helper.rb +25 -25
  29. data/lib/onix/identifier.rb +13 -54
  30. data/lib/onix/language.rb +8 -0
  31. data/lib/onix/market.rb +5 -0
  32. data/lib/onix/market_publishing_detail.rb +20 -0
  33. data/lib/onix/onix21.rb +76 -139
  34. data/lib/onix/onix_message.rb +87 -100
  35. data/lib/onix/price.rb +19 -39
  36. data/lib/onix/product.rb +141 -637
  37. data/lib/onix/product_form_feature.rb +7 -0
  38. data/lib/onix/product_part.rb +89 -0
  39. data/lib/onix/product_supplies_extractor.rb +275 -0
  40. data/lib/onix/product_supply.rb +17 -58
  41. data/lib/onix/publishing_detail.rb +16 -32
  42. data/lib/onix/related_material.rb +4 -3
  43. data/lib/onix/related_product.rb +9 -29
  44. data/lib/onix/related_work.rb +3 -17
  45. data/lib/onix/sales_outlet.rb +2 -10
  46. data/lib/onix/sales_restriction.rb +8 -21
  47. data/lib/onix/sales_rights.rb +1 -5
  48. data/lib/onix/sender.rb +12 -0
  49. data/lib/onix/serializer.rb +156 -0
  50. data/lib/onix/subject.rb +9 -30
  51. data/lib/onix/subset.rb +88 -78
  52. data/lib/onix/supply_detail.rb +42 -0
  53. data/lib/onix/supporting_resource.rb +29 -86
  54. data/lib/onix/tax.rb +9 -18
  55. data/lib/onix/territory.rb +23 -17
  56. data/lib/onix/title_detail.rb +22 -0
  57. data/lib/onix/title_element.rb +32 -0
  58. data/lib/onix/website.rb +3 -16
  59. metadata +53 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eec0e1b2732af7b05abadeadeafe1c4e9acf53166b2256cbe39476461e5f99a
4
- data.tar.gz: 166d34732659a91b6494d8dd1507100d861bebd7a8c258263e2d02204befdffc
3
+ metadata.gz: 291ef6c16051d0bf41321eab30c7b1217dd472242f9251d041c06fd48791726a
4
+ data.tar.gz: 749fb1ff1be0edd0d1711e8663f9d4a7c1091ba965da558a0b924a4937deefae
5
5
  SHA512:
6
- metadata.gz: e42f395bf965520563bf4697abde739bbcbfda111f8ec8c1b3a9bc5f9612bba6773a5c245c15fa442fcda75fc4a0283328dab228f387f9222be8892432527590
7
- data.tar.gz: 7f941cad2dfdc9946d9c4a773d543003131178394e636fe5d4de12c408ef31f6f22dc52d802840e70d0dcd57bac73f9bc3c2aa0a83fdc6a1c2dd7bfedc6b7fcd
6
+ metadata.gz: 0eb7dac0735de679d3be0b217b0c59c86304a759055d93d344c01291e31a745ad786eaa557f404748b7c3d99f5b7f246d5adb921843a47e4a89f2fe9f389af65
7
+ data.tar.gz: 01633b2daeb2a326869e47c0a512a160119e7c62055958a69dfb915b2fc3ff790114176a15c770bed389c6694c36eb7e7a843647c905fe6c094ccb5e806b648a
@@ -0,0 +1,4 @@
1
+ coverage/
2
+ Gemfile.lock
3
+ .idea/
4
+ *.gem
@@ -0,0 +1 @@
1
+ --load ./doc-src/handlers.rb
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'nokogiri'
4
+
5
+ group :development do
6
+ gem "shoulda", ">= 0"
7
+ gem "bundler"
8
+ end
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2013-2019 immatériel.fr
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ### Low level API
4
4
  Whole structure is accessible through ONIX::ONIXMessage object :
5
5
  ```ruby
6
- message=ONIX::ONIXMessage.new
6
+ message = ONIX::ONIXMessage.new
7
7
  message.parse("onix_file.xml")
8
8
  # first product
9
9
  pp message.products.first
@@ -14,8 +14,8 @@ pp message.products.first.identifiers.first
14
14
  Ruby elements variables are underscored, lowercase of ONIX tags (Product -> product, DescriptiveDetail -> descriptive_detail) and pluralized in case of array (ProductSupply -> product_supplies).
15
15
 
16
16
  ### High level API
17
- High level methods give abstracted and simplified access to the most important data.
18
- See http://nu.immateriel.fr/im_onix/doc/ONIX/Product.html for high level API rdoc and onix_pp.rb, onix3_to_onix2.rb and onix3_to_onix3.rb sample in bin/
17
+ High level methods give abstracted and simplified access to the most important data.
18
+ See https://www.rubydoc.info/gems/im_onix/ONIX/Product for high level API rdoc and onix_pp.rb, onix3_to_onix2.rb and onix3_to_onix3.rb sample in bin/
19
19
 
20
20
  Usage :
21
21
  ```shell
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/test_*.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -10,16 +10,15 @@ require 'yaml'
10
10
  class HTMLCodelist
11
11
 
12
12
  private
13
+
13
14
  def self.parse_codelist(codelist)
14
- h={}
15
- # puts "PARSE CODELIST #{codelist}"
16
- html=Nokogiri::HTML.parse(File.open(codelist))
15
+ h = {}
16
+ html = Nokogiri::HTML.parse(File.open(codelist))
17
17
  html.search("//tr").each do |tr|
18
- # pp tr
19
- td_code=tr.at("./td[1]")
20
- td_human=tr.at("./td[2]")
18
+ td_code = tr.at("./td[1]")
19
+ td_human = tr.at("./td[2]")
21
20
  if td_code and td_human
22
- h[td_code.text.strip]=self.rename(td_human.text.strip)
21
+ h[td_code.text.strip] = self.rename(td_human.text.strip)
23
22
  end
24
23
  end
25
24
  h
@@ -27,20 +26,20 @@ class HTMLCodelist
27
26
 
28
27
  # from rails
29
28
  def self.rename(term)
30
- term.gsub(/\(|\)|\,|\-|’|\/|“|”|‘|\.|\:|–|\||\+/,"").gsub(/\;/," Or ").gsub(/\s+/," ").split(" ").map{|t| t.capitalize}.join("")
29
+ term.gsub(/\(|\)|\,|\-|’|\/|“|”|‘|\.|\:|–|\||\+/, "").gsub(/\;/, " Or ").gsub(/\s+/, " ").split(" ").map { |t| t.capitalize }.join("")
31
30
  end
32
-
33
31
  end
34
32
 
35
- files=`ls #{ARGV[1]}/*.htm`.split(/\n/)
33
+ files = `ls #{ARGV[1]}/*.htm`.split(/\n/)
36
34
 
37
- h={}
35
+ h = {}
38
36
 
39
37
  files.sort.each do |file|
40
- codelist=file.gsub(/.*onix\-codelist\-(.*)\.htm/,'\1').to_i
41
- h=HTMLCodelist.parse_codelist(file)
42
-
43
- File.open("data/codelists/codelist-#{codelist}.yml",'w') do |fw| fw.write({:codelist=>h}.to_yaml) end
38
+ codelist = file.gsub(/.*onix\-codelist\-(.*)\.htm/, '\1').to_i
39
+ h = HTMLCodelist.parse_codelist(file)
44
40
 
41
+ File.open("data/codelists/codelist-#{codelist}.yml", 'w') do |fw|
42
+ fw.write({:codelist => h}.to_yaml)
43
+ end
45
44
  end
46
45
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'benchmark'
2
3
  require 'im_onix'
3
4
 
4
5
  filename=ARGV[0]
@@ -22,7 +22,6 @@ if filename
22
22
  end
23
23
 
24
24
  msg.products.each do |product|
25
- # pp product
26
25
  puts "---"
27
26
  puts " EAN: #{product.ean}"
28
27
  puts " Title: #{product.title}"
@@ -75,7 +74,6 @@ if filename
75
74
  puts " Publisher: #{product.publisher_name}"
76
75
  end
77
76
 
78
- # puts " Publisher: #{product.publisher_name}"
79
77
  if product.imprint_name
80
78
  puts " Imprint: #{product.imprint_name}"
81
79
  end
@@ -115,8 +113,8 @@ if filename
115
113
  if part.file_description
116
114
  puts " Description: #{part.raw_file_description}"
117
115
  end
118
- if part.protection_type
119
- puts " Protection: #{part.protection_type}"
116
+ product.protections.each do |protection|
117
+ puts " Protection: #{protection}"
120
118
  end
121
119
  if part.filesize
122
120
  puts " Filesize: #{part.filesize} bytes"
@@ -129,8 +127,8 @@ if filename
129
127
  if product.file_description
130
128
  puts " Description: #{product.raw_file_description}"
131
129
  end
132
- if product.protection_type
133
- puts " Protection: #{product.protection_type}"
130
+ product.protections.each do |protection|
131
+ puts " Protection: #{protection}"
134
132
  end
135
133
  if product.filesize
136
134
  puts " Filesize: #{product.filesize} bytes"
@@ -142,8 +140,6 @@ if filename
142
140
  end
143
141
  end
144
142
 
145
- # pp product.supplies
146
-
147
143
  current_price=product.current_price_amount_for('EUR', 'FR')
148
144
  if current_price
149
145
  puts " Current EUR price for FR: #{current_price/100.0} EUR"
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'im_onix'
3
+ require 'onix/serializer'
4
+ filename=ARGV[0]
5
+ version=ARGV[1]
6
+
7
+ if filename
8
+ msg=ONIX::ONIXMessage.new
9
+ msg.parse(filename, nil, version)
10
+ if true
11
+ msg.products.each do |product|
12
+ ONIX::Serializer::Dump::Subset.serialize(STDOUT, "Product", product)
13
+ end
14
+ end
15
+
16
+ if false
17
+ builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
18
+ xml.ONIXMessage {
19
+ msg.products.each do |product|
20
+ ONIX::Serializer::Default::Subset.serialize(xml, "Product", product)
21
+ end
22
+ }
23
+ end
24
+ puts builder.to_xml
25
+ end
26
+
27
+ end
@@ -0,0 +1,154 @@
1
+ class DSLHelpers
2
+ def self.inflectors
3
+ [['ox', 'oxes'],
4
+ ['us', 'uses'],
5
+ ['', 's'],
6
+ ['ero', 'eroes'],
7
+ ['rf', 'rves'],
8
+ ['af', 'aves'],
9
+ ['ero', 'eroes'],
10
+ ['man', 'men'],
11
+ ['ch', 'ches'],
12
+ ['sh', 'shes'],
13
+ ['ss', 'sses'],
14
+ ['ta', 'tum'],
15
+ ['ia', 'ium'],
16
+ ['ra', 'rum'],
17
+ ['ay', 'ays'],
18
+ ['ey', 'eys'],
19
+ ['oy', 'oys'],
20
+ ['uy', 'uys'],
21
+ ['y', 'ies'],
22
+ ['x', 'xes'],
23
+ ['lf', 'lves'],
24
+ ['ffe', 'ffes'],
25
+ ['afe', 'aves'],
26
+ ['ouse', 'ouses']]
27
+ end
28
+
29
+ def self.pluralize(str)
30
+ rex = /(#{self.inflectors.map { |si, pl| si }.join('|')})$/i
31
+ hash = Hash[*self.inflectors.flatten]
32
+ str.sub(rex) { |m| hash[m] }
33
+ end
34
+
35
+ def self.underscore(str)
36
+ word = str.to_s.dup
37
+ word.gsub!('::', '/')
38
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
39
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
40
+ word.tr!("-", "_")
41
+ word.downcase!
42
+ word
43
+ end
44
+ end
45
+
46
+ class ElementDSLAttributeHandler < YARD::Handlers::Ruby::Base
47
+ handles method_call(:element)
48
+ namespace_only
49
+
50
+ process do
51
+ name = statement.parameters[0].jump(:tstring_content, :ident).source
52
+ type = statement.parameters[1].jump(:tstring_content, :ident).source
53
+ attrs = statement.parameters[2] ? statement.parameters[2].jump(:hash).source : "{}"
54
+
55
+ unless attrs.start_with?("{")
56
+ attrs = "{#{attrs}}"
57
+ end
58
+
59
+ attrs = eval(attrs)
60
+
61
+ returns = nil
62
+ case type
63
+ when "subset"
64
+ returns = YARD::DocstringParser.new.parse("@return [#{name}]").to_docstring.tags.first
65
+ when "text"
66
+ returns = YARD::DocstringParser.new.parse("@return [String]").to_docstring.tags.first
67
+ when "integer"
68
+ returns = YARD::DocstringParser.new.parse("@return [Integer]").to_docstring.tags.first
69
+ when "float"
70
+ returns = YARD::DocstringParser.new.parse("@return [Float]").to_docstring.tags.first
71
+ when "bool"
72
+ returns = YARD::DocstringParser.new.parse("@return [Boolean]").to_docstring.tags.first
73
+ end
74
+
75
+ object = YARD::CodeObjects::MethodObject.new(namespace, "#{DSLHelpers.underscore(name)}", :instance)
76
+ object.dynamic = true
77
+ object.add_tag(returns) if returns
78
+ object[:group] = 'Low level'
79
+ register(object)
80
+
81
+ if attrs[:shortcut]
82
+ object = YARD::CodeObjects::MethodObject.new(namespace, attrs[:shortcut].to_s, :instance)
83
+ object.dynamic = true
84
+ object[:docstring] = "shortcut for {##{DSLHelpers.underscore(name)}}"
85
+ object.add_tag(returns) if returns
86
+ object[:group] = 'Shortcuts'
87
+ register(object)
88
+ end
89
+ end
90
+ end
91
+
92
+ class ElementsDSLAttributeHandler < YARD::Handlers::Ruby::Base
93
+ handles method_call(:elements)
94
+ namespace_only
95
+
96
+ process do
97
+ name = statement.parameters[0].jump(:tstring_content, :ident).source
98
+ type = statement.parameters[1].jump(:tstring_content, :ident).source
99
+ attrs = statement.parameters[2] ? statement.parameters[2].jump(:hash).source : "{}"
100
+
101
+ unless attrs.start_with?("{")
102
+ attrs = "{#{attrs}}"
103
+ end
104
+
105
+ attrs = eval(attrs)
106
+
107
+ returns = nil
108
+ case type
109
+ when "subset"
110
+ returns = YARD::DocstringParser.new.parse("@return [Array<#{name}>]").to_docstring.tags.first
111
+ when "text"
112
+ returns = YARD::DocstringParser.new.parse("@return [Array<String>]").to_docstring.tags.first
113
+ when "integer"
114
+ returns = YARD::DocstringParser.new.parse("@return [Array<Integer>]").to_docstring.tags.first
115
+ when "float"
116
+ returns = YARD::DocstringParser.new.parse("@return [Array<Float>]").to_docstring.tags.first
117
+ when "bool"
118
+ returns = YARD::DocstringParser.new.parse("@return [Array<Boolean>]").to_docstring.tags.first
119
+ end
120
+
121
+ object = YARD::CodeObjects::MethodObject.new(namespace, "#{DSLHelpers.pluralize(DSLHelpers.underscore(name))}", :instance)
122
+ object.dynamic = true
123
+ object.add_tag(returns) if returns
124
+ object[:group] = 'Low level'
125
+ register(object)
126
+
127
+ if attrs[:shortcut]
128
+ object = YARD::CodeObjects::MethodObject.new(namespace, attrs[:shortcut].to_s, :instance)
129
+ object.dynamic = true
130
+ object[:docstring] = "shortcut for {##{DSLHelpers.pluralize(DSLHelpers.underscore(name))}}"
131
+ object.add_tag(returns) if returns
132
+ object[:group] = 'Shortcuts'
133
+ register(object)
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+
140
+ class DefDelegatorAttributeHandler < YARD::Handlers::Ruby::Base
141
+ handles method_call(:def_delegator)
142
+ namespace_only
143
+
144
+ process do
145
+ obj = statement.parameters[0].jump(:tstring_content, :ident).source
146
+ method = statement.parameters[1].jump(:tstring_content, :ident).source
147
+ object = YARD::CodeObjects::MethodObject.new(namespace, method, :instance)
148
+ object.docstring = ["Forwarded to {#{obj.split("_").map(&:capitalize).join("")}##{method}}",
149
+ "@return (see #{obj.split("_").map(&:capitalize).join("")}##{method})"
150
+ ].join("\n")
151
+ object[:group] = 'High level'
152
+ register(object)
153
+ end
154
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "im_onix"
7
+ spec.version = "1.1.1"
8
+ spec.authors = ["Julien Boulnois"]
9
+ spec.email = ["jboulnois@immateriel.fr"]
10
+
11
+ spec.summary = "ONIX 3.0 & 2.1 parser for Ruby"
12
+ spec.description = "ONIX 3.0 & 2.1 parser for Ruby"
13
+ spec.homepage = "http://github.com/immateriel/im_onix"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency 'yard'
27
+ spec.add_development_dependency 'shoulda'
28
+
29
+ spec.required_ruby_version = '>= 2.1'
30
+
31
+ spec.add_dependency 'nokogiri'
32
+ end
@@ -1,2 +1 @@
1
1
  require_relative 'onix/onix_message'
2
-
@@ -0,0 +1,10 @@
1
+ require 'onix/identifier'
2
+
3
+ module ONIX
4
+ class Addressee < SubsetDSL
5
+ include GlnMethods
6
+
7
+ elements "AddresseeIdentifier", :subset, :shortcut => :identifiers
8
+ element "AddresseeName", :text, :shortcut => :name
9
+ end
10
+ end
@@ -4,8 +4,8 @@ require 'yaml'
4
4
  module ONIX
5
5
  module CodeHelper
6
6
  def parse(n)
7
- @code=n.text
8
- @human=self.class.hash[n.text]
7
+ @code = n.text
8
+ @human = self.class.hash[n.text]
9
9
  end
10
10
 
11
11
  # Humanized string code
@@ -20,166 +20,136 @@ module ONIX
20
20
  end
21
21
 
22
22
  class Code < Subset
23
- # code as defined in ONIX documentation codelist
23
+ # @!attribute code
24
+ # @return [String] code as defined in ONIX documentation codelist
24
25
  attr_accessor :code
25
- # humanized string (eg: "Digital watermarking" become DigitalWatermarking, "PDF" become Pdf, "BISAC Subject Heading" become BisacSubjectHeading, etc)
26
+ # @!attribute human
27
+ # @return [String] humanized string (eg: "Digital watermarking" become DigitalWatermarking, "PDF" become Pdf, "BISAC Subject Heading" become BisacSubjectHeading, etc)
26
28
  attr_accessor :human
27
29
 
28
30
  include CodeHelper
29
31
 
30
- # create Code from string ONIX code
32
+ # create Code from ONIX code
33
+ # @param [String] code ONIX code
34
+ # @return [Code]
31
35
  def self.from_code(code)
32
- o=self.new
33
- o.code=code
34
- o.human=self.hash[code]
35
- o
36
+ obj = self.new
37
+ obj.code = code
38
+ obj.human = self.hash[code]
39
+ obj
36
40
  end
37
41
 
38
- # create Code from humanized string code
42
+ # create Code from human readable code
43
+ # @param [String] human human readable code
44
+ # @return [Code]
39
45
  def self.from_human(human)
40
- o=self.new
41
- o.human=human
42
- o.code=self.hash.key(human)
43
- o
46
+ obj = self.new
47
+ obj.human = human
48
+ obj.code = self.hash.key(human)
49
+ obj
44
50
  end
45
51
 
46
52
  private
53
+
47
54
  def self.hash
48
55
  {}
49
56
  end
50
-
51
57
  end
52
58
 
53
59
  class CodeFromYaml < Code
54
60
  def self.hash
55
- @hash||=YAML.load(File.open(File.dirname(__FILE__) + "/../../data/codelists/codelist-#{self.code_ident}.yml"))[:codelist]
61
+ @hash ||= YAML.load(File.open(File.dirname(__FILE__) + "/../../data/codelists/codelist-#{self.code_ident}.yml"))[:codelist]
56
62
  end
57
63
 
58
64
  def self.list
59
- self.hash.to_a.map{|h| h.first}
65
+ self.hash.to_a.map { |h| h.first }
60
66
  end
61
67
 
62
68
  def self.code_ident
63
69
  nil
64
70
  end
71
+
72
+ def self.code_identifier code
73
+ define_singleton_method :code_ident do
74
+ return code
75
+ end
76
+ end
65
77
  end
66
78
 
67
79
  class CodeFromYamlWithMime < CodeFromYaml
68
80
  # main formats
69
81
  def mimetype
70
82
  case self.human
71
- when "Epub"
72
- "application/epub"
73
- when "Pdf"
74
- "application/pdf"
75
- when "Mobipocket"
76
- "application/x-mobipocket-ebook"
77
- when "Gif"
78
- "image/gif"
79
- when "Jpeg"
80
- "image/jpeg"
81
- when "Png"
82
- "image/png"
83
+ when "Epub"
84
+ "application/epub"
85
+ when "Pdf"
86
+ "application/pdf"
87
+ when "Mobipocket"
88
+ "application/x-mobipocket-ebook"
89
+ when "Gif"
90
+ "image/gif"
91
+ when "Jpeg"
92
+ "image/jpeg"
93
+ when "Png"
94
+ "image/png"
83
95
  end
84
96
  end
85
97
  end
86
98
 
87
99
  class NotificationType < CodeFromYaml
88
- private
89
- def self.code_ident
90
- 1
91
- end
100
+ code_identifier 1
92
101
  end
93
102
 
94
103
  class ProductComposition < CodeFromYaml
95
- private
96
- def self.code_ident
97
- 2
98
- end
104
+ code_identifier 2
99
105
  end
100
106
 
101
107
  class ProductIDType < CodeFromYaml
102
- private
103
- def self.code_ident
104
- 5
105
- end
108
+ code_identifier 5
106
109
  end
107
110
 
108
111
  class CollectionIDType < CodeFromYaml
109
- private
110
- def self.code_ident
111
- 13
112
- end
112
+ code_identifier 13
113
113
  end
114
114
 
115
115
  class TitleType < CodeFromYaml
116
- private
117
- def self.code_ident
118
- 15
119
- end
116
+ code_identifier 15
120
117
  end
121
118
 
122
119
  class WorkIDType < CodeFromYaml
123
- private
124
- def self.code_ident
125
- 16
126
- end
120
+ code_identifier 16
127
121
  end
128
122
 
129
123
  class ContributorRole < CodeFromYaml
130
- private
131
- def self.code_ident
132
- 17
133
- end
124
+ code_identifier 17
134
125
  end
135
126
 
136
127
  class EditionType < CodeFromYaml
137
- private
138
- def self.code_ident
139
- 21
140
- end
128
+ code_identifier 21
141
129
  end
142
130
 
143
131
  class LanguageRole < CodeFromYaml
144
- private
145
- def self.code_ident
146
- 22
147
- end
132
+ code_identifier 22
148
133
  end
149
134
 
150
135
  class ExtentType < CodeFromYaml
151
- private
152
- def self.code_ident
153
- 23
154
- end
136
+ code_identifier 23
155
137
  end
156
138
 
157
139
  class ExtentUnit < CodeFromYaml
158
- private
159
- def self.code_ident
160
- 24
161
- end
140
+ code_identifier 24
162
141
  end
163
142
 
164
143
  class SubjectSchemeIdentifier < CodeFromYaml
165
- private
166
- def self.code_ident
167
- 27
168
- end
144
+ code_identifier 27
169
145
  end
170
146
 
171
147
  class AudienceCode < CodeFromYaml
172
- private
173
- def self.code_ident
174
- 28
175
- end
148
+ code_identifier 28
176
149
  end
177
150
 
178
151
  class IDType < CodeFromYaml
179
- private
180
- def self.code_ident
181
- 44
182
- end
152
+ code_identifier 44
183
153
  end
184
154
 
185
155
  class SenderIDType < IDType
@@ -198,346 +168,202 @@ module ONIX
198
168
  end
199
169
 
200
170
  class PublishingRole < CodeFromYaml
201
- private
202
- def self.code_ident
203
- 45
204
- end
171
+ code_identifier 45
205
172
  end
206
173
 
207
174
  class SalesRightsType < CodeFromYaml
208
- private
209
- def self.code_ident
210
- 46
211
- end
175
+ code_identifier 46
212
176
  end
213
177
 
214
178
  class RegionCode < CodeFromYaml
215
- private
216
- def self.code_ident
217
- 49
218
- end
179
+ code_identifier 49
219
180
  end
220
181
 
221
182
  class ProductRelationCode < CodeFromYaml
222
- private
223
- def self.code_ident
224
- 51
225
- end
183
+ code_identifier 51
226
184
  end
227
185
 
228
186
  class DateFormat < CodeFromYaml
229
- private
230
- def self.code_ident
231
- 55
232
- end
187
+ code_identifier 55
233
188
  end
234
189
 
235
190
  class UnpricedItemType < CodeFromYaml
236
- private
237
- def self.code_ident
238
- 57
239
- end
191
+ code_identifier 57
240
192
  end
241
193
 
242
194
  class PriceType < CodeFromYaml
243
- private
244
- def self.code_ident
245
- 58
246
- end
195
+ code_identifier 58
247
196
  end
248
197
 
249
198
  class PriceQualifier < CodeFromYaml
250
- private
251
- def self.code_ident
252
- 59
253
- end
199
+ code_identifier 59
254
200
  end
255
201
 
256
202
  class PriceStatus < CodeFromYaml
257
- private
258
- def self.code_ident
259
- 61
260
- end
203
+ code_identifier 61
261
204
  end
262
205
 
263
206
  class TaxRateCode < CodeFromYaml
264
- private
265
- def self.code_ident
266
- 62
267
- end
207
+ code_identifier 62
268
208
  end
269
209
 
270
210
  class PublishingStatus < CodeFromYaml
271
- private
272
- def self.code_ident
273
- 64
274
- end
211
+ code_identifier 64
275
212
  end
276
213
 
277
214
  class ProductAvailability < CodeFromYaml
278
- private
279
- def self.code_ident
280
- 65
281
- end
215
+ code_identifier 65
282
216
  end
283
217
 
284
218
  class MarketPublishingStatus < CodeFromYaml
285
- private
286
- def self.code_ident
287
- 68
288
- end
219
+ code_identifier 68
289
220
  end
290
221
 
291
222
  class AgentRole < CodeFromYaml
292
- private
293
- def self.code_ident
294
- 69
295
- end
223
+ code_identifier 69
296
224
  end
297
225
 
298
226
  class SalesRestrictionType < CodeFromYaml
299
- private
300
- def self.code_ident
301
- 71
302
- end
227
+ code_identifier 71
303
228
  end
304
229
 
305
230
  class WebsiteRole < CodeFromYaml
306
- private
307
- def self.code_ident
308
- 73
309
- end
231
+ code_identifier 73
310
232
  end
311
233
 
312
234
  class LanguageCode < CodeFromYaml
313
- private
314
- def self.code_ident
315
- 74
316
- end
235
+ code_identifier 74
317
236
  end
318
237
 
319
238
  class ProductFormFeatureType < CodeFromYaml
320
- private
321
- def self.code_ident
322
- 79
323
- end
239
+ code_identifier 79
324
240
  end
325
241
 
326
242
  class ProductContentType < CodeFromYaml
327
- private
328
- def self.code_ident
329
- 81
330
- end
243
+ code_identifier 81
331
244
  end
332
245
 
333
246
  class CountryCode < CodeFromYaml
334
- private
335
- def self.code_ident
336
- 91
337
- end
247
+ code_identifier 91
338
248
  end
339
249
 
340
250
  class SupplierIDType < CodeFromYaml
341
- private
342
- def self.code_ident
343
- 92
344
- end
251
+ code_identifier 92
345
252
  end
346
253
 
347
254
  class AgentIDType < CodeFromYaml
348
- private
349
- def self.code_ident
350
- 92
351
- end
255
+ code_identifier 92
352
256
  end
353
257
 
354
258
  class SupplierRole < CodeFromYaml
355
- private
356
- def self.code_ident
357
- 93
358
- end
259
+ code_identifier 93
359
260
  end
360
261
 
361
262
  class SalesOutletIDType < CodeFromYaml
362
- private
363
- def self.code_ident
364
- 102
365
- end
263
+ code_identifier 102
366
264
  end
367
265
 
368
266
  class EpubTechnicalProtection < CodeFromYaml
369
- private
370
- def self.code_ident
371
- 144
372
- end
267
+ code_identifier 144
373
268
  end
374
269
 
375
270
  class EpubUsageType < CodeFromYaml
376
- private
377
- def self.code_ident
378
- 145
379
- end
271
+ code_identifier 145
380
272
  end
381
273
 
382
274
  class EpubUsageStatus < CodeFromYaml
383
- private
384
- def self.code_ident
385
- 146
386
- end
275
+ code_identifier 146
387
276
  end
388
277
 
389
278
  class EpubUsageUnit < CodeFromYaml
390
- private
391
- def self.code_ident
392
- 147
393
- end
279
+ code_identifier 147
394
280
  end
395
281
 
396
282
  class CollectionType < CodeFromYaml
397
- private
398
- def self.code_ident
399
- 148
400
- end
283
+ code_identifier 148
401
284
  end
402
285
 
403
286
  class CollectionSequenceType < CodeFromYaml
404
- private
405
- def self.code_ident
406
- 197
407
- end
287
+ code_identifier 197
408
288
  end
409
289
 
410
290
  class TitleElementLevel < CodeFromYaml
411
- private
412
- def self.code_ident
413
- 149
414
- end
291
+ code_identifier 149
415
292
  end
416
293
 
417
294
  class ProductForm < CodeFromYaml
418
- private
419
- def self.code_ident
420
- 150
421
- end
295
+ code_identifier 150
422
296
  end
423
297
 
424
298
  class ContributorPlaceRelator < CodeFromYaml
425
- private
426
- def self.code_ident
427
- 151
428
- end
299
+ code_identifier 151
429
300
  end
430
301
 
431
302
  class TextType < CodeFromYaml
432
- private
433
- def self.code_ident
434
- 153
435
- end
303
+ code_identifier 153
436
304
  end
437
305
 
438
306
  class ContentAudience < CodeFromYaml
439
- private
440
- def self.code_ident
441
- 154
442
- end
307
+ code_identifier 154
443
308
  end
444
309
 
445
310
  class ContentDateRole < CodeFromYaml
446
- private
447
- def self.code_ident
448
- 155
449
- end
311
+ code_identifier 155
450
312
  end
451
313
 
452
314
  class ResourceContentType < CodeFromYaml
453
- private
454
- def self.code_ident
455
- 158
456
- end
315
+ code_identifier 158
457
316
  end
458
317
 
459
318
  class ResourceMode < CodeFromYaml
460
- private
461
- def self.code_ident
462
- 159
463
- end
319
+ code_identifier 159
464
320
  end
465
321
 
466
322
  class ResourceFeatureType < CodeFromYaml
467
- private
468
- def self.code_ident
469
- 160
470
- end
323
+ code_identifier 160
471
324
  end
472
325
 
473
326
  class ResourceForm < CodeFromYaml
474
- private
475
- def self.code_ident
476
- 161
477
- end
327
+ code_identifier 161
478
328
  end
479
329
 
480
330
  class ResourceVersionFeatureType < CodeFromYaml
481
- private
482
- def self.code_ident
483
- 162
484
- end
331
+ code_identifier 162
485
332
  end
486
333
 
487
334
  class MarketDateRole < CodeFromYaml
488
- private
489
- def self.code_ident
490
- 163
491
- end
335
+ code_identifier 163
492
336
  end
493
337
 
494
338
  class PublishingDateRole < CodeFromYaml
495
- private
496
- def self.code_ident
497
- 163
498
- end
339
+ code_identifier 163
499
340
  end
500
341
 
501
342
  class WorkRelationCode < CodeFromYaml
502
- private
503
- def self.code_ident
504
- 164
505
- end
343
+ code_identifier 164
506
344
  end
507
345
 
508
346
  class SupplyDateRole < CodeFromYaml
509
- private
510
- def self.code_ident
511
- 166
512
- end
347
+ code_identifier 166
513
348
  end
514
349
 
515
350
  class TaxType < CodeFromYaml
516
- private
517
- def self.code_ident
518
- 171
519
- end
351
+ code_identifier 171
520
352
  end
521
353
 
522
354
  class PriceDateRole < CodeFromYaml
523
- private
524
- def self.code_ident
525
- 173
526
- end
355
+ code_identifier 173
527
356
  end
528
357
 
529
358
  class ProductFormDetail < CodeFromYamlWithMime
530
- private
531
- def self.code_ident
532
- 175
533
- end
359
+ code_identifier 175
534
360
  end
535
361
 
536
- class SupportingResourceFileFormat < CodeFromYamlWithMime
537
- private
538
- def self.code_ident
539
- 178
540
- end
362
+ class ContributorDateRole < CodeFromYaml
363
+ code_identifier 177
541
364
  end
542
365
 
366
+ class SupportingResourceFileFormat < CodeFromYamlWithMime
367
+ code_identifier 178
368
+ end
543
369
  end