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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +1 -1
- data/CLAUDE.md +96 -0
- data/Gemfile +1 -4
- data/README.adoc +195 -154
- data/bin/console +1 -1
- data/grammars/basicdoc.rng +1572 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1012 -377
- data/grammars/versions.json +26 -26
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +383 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +305 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +754 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +24 -0
- data/lib/relaton/bib/model/bibitem.rb +23 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +16 -0
- data/lib/relaton/bib/model/contributor.rb +71 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +33 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +26 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +23 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +137 -0
- data/lib/relaton/bib/model/item_base.rb +27 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +57 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +48 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +14 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/version.rb +5 -0
- data/lib/relaton/bib.rb +45 -0
- data/relaton-bib.gemspec +11 -8
- metadata +125 -67
- data/lib/relaton_bib/bib_item_locality.rb +0 -175
- data/lib/relaton_bib/biblio_note.rb +0 -72
- data/lib/relaton_bib/biblio_version.rb +0 -46
- data/lib/relaton_bib/bibliographic_date.rb +0 -119
- data/lib/relaton_bib/bibliographic_item.rb +0 -668
- data/lib/relaton_bib/bibliographic_size.rb +0 -103
- data/lib/relaton_bib/bibtex_parser.rb +0 -246
- data/lib/relaton_bib/bibxml_parser.rb +0 -422
- data/lib/relaton_bib/classification.rb +0 -40
- data/lib/relaton_bib/config.rb +0 -16
- data/lib/relaton_bib/contribution_info.rb +0 -117
- data/lib/relaton_bib/contributor.rb +0 -277
- data/lib/relaton_bib/copyright_association.rb +0 -79
- data/lib/relaton_bib/deep_dup.rb +0 -30
- data/lib/relaton_bib/document_identifier.rb +0 -118
- data/lib/relaton_bib/document_relation.rb +0 -95
- data/lib/relaton_bib/document_relation_collection.rb +0 -57
- data/lib/relaton_bib/document_status.rb +0 -92
- data/lib/relaton_bib/document_type.rb +0 -52
- data/lib/relaton_bib/edition.rb +0 -55
- data/lib/relaton_bib/editorial_group.rb +0 -41
- data/lib/relaton_bib/extent.rb +0 -39
- data/lib/relaton_bib/forename.rb +0 -65
- data/lib/relaton_bib/formatted_ref.rb +0 -17
- data/lib/relaton_bib/formatted_string.rb +0 -133
- data/lib/relaton_bib/full_name.rb +0 -108
- data/lib/relaton_bib/hash_converter.rb +0 -568
- data/lib/relaton_bib/hit.rb +0 -52
- data/lib/relaton_bib/hit_collection.rb +0 -105
- data/lib/relaton_bib/ics.rb +0 -42
- data/lib/relaton_bib/image.rb +0 -95
- data/lib/relaton_bib/localized_string.rb +0 -149
- data/lib/relaton_bib/medium.rb +0 -76
- data/lib/relaton_bib/organization.rb +0 -165
- data/lib/relaton_bib/person.rb +0 -129
- data/lib/relaton_bib/place.rb +0 -203
- data/lib/relaton_bib/renderer/bibtex_builder.rb +0 -312
- data/lib/relaton_bib/renderer/bibxml.rb +0 -296
- data/lib/relaton_bib/series.rb +0 -119
- data/lib/relaton_bib/structured_identifier.rb +0 -173
- data/lib/relaton_bib/technical_committee.rb +0 -34
- data/lib/relaton_bib/typed_title_string.rb +0 -191
- data/lib/relaton_bib/typed_uri.rb +0 -57
- data/lib/relaton_bib/util.rb +0 -16
- data/lib/relaton_bib/validity.rb +0 -52
- data/lib/relaton_bib/version.rb +0 -3
- data/lib/relaton_bib/workers_pool.rb +0 -43
- data/lib/relaton_bib/workgroup.rb +0 -58
- data/lib/relaton_bib/xml_parser.rb +0 -718
- data/lib/relaton_bib.rb +0 -111
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0dda50ff6033e0640ffeb6e18596373c644c9704206159f4447a5ccc7f8ec4b
|
|
4
|
+
data.tar.gz: 2d0d134b521224759c9636fbb3aff0f283ec6028a22e8bc0e554aa3795dcdc1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
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
|
-
=
|
|
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
|
-
|
|
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 '
|
|
32
|
+
require 'relaton/bib'
|
|
35
33
|
=> true
|
|
34
|
+
----
|
|
36
35
|
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
=> #<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
=> [#<
|
|
82
|
-
@content="
|
|
83
|
-
@
|
|
84
|
-
@
|
|
85
|
-
@script=
|
|
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(
|
|
93
|
-
=>
|
|
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
|
-
===
|
|
96
|
+
=== Document identifier
|
|
97
97
|
|
|
98
98
|
[source,ruby]
|
|
99
99
|
----
|
|
100
|
-
item.
|
|
101
|
-
=>
|
|
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="
|
|
124
|
+
=> "<bibitem id="ISO1231994" type="standard" schema-version="1.0.0">
|
|
110
125
|
<fetched>2022-05-02</fetched>
|
|
111
|
-
<
|
|
112
|
-
<title
|
|
113
|
-
<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="
|
|
140
|
+
=> "<bibdata type="standard" schema-version="1.0.0">
|
|
124
141
|
<fetched>2022-05-02</fetched>
|
|
125
|
-
<
|
|
142
|
+
<formattedref>ISO 123:1994</formattedref>
|
|
143
|
+
<title language="en" locale="en-US" script="Latn">Geographic information -- Metadata</title>
|
|
126
144
|
...
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
====
|
|
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
|
|
142
|
-
=> "<bibitem id="
|
|
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
|
-
<
|
|
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
|
-
|
|
165
|
+
=== Create bibliographic item form YAML
|
|
175
166
|
|
|
176
167
|
[source,ruby]
|
|
177
168
|
----
|
|
178
|
-
|
|
179
|
-
=> "
|
|
180
|
-
|
|
181
|
-
|
|
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
|
|
176
|
+
=== Create bibliographic item from RFC XML
|
|
187
177
|
|
|
188
178
|
[source,ruby]
|
|
189
179
|
----
|
|
190
|
-
|
|
191
|
-
=>
|
|
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
|
-
|
|
195
|
-
=> #<
|
|
196
|
-
...
|
|
183
|
+
Relaton::Bib::Converter::BibXml.to_item xml
|
|
184
|
+
=> #<Relaton::Bib::ItemData:0x000000011dc9fc98 ...
|
|
197
185
|
----
|
|
198
186
|
|
|
199
|
-
=== Create bibliographic item from
|
|
200
|
-
|
|
187
|
+
=== Create bibliographic item from XML
|
|
201
188
|
[source,ruby]
|
|
202
189
|
----
|
|
203
|
-
|
|
204
|
-
=> <
|
|
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
|
-
|
|
207
|
-
=> #<
|
|
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
|
-
===
|
|
201
|
+
=== Create bibliographic item from BibTeX (@TODO: add support for BibTeX)
|
|
212
202
|
|
|
213
203
|
[source,ruby]
|
|
214
204
|
----
|
|
215
|
-
|
|
216
|
-
=> {"
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
===
|
|
211
|
+
=== Export bibliographic item to YAML
|
|
226
212
|
|
|
227
213
|
[source,ruby]
|
|
228
214
|
----
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
|
224
|
+
=== Export bibliographic item to Hash
|
|
236
225
|
|
|
237
226
|
[source,ruby]
|
|
238
227
|
----
|
|
239
|
-
item.
|
|
240
|
-
=>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
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
|
|
287
|
+
=== Export bibliographic item to RFC XML
|
|
277
288
|
|
|
278
289
|
[source,ruby]
|
|
279
290
|
----
|
|
280
|
-
item.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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é,<br/>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é,<br/>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. <em>This is emphasized</em></t>
|
|
332
|
+
</abstract>
|
|
333
|
+
</front>
|
|
334
|
+
</reference>
|
|
294
335
|
----
|
|
295
336
|
|
|
296
337
|
=== Logging
|
data/bin/console
CHANGED