relaton-bsi 1.20.1 → 2.0.0.pre.alpha.1

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +1 -1
  4. data/README.adoc +33 -38
  5. data/grammars/basicdoc.rng +1559 -671
  6. data/grammars/biblio-standoc.rng +107 -46
  7. data/grammars/biblio.rng +1010 -375
  8. data/grammars/relaton-bsi.rng +8 -103
  9. data/lib/{relaton_bsi/bsi_bibliography.rb → relaton/bsi/bibliography.rb} +10 -13
  10. data/lib/relaton/bsi/hit.rb +14 -0
  11. data/lib/{relaton_bsi → relaton/bsi}/hit_collection.rb +36 -17
  12. data/lib/relaton/bsi/item_data.rb +49 -0
  13. data/lib/relaton/bsi/model/bibdata.rb +7 -0
  14. data/lib/relaton/bsi/model/bibitem.rb +7 -0
  15. data/lib/relaton/bsi/model/docidentifier.rb +9 -0
  16. data/lib/relaton/bsi/model/doctype.rb +14 -0
  17. data/lib/relaton/bsi/model/ext.rb +29 -0
  18. data/lib/relaton/bsi/model/item.rb +17 -0
  19. data/lib/relaton/bsi/model/item_base.rb +19 -0
  20. data/lib/relaton/bsi/model/relation.rb +9 -0
  21. data/lib/relaton/bsi/processor.rb +42 -0
  22. data/lib/{relaton_bsi/scrapper.rb → relaton/bsi/scraper.rb} +111 -73
  23. data/lib/relaton/bsi/util.rb +8 -0
  24. data/lib/relaton/bsi/version.rb +7 -0
  25. data/lib/relaton/bsi.rb +25 -0
  26. data/relaton_bsi.gemspec +7 -6
  27. metadata +42 -26
  28. data/lib/relaton_bsi/bsi_bibliographic_item.rb +0 -51
  29. data/lib/relaton_bsi/document_type.rb +0 -21
  30. data/lib/relaton_bsi/hash_converter.rb +0 -21
  31. data/lib/relaton_bsi/hit.rb +0 -14
  32. data/lib/relaton_bsi/processor.rb +0 -38
  33. data/lib/relaton_bsi/util.rb +0 -6
  34. data/lib/relaton_bsi/version.rb +0 -5
  35. data/lib/relaton_bsi/xml_parser.rb +0 -30
  36. data/lib/relaton_bsi.rb +0 -24
  37. /data/lib/{relaton_bsi → relaton/bsi}/schema.json +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e82578054911c622782ef91876b5e716095b936d3120e177744527a40563bb4b
4
- data.tar.gz: 97e482076533f1c5a19d4a6ab17dd93ddcb0d7c4b70602dfe03e16183d7b8572
3
+ metadata.gz: c15513bebf78f48b3913c1dcce3aa13c47b4cec303c27e994039a58ca7d16506
4
+ data.tar.gz: 4359596af621593b0066db9627f211d853f89be48e38706e901b789122032ced
5
5
  SHA512:
6
- metadata.gz: fbdfd5717275bba1a16e3cd421566528b3754d58bc189a0e0c3037c4689b7226a60a84f2f4dd1f1eb1baac3bff5cee091aaafbdc0353b82489b9eb1893bb2a3c
7
- data.tar.gz: b7ed10e6ea91a67c206d90bd65e5204c0043924e9ff861fbc12d6bc82797b55770a48b547d7dab579f3c3fc83ce293856ff861dd98f72b016614016d51b52987
6
+ metadata.gz: '077893dcf0d85d7cceb96de2e162f652b6a306b8072ce923c83ec7d4cb67b8f87748f15ecba6a05152758279ffd25a155d0109a7a150f5e529347952b9209091'
7
+ data.tar.gz: ad14896e08710a685cc3499e5940b89a89ddf1fa9d470661704190235249e7f7e1c0cdfdd0e87c9a71bd01dd1b0da0f492b1abb245b755029c3f32a66cef388b
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  Gemfile.lock
14
14
  .vscode/
15
15
  .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
16
+ .claude/
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/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonBsi retrieve BSI Standards for bibliographic use using the BibliographicItem model
1
+ = Relaton::Bsi retrieve BSI Standards for bibliographic use using the BibliographicItem model
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-bsi.svg["Gem Version", link="https://rubygems.org/gems/relaton-bsi"]
4
4
  image:https://github.com/relaton/relaton-bsi/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton-bsi/actions?workflow=rake"]
@@ -6,7 +6,7 @@ image:https://codeclimate.com/github/relaton/relaton-bsi/badges/gpa.svg["Code Cl
6
6
  image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-bsi.svg["Pull Requests", link="https://github.com/relaton/relaton-bsi/pulls"]
7
7
  image:https://img.shields.io/github/commits-since/relaton/relaton-bsi/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-bsi/releases"]
8
8
 
9
- RelatonBsi is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
9
+ Relaton::Bsi is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
10
10
 
11
11
  == Installation
12
12
 
@@ -31,14 +31,14 @@ Or install it yourself as:
31
31
 
32
32
  [source,ruby]
33
33
  ----
34
- require 'relaton_bsi'
34
+ require 'relaton/bsi'
35
35
  => true
36
36
 
37
- hit_collection = RelatonBsi::BsiBibliography.search("BS EN ISO 8848")
38
- => <RelatonBsi::HitCollection:0x007fead49fe1f8 @ref=BS EN ISO 8848 @fetched=false>
37
+ hit_collection = Relaton::Bsi::Bibliography.search("BS EN ISO 8848")
38
+ => <Relaton::Bsi::HitCollection:0x007fead49fe1f8 @ref=BS EN ISO 8848 @fetched=false>
39
39
 
