relaton-bib 1.20.8 → 2.0.0

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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rubocop.yml +1 -1
  4. data/CLAUDE.md +96 -0
  5. data/Gemfile +1 -4
  6. data/README.adoc +195 -154
  7. data/bin/console +1 -1
  8. data/grammars/basicdoc.rng +1572 -671
  9. data/grammars/biblio-standoc.rng +107 -46
  10. data/grammars/biblio.rng +1012 -377
  11. data/grammars/versions.json +26 -26
  12. data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
  13. data/lib/relaton/bib/converter/asciibib.rb +13 -0
  14. data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
  15. data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
  16. data/lib/relaton/bib/converter/bibtex.rb +23 -0
  17. data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +383 -0
  18. data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
  19. data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +305 -0
  20. data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
  21. data/lib/relaton/bib/converter/bibxml.rb +51 -0
  22. data/lib/relaton/bib/hash_parser_v1.rb +754 -0
  23. data/lib/relaton/bib/item_data.rb +229 -0
  24. data/lib/relaton/bib/model/abstract.rb +16 -0
  25. data/lib/relaton/bib/model/address.rb +22 -0
  26. data/lib/relaton/bib/model/affiliation.rb +16 -0
  27. data/lib/relaton/bib/model/bibdata.rb +24 -0
  28. data/lib/relaton/bib/model/bibitem.rb +23 -0
  29. data/lib/relaton/bib/model/contact.rb +18 -0
  30. data/lib/relaton/bib/model/contribution_info.rb +16 -0
  31. data/lib/relaton/bib/model/contributor.rb +71 -0
  32. data/lib/relaton/bib/model/copyright.rb +27 -0
  33. data/lib/relaton/bib/model/date.rb +31 -0
  34. data/lib/relaton/bib/model/depiction.rb +16 -0
  35. data/lib/relaton/bib/model/docidentifier.rb +33 -0
  36. data/lib/relaton/bib/model/doctype.rb +14 -0
  37. data/lib/relaton/bib/model/edition.rb +14 -0
  38. data/lib/relaton/bib/model/ext.rb +26 -0
  39. data/lib/relaton/bib/model/extent.rb +16 -0
  40. data/lib/relaton/bib/model/formattedref.rb +43 -0
  41. data/lib/relaton/bib/model/full_name_type.rb +64 -0
  42. data/lib/relaton/bib/model/fullname.rb +11 -0
  43. data/lib/relaton/bib/model/ics.rb +23 -0
  44. data/lib/relaton/bib/model/image.rb +28 -0
  45. data/lib/relaton/bib/model/item.rb +137 -0
  46. data/lib/relaton/bib/model/item_base.rb +27 -0
  47. data/lib/relaton/bib/model/keyword.rb +30 -0
  48. data/lib/relaton/bib/model/locality.rb +18 -0
  49. data/lib/relaton/bib/model/locality_stack.rb +14 -0
  50. data/lib/relaton/bib/model/localized_string.rb +57 -0
  51. data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
  52. data/lib/relaton/bib/model/logo.rb +14 -0
  53. data/lib/relaton/bib/model/medium.rb +22 -0
  54. data/lib/relaton/bib/model/note.rb +16 -0
  55. data/lib/relaton/bib/model/organization.rb +13 -0
  56. data/lib/relaton/bib/model/organization_type.rb +42 -0
  57. data/lib/relaton/bib/model/person.rb +36 -0
  58. data/lib/relaton/bib/model/phone.rb +14 -0
  59. data/lib/relaton/bib/model/place.rb +33 -0
  60. data/lib/relaton/bib/model/price.rb +14 -0
  61. data/lib/relaton/bib/model/relation.rb +43 -0
  62. data/lib/relaton/bib/model/series.rb +34 -0
  63. data/lib/relaton/bib/model/size.rb +23 -0
  64. data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
  65. data/lib/relaton/bib/model/status.rb +27 -0
  66. data/lib/relaton/bib/model/structured_identifier.rb +48 -0
  67. data/lib/relaton/bib/model/subdivision.rb +16 -0
  68. data/lib/relaton/bib/model/title.rb +56 -0
  69. data/lib/relaton/bib/model/type/string_date.rb +48 -0
  70. data/lib/relaton/bib/model/uri.rb +18 -0
  71. data/lib/relaton/bib/model/validity.rb +16 -0
  72. data/lib/relaton/bib/model/version.rb +14 -0
  73. data/lib/relaton/bib/namespace_helper.rb +21 -0
  74. data/lib/relaton/bib/util.rb +18 -0
  75. data/lib/relaton/bib/version.rb +5 -0
  76. data/lib/relaton/bib.rb +45 -0
  77. data/relaton-bib.gemspec +11 -8
  78. metadata +125 -67
  79. data/lib/relaton_bib/bib_item_locality.rb +0 -175
  80. data/lib/relaton_bib/biblio_note.rb +0 -72
  81. data/lib/relaton_bib/biblio_version.rb +0 -46
  82. data/lib/relaton_bib/bibliographic_date.rb +0 -119
  83. data/lib/relaton_bib/bibliographic_item.rb +0 -668
  84. data/lib/relaton_bib/bibliographic_size.rb +0 -103
  85. data/lib/relaton_bib/bibtex_parser.rb +0 -246
  86. data/lib/relaton_bib/bibxml_parser.rb +0 -422
  87. data/lib/relaton_bib/classification.rb +0 -40
  88. data/lib/relaton_bib/config.rb +0 -16
  89. data/lib/relaton_bib/contribution_info.rb +0 -117
  90. data/lib/relaton_bib/contributor.rb +0 -277
  91. data/lib/relaton_bib/copyright_association.rb +0 -79
  92. data/lib/relaton_bib/deep_dup.rb +0 -30
  93. data/lib/relaton_bib/document_identifier.rb +0 -118
  94. data/lib/relaton_bib/document_relation.rb +0 -95
  95. data/lib/relaton_bib/document_relation_collection.rb +0 -57
  96. data/lib/relaton_bib/document_status.rb +0 -92
  97. data/lib/relaton_bib/document_type.rb +0 -52
  98. data/lib/relaton_bib/edition.rb +0 -55
  99. data/lib/relaton_bib/editorial_group.rb +0 -41
  100. data/lib/relaton_bib/extent.rb +0 -39
  101. data/lib/relaton_bib/forename.rb +0 -65
  102. data/lib/relaton_bib/formatted_ref.rb +0 -17
  103. data/lib/relaton_bib/formatted_string.rb +0 -133
  104. data/lib/relaton_bib/full_name.rb +0 -108
  105. data/lib/relaton_bib/hash_converter.rb +0 -568
  106. data/lib/relaton_bib/hit.rb +0 -52
  107. data/lib/relaton_bib/hit_collection.rb +0 -105
  108. data/lib/relaton_bib/ics.rb +0 -42
  109. data/lib/relaton_bib/image.rb +0 -95
  110. data/lib/relaton_bib/localized_string.rb +0 -149
  111. data/lib/relaton_bib/medium.rb +0 -76
  112. data/lib/relaton_bib/organization.rb +0 -165
  113. data/lib/relaton_bib/person.rb +0 -129
  114. data/lib/relaton_bib/place.rb +0 -203
  115. data/lib/relaton_bib/renderer/bibtex_builder.rb +0 -312
  116. data/lib/relaton_bib/renderer/bibxml.rb +0 -296
  117. data/lib/relaton_bib/series.rb +0 -119
  118. data/lib/relaton_bib/structured_identifier.rb +0 -173
  119. data/lib/relaton_bib/technical_committee.rb +0 -34
  120. data/lib/relaton_bib/typed_title_string.rb +0 -191
  121. data/lib/relaton_bib/typed_uri.rb +0 -57
  122. data/lib/relaton_bib/util.rb +0 -16
  123. data/lib/relaton_bib/validity.rb +0 -52
  124. data/lib/relaton_bib/version.rb +0 -3
  125. data/lib/relaton_bib/workers_pool.rb +0 -43
  126. data/lib/relaton_bib/workgroup.rb +0 -58
  127. data/lib/relaton_bib/xml_parser.rb +0 -718
  128. data/lib/relaton_bib.rb +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49d2c98d4b60a043a8b8efaf715be39d83ce08025c02e2d467cb6d9de9d7c3e5
