relaton-bib 1.20.7 → 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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.adoc +183 -154
- data/bin/console +1 -1
- data/grammars/basicdoc.rng +1516 -645
- data/grammars/biblio-standoc.rng +100 -20
- data/grammars/biblio.rng +959 -356
- data/grammars/versions.json +10 -10
- data/lib/relaton/bib/hash_parser_v1.rb +711 -0
- data/lib/relaton/bib/item_data.rb +168 -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 +29 -0
- data/lib/relaton/bib/model/depiction.rb +14 -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/editorial_group.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +29 -0
- data/lib/relaton/bib/model/extent.rb +16 -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 +14 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +129 -0
- data/lib/relaton/bib/model/item_base.rb +19 -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 +12 -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 +32 -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 +14 -0
- data/lib/relaton/bib/model/technical_committee.rb +14 -0
- data/lib/relaton/bib/model/title.rb +18 -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/model/workgroup.rb +20 -0
- data/lib/relaton/bib/parser/rfc_address.rb +60 -0
- data/lib/relaton/bib/parser/rfc_contacts.rb +35 -0
- data/lib/relaton/bib/parser/rfc_docidentifier.rb +70 -0
- data/lib/relaton/bib/parser/rfc_organization.rb +31 -0
- data/lib/relaton/bib/parser/rfc_person.rb +42 -0
- data/lib/relaton/bib/parser/rfc_reference.rb +143 -0
- data/lib/relaton/bib/parser/rfc_referencegroup.rb +45 -0
- data/lib/relaton/bib/parser/rfc_shared.rb +23 -0
- data/lib/relaton/bib/renderer/bibtex_builder.rb +348 -0
- data/lib/relaton/bib/renderer/rfc.rb +297 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/version.rb +5 -0
- data/lib/{relaton_bib.rb → relaton/bib.rb} +47 -36
- data/lib/{relaton_bib → relaton}/bibtex_parser.rb +24 -27
- data/lib/{relaton_bib → relaton}/bibxml_parser.rb +43 -46
- data/lib/{relaton_bib → relaton}/hit.rb +3 -3
- data/lib/{relaton_bib → relaton}/hit_collection.rb +2 -2
- data/lib/{relaton_bib → relaton}/workers_pool.rb +1 -1
- data/lib/{relaton_bib → relaton}/xml_parser.rb +49 -51
- data/relaton-bib.gemspec +8 -8
- metadata +95 -74
- 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/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/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/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/workgroup.rb +0 -58
- /data/lib/{relaton_bib → relaton}/deep_dup.rb +0 -0
data/lib/relaton_bib/place.rb
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
module RelatonBib
|
2
|
-
class Place
|
3
|
-
|
4
|
-
# @return [String, nil]
|
5
|
-
attr_reader :name, :city
|
6
|
-
|
7
|
-
# @return [Array<RelatonBib::Place::RegionType>]
|
8
|
-
attr_reader :region, :country
|
9
|
-
|
10
|
-
#
|
11
|
-
# Initialize place.
|
12
|
-
#
|
13
|
-
# @param name [String, nil] name of place, name or city should be provided
|
14
|
-
# @param city [String, nil] name of city, city or name should be provided
|
15
|
-
# @param region [Array<RelatonBib::Place::RegionType>] region of place
|
16
|
-
# @param country [Array<RelatonBib::Place::RegionType>] country of place
|
17
|
-
#
|
18
|
-
def initialize(name: nil, city: nil, region: [], country: []) # rubocop:disable Metrics/CyclomaticComplexity
|
19
|
-
if name.nil? && city.nil?
|
20
|
-
raise ArgumentError, "`name` or `city` should be provided"
|
21
|
-
end
|
22
|
-
|
23
|
-
@name = name
|
24
|
-
@city = city
|
25
|
-
@region = region.map { |r| r.is_a?(Hash) ? RegionType.new(**r) : r }
|
26
|
-
@country = country.map { |c| c.is_a?(Hash) ? RegionType.new(**c) : c }
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Render place as XML.
|
31
|
-
#
|
32
|
-
# @param builder [Nologiri::XML::Builder]
|
33
|
-
#
|
34
|
-
def to_xml(builder)
|
35
|
-
if name
|
36
|
-
builder.place name
|
37
|
-
else
|
38
|
-
builder.place do |b|
|
39
|
-
b.city city
|
40
|
-
region.each { |r| b.region { r.to_xml b } }
|
41
|
-
country.each { |c| b.country { c.to_xml b } }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# Render place as Hash.
|
48
|
-
#
|
49
|
-
# @return [Hash]
|
50
|
-
#
|
51
|
-
def to_hash
|
52
|
-
if name then name
|
53
|
-
else
|
54
|
-
hash = { "city" => city }
|
55
|
-
hash["region"] = region.map(&:to_hash) if region.any?
|
56
|
-
hash["country"] = country.map(&:to_hash) if country.any?
|
57
|
-
hash
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Render place as AsciiBib.
|
63
|
-
#
|
64
|
-
# @param prefix [String]
|
65
|
-
# @param count [Integer] number of places
|
66
|
-
#
|
67
|
-
# @return [Stirng]
|
68
|
-
#
|
69
|
-
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
|
70
|
-
pref = prefix.empty? ? "place" : "#{prefix}.place"
|
71
|
-
out = count > 1 ? "#{pref}::\n" : ""
|
72
|
-
return "#{out}#{pref}.name:: #{name}\n" if name
|
73
|
-
|
74
|
-
out += "#{pref}.city:: #{city}\n"
|
75
|
-
out += region.map { |r| r.to_asciibib("#{pref}.region", region.size) }.join
|
76
|
-
out + country.map { |c| c.to_asciibib("#{pref}.country", country.size) }.join
|
77
|
-
end
|
78
|
-
|
79
|
-
class RegionType
|
80
|
-
STATES = {
|
81
|
-
"AK" => "Alaska",
|
82
|
-
"AL" => "Alabama",
|
83
|
-
"AR" => "Arkansas",
|
84
|
-
"AZ" => "Arizona",
|
85
|
-
"CA" => "California",
|
86
|
-
"CO" => "Colorado",
|
87
|
-
"CT" => "Connecticut",
|
88
|
-
"DC" => "District Of Columbia",
|
89
|
-
"DE" => "Delaware",
|
90
|
-
"FL" => "Florida",
|
91
|
-
"GA" => "Georgia",
|
92
|
-
"GU" => "Guam",
|
93
|
-
"HI" => "Hawaii",
|
94
|
-
"IA" => "Iowa",
|
95
|
-
"ID" => "Idaho",
|
96
|
-
"IL" => "Illinois",
|
97
|
-
"IN" => "Indiana",
|
98
|
-
"KS" => "Kansas",
|
99
|
-
"KY" => "Kentucky",
|
100
|
-
"LA" => "Louisiana",
|
101
|
-
"MA" => "Massachusetts",
|
102
|
-
"MD" => "Maryland",
|
103
|
-
"ME" => "Maine",
|
104
|
-
"MI" => "Michigan",
|
105
|
-
"MN" => "Minnesota",
|
106
|
-
"MO" => "Missouri",
|
107
|
-
"MS" => "Mississippi",
|
108
|
-
"MT" => "Montana",
|
109
|
-
"NC" => "North Carolina",
|
110
|
-
"ND" => "North Dakota",
|
111
|
-
"NE" => "Nebraska",
|
112
|
-
"NH" => "New Hampshire",
|
113
|
-
"NJ" => "New Jersey",
|
114
|
-
"NM" => "New Mexico",
|
115
|
-
"NV" => "Nevada",
|
116
|
-
"NY" => "New York",
|
117
|
-
"OH" => "Ohio",
|
118
|
-
"OK" => "Oklahoma",
|
119
|
-
"OR" => "Oregon",
|
120
|
-
"PA" => "Pennsylvania",
|
121
|
-
"PR" => "Puerto Rico",
|
122
|
-
"RI" => "Rhode Island",
|
123
|
-
"SC" => "South Carolina",
|
124
|
-
"SD" => "South Dakota",
|
125
|
-
"TN" => "Tennessee",
|
126
|
-
"TX" => "Texas",
|
127
|
-
"UT" => "Utah",
|
128
|
-
"VA" => "Virginia",
|
129
|
-
"VI" => "Virgin Islands",
|
130
|
-
"VT" => "Vermont",
|
131
|
-
"WA" => "Washington",
|
132
|
-
"WI" => "Wisconsin",
|
133
|
-
"WV" => "West Virginia",
|
134
|
-
"WY" => "Wyoming",
|
135
|
-
}.freeze
|
136
|
-
|
137
|
-
# @return [Strign] name of region
|
138
|
-
attr_reader :name
|
139
|
-
|
140
|
-
# @return [Strign, nil] ISO code of region
|
141
|
-
attr_reader :iso
|
142
|
-
|
143
|
-
# @return [Boolean, nil]
|
144
|
-
attr_reader :recommended
|
145
|
-
|
146
|
-
#
|
147
|
-
# Initialize region type. Name or valid US state ISO code should be provided.
|
148
|
-
#
|
149
|
-
# @param [String, nil] name name of region
|
150
|
-
# @param [String, nil] iso ISO code of region
|
151
|
-
# @param [Boolean, nil] recommended recommended region
|
152
|
-
#
|
153
|
-
def initialize(name: nil, iso: nil, recommended: nil)
|
154
|
-
unless name || STATES.key?(iso&.upcase)
|
155
|
-
raise ArgumentError, "`name` or valid US state ISO code should be provided"
|
156
|
-
end
|
157
|
-
|
158
|
-
@name = name || STATES[iso&.upcase]
|
159
|
-
@iso = iso
|
160
|
-
@recommended = recommended
|
161
|
-
end
|
162
|
-
|
163
|
-
#
|
164
|
-
# Render region type as XML.
|
165
|
-
#
|
166
|
-
# @param [Nokogiri::XML::Builder] builder XML builder
|
167
|
-
#
|
168
|
-
def to_xml(builder)
|
169
|
-
builder.parent["iso"] = iso if iso
|
170
|
-
builder.parent["recommended"] = recommended.to_s unless recommended.nil?
|
171
|
-
builder.text name
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# Render region type as Hash.
|
176
|
-
#
|
177
|
-
# @return [Hash] region type as Hash
|
178
|
-
#
|
179
|
-
def to_hash
|
180
|
-
hash = { "name" => name }
|
181
|
-
hash["iso"] = iso if iso
|
182
|
-
hash["recommended"] = recommended unless recommended.nil?
|
183
|
-
hash
|
184
|
-
end
|
185
|
-
|
186
|
-
#
|
187
|
-
# Render region type as AsciiBib.
|
188
|
-
#
|
189
|
-
# @param [String] pref prefix
|
190
|
-
# @param [Integer] count number of region types
|
191
|
-
#
|
192
|
-
# @return [String] region type as AsciiBib
|
193
|
-
#
|
194
|
-
def to_asciibib(pref, count = 1) # rubocop:disable Metrics/AbcSize
|
195
|
-
out = count > 1 ? "#{pref}::\n" : ""
|
196
|
-
out += "#{pref}.name:: #{name}\n"
|
197
|
-
out += "#{pref}.iso:: #{iso}\n" if iso
|
198
|
-
out += "#{pref}.recommended:: #{recommended}\n" if recommended
|
199
|
-
out
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
@@ -1,312 +0,0 @@
|
|
1
|
-
# Monkey patch to fix the issue with month quotes in BibTeX
|
2
|
-
module BibTeX
|
3
|
-
class Value
|
4
|
-
def to_s(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
5
|
-
if options.key?(:filter)
|
6
|
-
opts = options.reject { |k,| k == :filter || (k == :quotes && (!atomic? || symbol?)) }
|
7
|
-
return convert(options[:filter]).to_s(opts)
|
8
|
-
end
|
9
|
-
|
10
|
-
return value.to_s unless options.key?(:quotes) && atomic?
|
11
|
-
|
12
|
-
q = Array(options[:quotes])
|
13
|
-
[q[0], value, q[-1]].compact.join
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module RelatonBib
|
19
|
-
# BibTeX builder.
|
20
|
-
module Renderer
|
21
|
-
class BibtexBuilder
|
22
|
-
ATTRS = %i[
|
23
|
-
type id title author editor booktitle series number edition contributor
|
24
|
-
date address note relation extent classification keyword docidentifier
|
25
|
-
timestamp link
|
26
|
-
].freeze
|
27
|
-
|
28
|
-
#
|
29
|
-
# Build BibTeX bibliography.
|
30
|
-
#
|
31
|
-
# @param bib [RelatonBib::BibliographicItem]
|
32
|
-
# @param bibtex [BibTeX::Bibliography, nil] BibTeX bibliography
|
33
|
-
#
|
34
|
-
# @return [BibTeX::Bibliography] BibTeX bibliography
|
35
|
-
#
|
36
|
-
def self.build(bib, bibtex = nil)
|
37
|
-
new(bib).build bibtex
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Initialize BibTeX builder.
|
42
|
-
#
|
43
|
-
# @param bib [RelatonBib::BibliographicItem]
|
44
|
-
def initialize(bib)
|
45
|
-
@bib = bib
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# Build BibTeX bibliography.
|
50
|
-
#
|
51
|
-
# @param bibtex [BibTeX::Bibliography, nil] BibTeX bibliography
|
52
|
-
#
|
53
|
-
# @return [BibTeX::Bibliography] BibTeX bibliography
|
54
|
-
#
|
55
|
-
def build(bibtex = nil)
|
56
|
-
@item = BibTeX::Entry.new
|
57
|
-
ATTRS.each { |a| send("add_#{a}") }
|
58
|
-
bibtex ||= BibTeX::Bibliography.new
|
59
|
-
bibtex << @item
|
60
|
-
bibtex
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
#
|
66
|
-
# Add type to BibTeX item
|
67
|
-
#
|
68
|
-
def add_type
|
69
|
-
@item.type = bibtex_type
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [String] BibTeX type
|
73
|
-
def bibtex_type
|
74
|
-
case @bib.type
|
75
|
-
when "standard", nil then "misc"
|
76
|
-
else @bib.type
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# Add ID to BibTeX item
|
82
|
-
#
|
83
|
-
def add_id
|
84
|
-
@item.key = @bib.id
|
85
|
-
end
|
86
|
-
|
87
|
-
#
|
88
|
-
# Add title to BibTeX item
|
89
|
-
#
|
90
|
-
def add_title
|
91
|
-
@bib.title.to_bibtex @item
|
92
|
-
end
|
93
|
-
|
94
|
-
#
|
95
|
-
# Add booktitle to BibTeX item
|
96
|
-
#
|
97
|
-
def add_booktitle
|
98
|
-
included_in = @bib.relation.detect { |r| r.type == "includedIn" }
|
99
|
-
return unless included_in
|
100
|
-
|
101
|
-
@item.booktitle = included_in.bibitem.title.first.title
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# Add author to BibTeX item
|
106
|
-
#
|
107
|
-
def add_author
|
108
|
-
add_author_editor "author"
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
# Add editor to BibTeX item
|
113
|
-
#
|
114
|
-
def add_editor
|
115
|
-
add_author_editor "editor"
|
116
|
-
end
|
117
|
-
|
118
|
-
#
|
119
|
-
# Add author or editor to BibTeX item
|
120
|
-
#
|
121
|
-
# @param [String] type "author" or "editor"
|
122
|
-
#
|
123
|
-
def add_author_editor(type)
|
124
|
-
contribs = @bib.contributor.select do |c|
|
125
|
-
c.entity.is_a?(Person) && c.role.any? { |e| e.type == type }
|
126
|
-
end.map &:entity
|
127
|
-
|
128
|
-
return unless contribs.any?
|
129
|
-
|
130
|
-
@item.send "#{type}=", concat_names(contribs)
|
131
|
-
end
|
132
|
-
|
133
|
-
#
|
134
|
-
# Concatenate names of contributors
|
135
|
-
#
|
136
|
-
# @param [Array<RelatonBib::Person>] contribs contributors
|
137
|
-
#
|
138
|
-
# @return [String] concatenated names
|
139
|
-
#
|
140
|
-
def concat_names(contribs)
|
141
|
-
contribs.map do |p|
|
142
|
-
if p.name.surname
|
143
|
-
"#{p.name.surname}, #{p.name.forename.map(&:to_s).join(' ')}"
|
144
|
-
else
|
145
|
-
p.name.completename.to_s
|
146
|
-
end
|
147
|
-
end.join(" and ")
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# Add series to BibTeX item
|
152
|
-
#
|
153
|
-
def add_series
|
154
|
-
@bib.series.each do |s|
|
155
|
-
case s.type
|
156
|
-
when "journal"
|
157
|
-
@item.journal = s.title.title
|
158
|
-
@item.number = s.number if s.number
|
159
|
-
when nil then @item.series = s.title.title
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
#
|
165
|
-
# Add number to BibTeX item
|
166
|
-
#
|
167
|
-
def add_number
|
168
|
-
return unless %w[techreport manual].include? @bib.type
|
169
|
-
|
170
|
-
did = @bib.docidentifier.detect { |i| i.primary == true }
|
171
|
-
did ||= @bib.docidentifier.first
|
172
|
-
@item.number = did.id if did
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# Add edition to BibTeX item
|
177
|
-
#
|
178
|
-
def add_edition
|
179
|
-
@item.edition = @bib.edition.content if @bib.edition
|
180
|
-
end
|
181
|
-
|
182
|
-
#
|
183
|
-
# Add contributor to BibTeX item
|
184
|
-
#
|
185
|
-
def add_contributor # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
186
|
-
@bib.contributor.each do |c|
|
187
|
-
rls = c.role.map(&:type)
|
188
|
-
if rls.include?("publisher") then @item.publisher = c.entity.name
|
189
|
-
elsif rls.include?("distributor")
|
190
|
-
case @bib.type
|
191
|
-
when "techreport" then @item.institution = c.entity.name
|
192
|
-
when "inproceedings", "conference", "manual", "proceedings"
|
193
|
-
@item.organization = c.entity.name
|
194
|
-
when "mastersthesis", "phdthesis" then @item.school = c.entity.name
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
#
|
201
|
-
# Add date to BibTeX item
|
202
|
-
#
|
203
|
-
def add_date
|
204
|
-
@bib.date.each do |d|
|
205
|
-
case d.type
|
206
|
-
when "published"
|
207
|
-
@item.year = d.on :year
|
208
|
-
month = d.on :month
|
209
|
-
@item.month = month if month
|
210
|
-
when "accessed" then @item.urldate = d.on.to_s
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
#
|
216
|
-
# Add address to BibTeX item
|
217
|
-
#
|
218
|
-
def add_address # rubocop:disable Metrics/AbcSize
|
219
|
-
return unless @bib.place.any?
|
220
|
-
|
221
|
-
reg = @bib.place[0].region[0].name if @bib.place[0].region.any?
|
222
|
-
addr = [@bib.place[0].name, @bib.place[0].city, reg]
|
223
|
-
@item.address = addr.compact.join(", ")
|
224
|
-
end
|
225
|
-
|
226
|
-
#
|
227
|
-
# Add note to BibTeX item
|
228
|
-
#
|
229
|
-
def add_note # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
230
|
-
@bib.biblionote.each do |n|
|
231
|
-
case n.type
|
232
|
-
when "annote" then @item.annote = n.content
|
233
|
-
when "howpublished" then @item.howpublished = n.content
|
234
|
-
when "comment" then @item.comment = n.content
|
235
|
-
when "tableOfContents" then @item.content = n.content
|
236
|
-
when nil then @item.note = n.content
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
#
|
242
|
-
# Add relation to BibTeX item
|
243
|
-
#
|
244
|
-
def add_relation
|
245
|
-
rel = @bib.relation.detect { |r| r.type == "partOf" }
|
246
|
-
if rel
|
247
|
-
title_main = rel.bibitem.title.detect { |t| t.type == "main" }
|
248
|
-
@item.booktitle = title_main.title.content
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
#
|
253
|
-
# Add extent to BibTeX item
|
254
|
-
#
|
255
|
-
def add_extent
|
256
|
-
@bib.extent.each { |e| e.to_bibtex(@item) }
|
257
|
-
end
|
258
|
-
|
259
|
-
#
|
260
|
-
# Add classification to BibTeX item
|
261
|
-
#
|
262
|
-
def add_classification
|
263
|
-
@bib.classification.each do |c|
|
264
|
-
case c.type
|
265
|
-
when "type" then @item["type"] = c.value
|
266
|
-
when "mendeley" then @item["mendeley-tags"] = c.value
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
#
|
272
|
-
# Add keywords to BibTeX item
|
273
|
-
#
|
274
|
-
def add_keyword
|
275
|
-
@item.keywords = @bib.keyword.map(&:content).join(", ") if @bib.keyword.any?
|
276
|
-
end
|
277
|
-
|
278
|
-
#
|
279
|
-
# Add docidentifier to BibTeX item
|
280
|
-
#
|
281
|
-
def add_docidentifier
|
282
|
-
@bib.docidentifier.each do |i|
|
283
|
-
case i.type
|
284
|
-
when "isbn" then @item.isbn = i.id
|
285
|
-
when "lccn" then @item.lccn = i.id
|
286
|
-
when "issn" then @item.issn = i.id
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
#
|
292
|
-
# Add identifier to BibTeX item
|
293
|
-
#
|
294
|
-
def add_timestamp
|
295
|
-
@item.timestamp = @bib.fetched.to_s if @bib.fetched
|
296
|
-
end
|
297
|
-
|
298
|
-
#
|
299
|
-
# Add link to BibTeX item
|
300
|
-
#
|
301
|
-
def add_link
|
302
|
-
@bib.link.each do |l|
|
303
|
-
case l.type&.downcase
|
304
|
-
when "doi" then @item.doi = l.content
|
305
|
-
when "file" then @item.file2 = l.content
|
306
|
-
when "src" then @item.url = l.content
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|