40
- item = hit_collection[1].fetch
41
- => #<RelatonBsi::BsiBibliographicItem:0x007fead494fbf8
40
+ item = hit_collection[1].item
41
+ => #<Relaton::Bsi::ItemData:0x000000012ac6c9a8
42
42
  ...
43
43
  ----
44
44
 
@@ -46,10 +46,10 @@ item = hit_collection[1].fetch
46
46
  [source,ruby]
47
47
  ----
48
48
  item.to_xml
49
- => "<bibitem id="BSENISO8848-2021" type="standard" schema-version="v1.2.1">
50
- <fetched>2022-12-02</fetched>
51
- <title type="title-main" format="text/plain" language="en" script="Latn">Small craft. Remote mechanical steering systems</title>
52
- <title type="main" format="text/plain" language="en" script="Latn">Small craft. Remote mechanical steering systems</title>
49
+ => "<bibitem id="BSENISO88482021" type="standard" schema-version="v1.4.1">
50
+ <fetched>2025-10-18</fetched>
51
+ <title language="en" script="Latn" type="title-main">Small craft. Remote mechanical steering systems</title>
52
+ <title language="en" script="Latn" type="main">Small craft. Remote mechanical steering systems</title>
53
53
  <uri type="src">https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems</uri>
54
54
  <docidentifier type="BSI" primary="true">BS EN ISO 8848:2021</docidentifier>
55
55
  ...
@@ -62,23 +62,22 @@ Each BSI document has `src` type link.
62
62
 
63
63
  [source,ruby]
64
64
  ----
65
- item.link
66
- => [#<RelatonBib::TypedUri:0x00007fc446c4a1a0
67
- @content=#<Addressable::URI:0x54d8 URI:https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems>,
68
- @language=nil,
69
- @script=nil,
70
- @type="src">]
65
+ item.source[0].type
66
+ => "src"
67
+
68
+ item.source[0].content
69
+ => "https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems"
71
70
  ----
72
71
 
73
72
  With `bibdata: true` option XML output wrapped with `bibdata` element and `ext` element added.
74
73
  [source,ruby]
75
74
  ----
76
75
  item.to_xml bibdata: true
77
- => "<bibdata type="standard" schema-version="v1.2.1">
78
- <fetched>2022-12-02</fetched>
79
- <title type="title-main" format="text/plain" language="en" script="Latn">Small craft. Remote mechanical steering systems</title>
76
+ => "<bibdata type="standard" schema-version="v1.4.1">
77
+ <fetched>2025-10-18</fetched>
78
+ <title language="en" script="Latn" type="title-main">Small craft. Remote mechanical steering systems</title>
80
79
  ...
81
- <ext schema-version="v1.0.0">
80
+ <ext schema-version="v1.0.3">
82
81
  <doctype>standard</doctype>
83
82
  ...
84
83
  </ext>
@@ -88,42 +87,38 @@ item.to_xml bibdata: true
88
87
  === Get standard by code and year
89
88
  [source,ruby]
90
89
  ----
91
- RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
92
- [relaton-bsi] (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
93
- [relaton-bsi] (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
94
- => #<RelatonBsi::BsiBibliographicItem:0x007feb14814ca8
90
+ Relaton::Bsi::Bibliography.get "BS EN ISO 8848:2021"
91
+ [relaton-bsi] INFO: (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
92
+ [relaton-bsi] INFO: (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
93
+ => #<Relaton::Bsi::ItemData:0x000000011f19b688
95
94
  ...
96
95
 
97
- RelatonBsi::BsiBibliography.get "BS EN ISO 8848", "2021"
98
- [relaton-bsi] (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
99
- [relaton-bsi] (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
100
- => #<RelatonBsi::BsiBibliographicItem:0x007feaf59188a8
96
+ Relaton::Bsi::Bibliography.get "BS EN ISO 8848", "2021"
97
+ [relaton-bsi] INFO: (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
98
+ [relaton-bsi] INFO: (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
99
+ => #<Relaton::Bsi::ItemData:0x000000011f1bdc10
101
100
  ...
102
101
  ----
103
102
 
104
103
  === Create bibliographic item form YAML
105
104
  [source,ruby]
106
105
  ----
107
- hash = YAML.load_file 'spec/fixtures/bibdata.yaml'
108
- => {"id"=>"BSENISO8848-2021",
109
- ...
110
-
111
- RelatonBsi::BsiBibliographicItem.from_hash hash
112
- => #<RelatonBsi::BsiBibliographicItem:0x007feaf5109630
106
+ Relaton::Bsi::Item.from_yaml File.read("spec/fixtures/item.yaml", encoding: "UTF-8")
107
+ => #<Relaton::Bsi::ItemData:0x0000000104dd0dd8
113
108
  ...
114
109
  ----
115
110
 
116
111
  === Create bibliographic item from XML
117
112
  [source,ruby]
118
113
  ----
119
- RelatonBsi::XMLParser.from_xml File.read("spec/fixtures/bibdata.xml", encoding: "UTF-8")
120
- => #<RelatonBsi::BsiBibliographicItem:0x007feb14d50b68
114
+ Relaton::Bsi::Item.from_xml File.read("spec/fixtures/bibdata.xml", encoding: "UTF-8")
115
+ => #<Relaton::Bsi::ItemData:0x0000000104178c20
121
116
  ...
122
117
  ----
123
118
 
124
119
  === Logging
125
120
 
126
- RelatonBsi uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
121
+ Relaton::Bsi uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
127
122
 
128
123
  == Development
129
124