4
- data.tar.gz: daaad7370596650df3b251433d59b87205cdd195becdd4aa1ecdeadb2f3f9e17
3
+ metadata.gz: f0dda50ff6033e0640ffeb6e18596373c644c9704206159f4447a5ccc7f8ec4b
4
+ data.tar.gz: 2d0d134b521224759c9636fbb3aff0f283ec6028a22e8bc0e554aa3795dcdc1a
5
5
  SHA512:
6
- metadata.gz: 798582d941e2f4d720e16ec306dda1d0a3038274d0f9a620720ab8dca06a9482431729ff7497663ada588b49350c3290fc398d60f9bf3ea946b735f2d6f34615
7
- data.tar.gz: d5c783b0049c2a48f3b7713708e6edb832f8cc88d903e06fe978d5a0be61003d0f1bd642077b8aa556a40cec8d49a3061c4de933a8635eb14de6a4a52ced18d3
6
+ metadata.gz: cfaa4b06692c17d90018c4e54f5efaa91be82f49be3008730a46814433bf2f2dcd7ff3541b2369bf898401b620bbd19adad1752232e3b5a6eeb1ec3ab2914a38
7
+ data.tar.gz: ff217c62b41988af9300bf4dfafd1c469d76254dd2c9402199b0d88418c23c8d7e020ca069b4074cb1d0909fdb57abdd8a0391eb855b9d8d1528548050313caf
data/.gitignore CHANGED
@@ -11,5 +11,7 @@
11
11
 
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
- .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
15
14
  Gemfile.lock
