relaton-bib 2.0.0.pre.alpha.1 → 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 -0
- data/README.adoc +14 -2
- data/grammars/basicdoc.rng +75 -45
- data/grammars/biblio-standoc.rng +37 -56
- data/grammars/biblio.rng +68 -36
- data/grammars/versions.json +25 -25
- 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/{renderer/rfc.rb → converter/bibxml/to_rfcxml.rb} +100 -92
- 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 +121 -78
- data/lib/relaton/bib/item_data.rb +83 -22
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/date.rb +6 -4
- data/lib/relaton/bib/model/depiction.rb +2 -0
- data/lib/relaton/bib/model/ext.rb +0 -3
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/ics.rb +9 -0
- data/lib/relaton/bib/model/item.rb +12 -4
- data/lib/relaton/bib/model/item_base.rb +17 -9
- data/lib/relaton/bib/model/keyword.rb +3 -3
- data/lib/relaton/bib/model/logo.rb +2 -0
- data/lib/relaton/bib/model/organization_type.rb +1 -1
- data/lib/relaton/bib/model/relation.rb +2 -2
- data/lib/relaton/bib/model/series.rb +5 -3
- data/lib/relaton/bib/model/subdivision.rb +2 -0
- data/lib/relaton/bib/model/title.rb +38 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/validity.rb +3 -3
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/version.rb +1 -1
- data/lib/relaton/bib.rb +5 -82
- data/relaton-bib.gemspec +5 -2
- metadata +63 -29
- data/lib/relaton/bib/model/editorial_group.rb +0 -14
- data/lib/relaton/bib/model/technical_committee.rb +0 -14
- data/lib/relaton/bib/model/workgroup.rb +0 -20
- data/lib/relaton/bib/parser/rfc_address.rb +0 -60
- data/lib/relaton/bib/parser/rfc_contacts.rb +0 -35
- data/lib/relaton/bib/parser/rfc_docidentifier.rb +0 -70
- data/lib/relaton/bib/parser/rfc_organization.rb +0 -31
- data/lib/relaton/bib/parser/rfc_person.rb +0 -42
- data/lib/relaton/bib/parser/rfc_reference.rb +0 -143
- data/lib/relaton/bib/parser/rfc_referencegroup.rb +0 -45
- data/lib/relaton/bib/parser/rfc_shared.rb +0 -23
- data/lib/relaton/bib/renderer/bibtex_builder.rb +0 -348
- data/lib/relaton/bibtex_parser.rb +0 -243
- data/lib/relaton/bibxml_parser.rb +0 -419
- data/lib/relaton/deep_dup.rb +0 -30
- data/lib/relaton/hit.rb +0 -52
- data/lib/relaton/hit_collection.rb +0 -105
- data/lib/relaton/workers_pool.rb +0 -43
- data/lib/relaton/xml_parser.rb +0 -716
data/lib/relaton/hit.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require "weakref"
|
|
2
|
-
|
|
3
|
-
module Relaton
|
|
4
|
-
class Hit
|
|
5
|
-
# @return [Relaton::HitCollection]
|
|
6
|
-
attr_accessor :hit_collection
|
|
7
|
-
|
|
8
|
-
# @return [Array<Hash>]
|
|
9
|
-
attr_reader :hit
|
|
10
|
-
|
|
11
|
-
# @param hit [Hash]
|
|
12
|
-
# @param hit_collection [Relaton::HitCollection]
|
|
13
|
-
def initialize(hit, hit_collection = nil)
|
|
14
|
-
@hit = hit
|
|
15
|
-
@hit_collection = WeakRef.new hit_collection if hit_collection
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @return [String]
|
|
19
|
-
def to_s
|
|
20
|
-
inspect
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# @return [String]
|
|
24
|
-
def inspect
|
|
25
|
-
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} " \
|
|
26
|
-
"@text=\"#{@hit_collection&.text}\" " \
|
|
27
|
-
"@fetched=\"#{!@fetch.nil?}\" " \
|
|
28
|
-
"@fullIdentifier=\"#{@fetch&.shortref(nil)}\" " \
|
|
29
|
-
"@title=\"#{@hit[:code]}\">"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def fetch
|
|
33
|
-
raise "Not implemented"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @param opts [Hash]
|
|
37
|
-
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
|
38
|
-
# @option opts [Boolean] :bibdata
|
|
39
|
-
# @option opts [String, Symbol] :lang language
|
|
40
|
-
# @return [String] XML
|
|
41
|
-
def to_xml(**opts)
|
|
42
|
-
if opts[:builder]
|
|
43
|
-
fetch.to_xml(**opts)
|
|
44
|
-
else
|
|
45
|
-
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
|
46
|
-
fetch.to_xml(**opts.merge(builder: xml))
|
|
47
|
-
end
|
|
48
|
-
builder.doc.root.to_xml
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
require "forwardable"
|
|
2
|
-
|
|
3
|
-
module Relaton
|
|
4
|
-
class HitCollection
|
|
5
|
-
extend Forwardable
|
|
6
|
-
|
|
7
|
-
def_delegators :@array, :<<, :[], :first, :empty?, :any?, :size, :each,
|
|
8
|
-
:each_slice, :reduce, :map
|
|
9
|
-
|
|
10
|
-
# @return [TrueClass, FalseClass]
|
|
11
|
-
attr_reader :fetched
|
|
12
|
-
|
|
13
|
-
# @return [String]
|
|
14
|
-
attr_reader :text
|
|
15
|
-
|
|
16
|
-
# @return [String]
|
|
17
|
-
attr_reader :year
|
|
18
|
-
|
|
19
|
-
# @param text [String] reference to search
|
|
20
|
-
def initialize(text, year = nil)
|
|
21
|
-
@array = []
|
|
22
|
-
@text = text
|
|
23
|
-
@year = year
|
|
24
|
-
@fetched = false
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
# Fetches hits from the data source
|
|
29
|
-
#
|
|
30
|
-
# @return [self] self object
|
|
31
|
-
#
|
|
32
|
-
def fetch
|
|
33
|
-
workers = WorkersPool.new 4
|
|
34
|
-
workers.worker(&:fetch)
|
|
35
|
-
each do |hit|
|
|
36
|
-
workers << hit
|
|
37
|
-
end
|
|
38
|
-
workers.end
|
|
39
|
-
workers.result
|
|
40
|
-
@fetched = true
|
|
41
|
-
self
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
# Renders the collection as XML
|
|
46
|
-
#
|
|
47
|
-
# @param opts [Hash] options
|
|
48
|
-
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
|
49
|
-
# @option opts [Boolean] :bibdata render bibdata if true
|
|
50
|
-
# @option opts [String, Symbol] :lang language
|
|
51
|
-
#
|
|
52
|
-
# @return [String] XML representation of the collection
|
|
53
|
-
#
|
|
54
|
-
def to_xml(**opts)
|
|
55
|
-
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
|
56
|
-
xml.documents do
|
|
57
|
-
@array.each do |hit|
|
|
58
|
-
hit.fetch
|
|
59
|
-
hit.to_xml(**opts.merge(builder: xml))
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
builder.to_xml
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
# Selects matching hits and returns a new collection
|
|
68
|
-
#
|
|
69
|
-
# @param [Proc] &block proc to select hits
|
|
70
|
-
#
|
|
71
|
-
# @return [Relaton::Bib::HitCollection] new hit collection
|
|
72
|
-
#
|
|
73
|
-
def select(&block)
|
|
74
|
-
me = deep_dup
|
|
75
|
-
array_dup = instance_variable_get(:@array).deep_dup
|
|
76
|
-
me.instance_variable_set(:@array, array_dup)
|
|
77
|
-
array_dup.select!(&block)
|
|
78
|
-
array_dup.each { |h| h.hit_collection = WeakRef.new me }
|
|
79
|
-
me
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def reduce!(sum, &block)
|
|
83
|
-
@array = @array.reduce sum, &block
|
|
84
|
-
self
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
# Returns String representation of the collection
|
|
89
|
-
#
|
|
90
|
-
# @return [String] String representation of the collection
|
|
91
|
-
#
|
|
92
|
-
def to_s
|
|
93
|
-
inspect
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
#
|
|
97
|
-
# Returns String representation of the collection
|
|
98
|
-
#
|
|
99
|
-
# @return [String] String representation of the collection
|
|
100
|
-
#
|
|
101
|
-
def inspect
|
|
102
|
-
"<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@text} @fetched=#{@fetched}>"
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
data/lib/relaton/workers_pool.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Relaton
|
|
4
|
-
# Workers poll.
|
|
5
|
-
class WorkersPool
|
|
6
|
-
attr_accessor :nb_hits
|
|
7
|
-
|
|
8
|
-
def initialize(num_workers = 2)
|
|
9
|
-
@num_workers = num_workers < 2 ? 2 : num_workers
|
|
10
|
-
@queue = SizedQueue.new(num_workers * 2)
|
|
11
|
-
@result = []
|
|
12
|
-
@nb_hits = 0
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def worker(&block)
|
|
16
|
-
@threads = Array.new @num_workers do
|
|
17
|
-
Thread.new do
|
|
18
|
-
until (item = @queue.pop) == :END
|
|
19
|
-
@result << yield(item) if block
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def result
|
|
26
|
-
@threads.each(&:join)
|
|
27
|
-
@result
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def <<(item)
|
|
31
|
-
@queue << item
|
|
32
|
-
self
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def end
|
|
36
|
-
@num_workers.times { @queue << :END }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def size
|
|
40
|
-
@result.size
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|