15
+ .claude/
16
+ .rubocop-remote-87c7cdd254a8d09d005ee06efac7acc0.yml
17
+ rubocop-87c7cdd254a8d09d005ee06efac7acc0.yml
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.7
10
+ TargetRubyVersion: 3.2
11
11
  Rails:
12
12
  Enabled: false
data/CLAUDE.md ADDED
@@ -0,0 +1,96 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ RelatonBib is a Ruby gem that implements the [BibliographicItem model](https://github.com/metanorma/relaton-models#bibliography-uml-models) for bibliographic reference management. It's part of the Relaton ecosystem and serves as the base library for other Relaton gems.
8
+
9
+ ## Common Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Run all tests
16
+ bundle exec rake spec
17
+
18
+ # Run a single test file
19
+ bundle exec rspec spec/relaton_bib/bibliographic_item_spec.rb
20
+
21
+ # Run a specific test by line number
22
+ bundle exec rspec spec/relaton_bib/bibliographic_item_spec.rb:42
23
+
24
+ # Run linting
25
+ bundle exec rubocop
26
+
27
+ # Auto-fix linting issues
28
+ bundle exec rubocop -a
29
+
30
+ # Interactive console
31
+ bin/console
32
+ ```
33
+
34
+ ## Architecture
35
+
36
+ ### Serialization Layer (lutaml-model)
37
+
38
+ The codebase uses [lutaml-model](https://github.com/lutaml/lutaml-model) for serialization. Each model class in `lib/relaton/bib/model/` inherits from `Lutaml::Model::Serializable` and declares attributes with XML/YAML/JSON mappings.
39
+
40
+ ### Core Classes
41
+
42
+ **`Relaton::Bib::Item`** ([lib/relaton/bib/model/item.rb](lib/relaton/bib/model/item.rb)) - The main serialization class defining all bibliographic attributes and their XML mappings. Uses `ItemData` as its underlying model.
43
+
44
+ **`Relaton::Bib::ItemData`** ([lib/relaton/bib/item_data.rb](lib/relaton/bib/item_data.rb)) - The data container class that holds bibliographic data and provides conversion methods (`to_xml`, `to_yaml`, `to_bibtex`, `to_rfcxml`). This separation allows the same data to be serialized differently (bibitem vs bibdata).
45
+
46
+ **`Relaton::Bib::Bibitem`** and **`Relaton::Bib::Bibdata`** - Variants of `Item` with different XML root elements and attributes (bibitem excludes `ext`, bibdata excludes `id`).
47
+
48
+ ### Component Models
49
+
50
+ Each bibliographic attribute has its own class in `lib/relaton/bib/model/`:
51
+
52
+ - `Title`, `LocalizedString`, `LocalizedMarkedUpString` - text with language/script
53
+ - `Contributor`, `Person`, `Organization` - contributors and affiliations
54
+ - `Docidentifier` - document IDs (DOI, ISBN, etc.)
55
+ - `Date` - publication dates with custom `StringDate` type
56
+ - `Relation` - related documents (circular reference with Item)
57
+ - `Ext` - extension data (doctype, ICS codes, structured identifiers)
58
+
59
+ ### Parsing
60
+
61
+ - **`HashParserV1`** ([lib/relaton/bib/hash_parser_v1.rb](lib/relaton/bib/hash_parser_v1.rb)) - Converts legacy Hash/YAML format to `ItemData`
62
+ - **`Converter::BibXml`** ([lib/relaton/bib/converter/bibxml.rb](lib/relaton/bib/converter/bibxml.rb)) - Parses RFC BibXML format via `Relaton::Bib::Converter::BibXml.to_item`
63
+ - **lutaml-model native** - `Item.from_xml`, `Item.from_yaml`, `Item.from_json` handle current format
64
+
65
+ ### Rendering
66
+
67
+ - **`Renderer::BibtexBuilder`** - Converts `ItemData` to BibTeX format
68
+ - **`Converter::BibXml`** - Converts `ItemData` to RFC XML format via `Relaton::Bib::Converter::BibXml.to_xml`
69
+ - **lutaml-model native** - `to_xml`, `to_yaml`, `to_json` via the serialization classes
70
+
71
+ ### Usage Pattern
72
+
73
+ ```ruby
74
+ # Parse from YAML
75
+ item = Relaton::Bib::Item.from_yaml(yaml_string)
76
+
77
+ # Parse from XML
78
+ item = Relaton::Bib::Bibitem.from_xml(xml_string)
79
+ item = Relaton::Bib::Bibdata.from_xml(xml_string)
80
+
81
+ # Parse from RFC XML
82
+ item = Relaton::Bib::Converter::BibXml.to_item(xml_string)
83
+
84
+ # Convert to different formats (returns string)
85
+ item.to_xml # as <bibitem>
86
+ item.to_xml(bibdata: true) # as <bibdata>
87
+ item.to_yaml
88
+ item.to_bibtex
89
+ item.to_rfcxml
90
+ ```
91
+
92
+ ## Code Style
93
+
94
+ - Follows Ribose OSS Ruby style guide (inherited via `.rubocop.yml`)
95
+ - Target Ruby version: 3.1+
96
+ - Uses YARD documentation comments
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
 
6
6
  gem "byebug"
7
7
  gem "equivalent-xml", "~> 0.6"
8
+ gem "openssl", "~> 3.3.2" # 3.3.0 raises error when rubocop fetches https resources
8
9
  gem "rake", "~> 13.0"
9
10
  gem "rspec", "~> 3.0"
10
11
  gem "rubocop"
@@ -12,7 +13,3 @@ gem "rubocop-performance"
12
13
  gem "rubocop-rails"
13
14
  gem "ruby-jing"
14
15
  gem "simplecov"
15
-
16
- group :development do
17
- gem "pry"
18
- end
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonBib
1
+ = Relaton::Bib
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-bib.svg["Gem Version", link="https://rubygems.org/gems/relaton-bib"]
4
4
  image:https://github.com/relaton/relaton-bib/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton-bib/actions?workflow=rake"]
@@ -6,7 +6,7 @@ image:https://codeclimate.com/github/relaton/relaton-bib/badges/gpa.svg["Code Cl
6
6
  image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-bib.svg["Pull Requests", link="https://github.com/relaton/relaton-bib/pulls"]
7
7
  image:https://img.shields.io/github/commits-since/relaton/relaton-bib/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-bib/releases"]
8
8
 
9
- RelatonBib is a Ruby gem that implements the https://github.com/metanorma/relaton-models#bibliography-uml-models[BibliographicItem model].
9
+ Relaton::Bib is a Ruby gem that implements the https://github.com/metanorma/relaton-models#bibliography-uml-models[BibliographicItem model].
10
10
 
11
11
  == Installation
12
12
 
@@ -27,78 +27,93 @@ Or install it yourself as:
27
27
 
28
28
  == Usage
29
29
 
30
- === Create bibliographic item
31
-
32
30
  [source,ruby]
33
31
  ----
34
- require 'relaton_bib'
32
+ require 'relaton/bib'
35
33
  => true
34
+ ----
36
35
 
37
- hash = YAML.load_file "spec/examples/bib_item.yml"
38
- => {"id"=>"ISOTC211",
39
- "fetched"=>"2022-05-02",
40
- "title"=>["Geographic information", {"content"=>"Information géographique", "language"=>"fr", "script"=>"Latn"}],
41
- ...
36
+ === Create bibliographic item
42
37
 
43
- item = RelatonBib::BibliographicItem.from_hash(hash)
44
- => #<RelatonBib::BibliographicItem:0x00007f962f030710
45
- @abstract=
46
- [#<RelatonBib::FormattedString:0x00007f962f02acc0
47
- ...
38
+ [source,ruby]
48
39
  ----
40
+ yaml = File.read 'spec/fixtures/item.yaml'
41
+ => "id: ISO1231994\ntype: standard\nschema_version: 1.0.0\nfetched: \"2022-05-02\"\nformattedref: ISO 123:1994\ntitle..."
49
42
 
50
- === BibliographicItem Typed Title Strings
43
+ item = Relaton::Bib::Item.from_yaml yaml
44
+ => #<Relaton::Bib::ItemData:0x000000012838bfc0 ...
45
+ ----
46
+
47
+ === Title
51
48
 
52
49
  [source,ruby]
53
50
  ----
54
51
  item.title
55
- => #<RelatonBib::TypedTitleStringCollection:0x00007fea821ec6b0
56
- @array=
57
- [#<RelatonBib::TypedTitleString:0x00007fea821ecb60
58
- @title=#<RelatonBib::FormattedString:0x00007fea821eca70 @content="Geographic information", @format="text/plain", @language=nil, @script=nil>,
59
- @type="title-main">,
60
- #<RelatonBib::TypedTitleString:0x00007fea821ec8b8
61
- @title=#<RelatonBib::FormattedString:0x00007fea821ec818 @content="Geographic information", @format="text/plain", @language=nil, @script=nil>,
62
- @type="main">,
63
- #<RelatonBib::TypedTitleString:0x00007fea821ec610
64
- @title=
65
- #<RelatonBib::FormattedString:0x00007fea821ec570 @content="Information géographique", @format="text/plain", @language=["fr"], @script=["Latn"]>,
66
- @type=nil>]>
67
-
68
- item.title lang: "fr"
69
- => #<RelatonBib::TypedTitleStringCollection:0x00007fea8222d908
70
- @array=
71
- [#<RelatonBib::TypedTitleString:0x00007fea821ec610
72
- @title=#<RelatonBib::FormattedString:0x00007fea821ec570 @content="Information géographique", @format="text/plain", @language=["fr"], @script=["Latn"]>,
73
- @type=nil>]>
74
- ----
75
-
76
- === BibliographicItem Formatted Strings
52
+ => [#<Relaton::Bib::Title:0x00000001270a6810
53
+ @content="Geographic information -- Metadata",
54
+ @format=nil,
55
+ @language="en",
56
+ @locale="en-US",
57
+ @script="Latn",
58
+ @type=nil>,
59
+ #<Relaton::Bib::Title:0x00000001270a5cd0
60
+ @content="Information géographique -- Métadonnées",
61
+ @format=nil,
62
+ @language="fr",
63
+ @locale="fr-FR",
64
+ @script="Latn",
65
+ @type=nil>]
66
+
67
+ item.title "fr"
68
+ => [#<Relaton::Bib::Title:0x00000001270a5cd0
69
+ @content="Information géographique -- Métadonnées",
70
+ @format=nil,
71
+ @language="fr",
72
+ @locale="fr-FR",
73
+ @script="Latn",
74
+ @type=nil>]
75
+ ----
76
+
77
+ === Abstract
77
78
 
78
79
  [source,ruby]
79
80
  ----
80
81
  item.abstract
81
- => [#<RelatonBib::FormattedString:0x00007fea82236828
82
- @content="<p>ISO 19115-1:2014 defines the schema required for ...</p>",
83
- @format="text/html",
84
- @language=["en"],
85
- @script=["Latn"]>,
86
- #<RelatonBib::FormattedString:0x00007fea82236670
87
- @content="L'ISO 19115-1:2014 définit le schéma requis pour ...",
88
- @format="text/plain",
89
- @language=["fr"],
90
- @script=["Latn"]>]
82
+ => [#<Relaton::Bib::LocalizedMarkedUpString:0x0000000126c05748
83
+ @content="This is an abstract. <em>This is emphasized</em>",
84
+ @language="en",
85
+ @locale="en-US",
86
+ @script="Latn">]
91
87
 
92
- item.abstract(lang: "en").to_s
93
- => "<p>ISO 19115-1:2014 defines the schema required for ...</p>"
88
+ item.abstract("en")
89
+ => [#<Relaton::Bib::LocalizedMarkedUpString:0x0000000126c05748
90
+ @content="This is an abstract. <em>This is emphasized</em>",
91
+ @language="en",
92
+ @locale="en-US",
93
+ @script="Latn">]
94
94
  ----
95
95
 
96
- === BibliographicItem references
96
+ === Document identifier
97
97
 
98
98
  [source,ruby]
99
99
  ----
100
- item.shortref item.docidentifier.first
101
- => "ISOTC211:2014"
100
+ item.docidentifier
101
+ => [#<Relaton::Bib::Docidentifier:0x00000001270a4b00
102
+ @content="ISO 123:1994",
103
+ @language="en",
104
+ @locale="en-US",
105
+ @primary=true,
106
+ @scope="global",
107
+ @script="Latn",
108
+ @type="ISO">,
109
+ #<Relaton::Bib::Docidentifier:0x00000001270a46a0
110
+ @content="10.1007/978-3-319-99155-2_1",
111
+ @language=nil,
112
+ @locale=nil,
113
+ @primary=nil,
114
+ @scope=nil,
115
+ @script=nil,
116
+ @type="DOI">]
102
117
  ----
103
118
 
104
119
  === XML serialization
@@ -106,11 +121,13 @@ item.shortref item.docidentifier.first
106
121
  [source,ruby]
107
122
  ----
108
123
  item.to_xml
109
- => "<bibitem id="ISOTC211" type="standard" schema-version="v1.2.1">
124
+ => "<bibitem id="ISO1231994" type="standard" schema-version="1.0.0">
110
125
  <fetched>2022-05-02</fetched>
111
- <title type="title-main" format="text/plain">Geographic information</title>
112
- <title type="main" format="text/plain">Geographic information</title>
113
- <title format="text/plain" language="fr" script="Latn">Information géographique</title>
126
+ <formattedref>ISO 123:1994</formattedref>
127
+ <title language="en" locale="en-US" script="Latn">Geographic information -- Metadata</title>
128
+ <title language="fr" locale="fr-FR" script="Latn">Information géographique -- Métadonnées</title>
129
+ <uri type="src">https://www.iso.org/standard/22722.html</uri>
130
+ <uri type="doi">10.1007/978-3-319-99155-2_1</uri>
114
131
  ...
115
132
  </bibitem>"
116
133
  ----
@@ -120,131 +137,125 @@ The default root element is `bibitem`. With argument `bibdata: true` the XML wra
120
137
  [source,ruby]
121
138
  ----
122
139
  item.to_xml bibdata: true
123
- => "<bibdata type="standard" schema-version="v1.2.1">
140
+ => "<bibdata type="standard" schema-version="1.0.0">
124
141
  <fetched>2022-05-02</fetched>
125
- <title type="title-main" format="text/plain">Geographic information</title>
142
+ <formattedref>ISO 123:1994</formattedref>
143
+ <title language="en" locale="en-US" script="Latn">Geographic information -- Metadata</title>
126
144
  ...
127
- <ext>
128
- <doctype>document</doctype>
129
- <subdoctype>subdocument</subdoctype>
130
- ...
131
- </ext>
145
+ <ext schema-version="1.0.0">
146
+ <doctype abbreviation="std">Standard</doctype>
147
+ <subdoctype>Technical Report</subdoctype>
148
+ ...
149
+ </ext>
132
150
  </bibdata>"
133
151
  ----
134
152
 
135
- ==== Date format
136
-
137
- By default date elements are formatted as a year (yyyy). Option `:date_format` allows to output date elements in `:short` (yyyy-mm) and `:full` (yyyy-mm-dd) additional formats.
153
+ ==== Adding notes
138
154
 
139
155
  [source,ruby]
140
156
  ----
141
- item.to_xml date_format: :short
142
- => "<bibitem id="ISOTC211" type="standard" schema-version="v1.2.1">
143
- <fetched>2022-05-02</fetched>
144
- <title type="title-main" format="text/plain">Geographic information</title>
157
+ item.to_xml note: [{ content: "Note", type: "note" }]
158
+ => "<bibitem id="ISO1231994" type="standard" schema-version="1.0.0">
145
159
  ...
146
- <date type="issued">
147
- <on>2014-01</on>
148
- </date>
149
- <date type="published">
150
- <on>2014-04</on>
151
- </date>
152
- <date type="accessed">
153
- <on>2015-05</on>
154
- </date>
155
- ...
156
- </bibitem>"
157
-
158
- item.to_xml date_format: :full
159
- => "<bibitem id="ISOTC211" type="standard" schema-version="v1.2.1">
160
- ...
161
- <date type="issued">
162
- <on>2014-01-01</on>
163
- </date>
164
- <date type="published">
165
- <on>2014-04-01</on>
166
- </date>
167
- <date type="accessed">
168
- <on>2015-05-20</on>
169
- </date>
160
+ <note type="note">Note</note>
170
161
  ...
171
162
  </bibitem>"
172
163
  ----
173
164
 
174
- ==== Adding notes
165
+ === Create bibliographic item form YAML
175
166
 
176
167
  [source,ruby]
177
168
  ----
178
- item.to_xml note: [{ text: "Note", type: "note" }]
179
- => "<bibitem id="ISOTC211" type="standard" schema-version="v1.2.1">
180
- ...
181
- <note format="text/plain" type="note">Note</note>
182
- ...
183
- </bibitem>"
169
+ yaml = File.read 'spec/fixtures/item.yaml'
170
+ => "id: ISO1231994\ntype: standard\nschema_version: 1.0.0\nfetched: \"2022-05-02\"\nformattedref: ISO 123:1994\ntitle..."
171
+
172
+ Relaton::Bib::Item.from_yaml yaml
173
+ => #<Relaton::Bib::ItemData:0x000000011dc9e118 ...
184
174
  ----
185
175
 
186
- === Create bibliographic item form YAML
176
+ === Create bibliographic item from RFC XML
187
177
 
188
178
  [source,ruby]
189
179
  ----
190
- hash = YAML.load_file 'spec/examples/bib_item.yml'
191
- => {"id"=>"ISOTC211"
192
- ...
180
+ xml = File.read 'spec/fixtures/rfc.xml'
181
+ => "<reference anchor=\"RFC1\" target=\"10.17487/RFC0001\">\n <front>\n <title>Title RFC1</title>\n <seriesInf..."
193
182
 
194
- RelatonBib::BibliographicItem.from_hash hash
195
- => #<RelatonBib::BibliographicItem:0x007ff1524f8c88
196
- ...
183
+ Relaton::Bib::Converter::BibXml.to_item xml
184
+ => #<Relaton::Bib::ItemData:0x000000011dc9fc98 ...
197
185
  ----
198
186
 
199
- === Create bibliographic item from BibXML
200
-
187
+ === Create bibliographic item from XML
201
188
  [source,ruby]
202
189
  ----
203
- bibxml = File.read "spec/examples/rfc.xml"
204
- => <reference anchor=...
190
+ xml = File.read 'spec/fixtures/bibitem.xml'
191
+ => "<bibitem id=\"ISO1231994\" type=\"standard\" schema-version=\"1.0.0\">\n <fetched>2022-05-02</fetched>\n <forma..."
205
192
 
206
- RelatonBib::BibXMLParser.parse bibxml
207
- => #<RelatonBib::BibliographicItem:0x00007f9d0c75b268
208
- ...
193
+ item = Relaton::Bib::Bibitem.from_xml xml
194
+ => #<Relaton::Bib::ItemData:0x000000011d4b7580 ...
195
+
196
+ xml = File.read 'spec/fixtures/bibdata.xml'
197
+ item = Relaton::Bib::Bibdata.from_xml xml
198
+ => #<Relaton::Bib::ItemData:0x000000011d4daa08 ...
209
199
  ----
210
200
 
211
- === Export bibliographic item to Hash
201
+ === Create bibliographic item from BibTeX (@TODO: add support for BibTeX)
212
202
 
213
203
  [source,ruby]
214
204
  ----
215
- item.to_hash
216
- => {"schema-version"=>"v1.2.1",
217
- "id"=>"ISOTC211",
218
- "title"=>
219
- [{"content"=>"Geographic information", "format"=>"text/plain", "type"=>"title-main"},
220
- {"content"=>"Geographic information", "format"=>"text/plain", "type"=>"main"},
221
- {"content"=>"Information géographique", "language"=>["fr"], "script"=>["Latn"], "format"=>"text/plain"}],
222
- ...
205
+ Relaton::Bib::BibtexParser.from_bibtex File.read('spec/fixtures/techreport.bib')
206
+ => {"ISOTC211"=>
207
+ #<Relaton::Bib::Item:0x007fedee0a2ab0
208
+ ...
223
209
  ----
224
210
 
225
- === Create bibliographic item from BibTeX
211
+ === Export bibliographic item to YAML
226
212
 
227
213
  [source,ruby]
228
214
  ----
229
- RelatonBib::BibtexParser.from_bibtex File.read('spec/examples/techreport.bib')
230
- => {"ISOTC211"=>
231
- #<RelatonBib::BibliographicItem:0x007fedee0a2ab0
232
- ...
215
+ item.to_yaml
216
+ ---
217
+ type: standard
218
+ schema_version: 1.0.0
219
+ fetched: '2022-05-02'
220
+ formattedref: ISO 123:1994
221
+ ...
233
222
  ----
234
223
 
235
- === Export bibliographic item to BibTeX
224
+ === Export bibliographic item to Hash
236
225
 
237
226
  [source,ruby]
238
227
  ----
239
- item.to_bibtex
240
- => @misc{ISOTC211,
241
- title = {Geographic information},
242
- edition = {Edition 1},
243
- author = {Bierman, A. and Bierman, Arnold and Bierman, Arnold B},
244
- ...
228
+ item.to_h
229
+ => {"id"=>"ISO1231994",
230
+ "type"=>"standard",
231
+ "schema_version"=>"...",
232
+ "title"=>[...],
233
+ ...}
245
234
  ----
246
235
 
247
- === Export bibliographic item to Citeproc
236
+ === Export bibliographic item to BibTeX
237
+
238
+ [source,ruby]
239
+ ----
240
+ item.to_bibtex
241
+ @misc{doe1994a,
242
+ title = {Geographic information -- Metadata},
243
+ author = {Doe, John},
244
+ edition = {First edition},
245
+ publisher = {International Organization for Standardization},
246
+ year = {1994},
247
+ month = {jan},
248
+ address = {Geneva, Switzerland, Geneva, Geneva},
249
+ pages = {1--10},
250
+ keywords = {information},
251
+ timestamp = {2022-05-02},
252
+ url = {https://www.iso.org/standard/22722.html},
253
+ doi = {10.1007/978-3-319-99155-2_1},
254
+ month_numeric = {1}
255
+ }
256
+ ----
257
+
258
+ === Export bibliographic item to Citeproc (@TODO: add support for Citeproc)
248
259
 
249
260
  [source,ruby]
250
261
  ----
@@ -257,7 +268,7 @@ item.to_citeproc
257
268
  ...
258
269
  ----
259
270
 
260
- === Exporting bibliographic item to AsciiBib
271
+ === Exporting bibliographic item to AsciiBib (@TODO: add support for AsciiBib)
261
272
 
262
273
  [source,ruby]
263
274
  ----
@@ -273,24 +284,54 @@ item.to_asciibib
273
284
  ...
274
285
  ----
275
286
 
276
- === Export bibliographic item to BibXML (RFC)
287
+ === Export bibliographic item to RFC XML
277
288
 
278
289
  [source,ruby]
279
290
  ----
280
- item.to_bibxml
281
- => "<reference anchor="ISO.TC.211" target="https://www.iso.org/standard/53798.html">
282
- <front>
283
- <title>Geographic information</title>
284
- <author>
285
- <organization abbrev="ISO">International Organization for Standardization</organization>
286
- </author>
287
- ..
288
- </front>
289
- <seriesInfo name="DOI" value="10.17487/rfc1149"/>
290
- <seriesInfo name="Internet-Draft" value="draft-ietf-somewg-someprotocol-07"/>
291
- <seriesInfo name="ISO/IEC FDIS 10118-3" value="serie1234"/>
292
- ...
293
- </reference>"
291
+ item.to_rfcxml
292
+ <reference anchor="ISO 123:1994" target="https://www.iso.org/standard/22722.html">
293
+ <front>
294
+ <title>Geographic information -- Metadata</title>
295
+ <seriesInfo name="DOI" value="10.1007/978-3-319-99155-2_1"/>
296
+ <seriesInfo name="ISO 123" value="1"/>
297
+ <author initials="J.D." surname="Doe" fullname="Prof. John Doe PhD">
298
+ <organization>International Organization for Standardization</organization>
299
+ <address>
300
+ <postal>
301
+ <street>1, rue de Varembé</street>
302
+ <city>Geneva</city>
303
+ <code>1211</code>
304
+ <country>Switzerland</country>
305
+ <postalLine>1, rue de Varembé,&lt;br/&gt;Geneva, Switzerland, 1211</postalLine>
306
+ </postal>
307
+ <phone>+41 22 749 01 11</phone>
308
+ <email>jdoe@email.org</email>
309
+ <uri>https://orcid.org/0000-0002-1825-0097</uri>
310
+ </address>
311
+ </author>
312
+ <author>
313
+ <organization abbrev="ISO">International Organization for Standardization</organization>
314
+ <address>
315
+ <postal>
316
+ <street>1, rue de Varembé</street>
317
+ <city>Geneva</city>
318
+ <code>1211</code>
319
+ <country>Switzerland</country>
320
+ <postalLine>1, rue de Varembé,&lt;br/&gt;Geneva, Switzerland, 1211</postalLine>
321
+ </postal>
322
+ <phone>+41 22 749 01 11</phone>
323
+ <email>office@iso.org</email>
324
+ <uri>https://www.iso.org</uri>
325
+ </address>
326
+ </author>
327
+ <date day="01" month="January" year="1994"></date>
328
+ <workgroup>Geographic information</workgroup>
329
+ <keyword>information</keyword>
330
+ <abstract>
331
+ <t>This is an abstract. &lt;em&gt;This is emphasized&lt;/em&gt;</t>
332
+ </abstract>
333
+ </front>
334
+ </reference>
294
335
  ----
295
336
 
296
337
  === Logging
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "relaton_bib"
4
+ require "relaton/bib"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.