relaton-bib 1.11.2 → 1.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d15360baaf96bbd8ba4bb079f5c1ed71b2d1a3c04a709b7b26122b10ea6e998d
4
- data.tar.gz: ea64b85cfe56d2bac01881c246877f9ffb5329bf108dbffbe9e9ce789352a244
3
+ metadata.gz: 2fff6fdcb77f7545cc6989fa6dcc65eadfde4609ee167eaacf2648205a43a9d4
4
+ data.tar.gz: d2529ceddabe29e386900bceedc3f101e9bf441a87c5d9ac128a7450813083d2
5
5
  SHA512:
6
- metadata.gz: c94693cbcd3a935883d608a80af6d8660ebf08a079898a4658ed057fd5ce7f84e93631f33579f8fbc6696b80f1413fac49b2dd48af120d5c60c7e104ebbf1b01
7
- data.tar.gz: e98dca1228dff147f05e7ea460a95ea909137fa49fdd38fdc9af3c9147e3030e0ef1c65906f79dac5f108b5d2d0107410c52bf8d584a75401f01fd112a8205cb
6
+ metadata.gz: d4aab0bed22dcc71b722547965dedc1a3b315cb092e5b08817cd760c2f3db4363d82d079d58da165f634f440974e2f474255a64a626c2917199ac546b3d05dc9
7
+ data.tar.gz: 21e8feee74c3f8c28b465068700b43c63f9f2ed81cca87974807cae646ed287def53651dce58c5fb5ca2ab274cf482cc1f34b634bdb276a39250df91ed000a6d
data/README.adoc CHANGED
@@ -416,6 +416,19 @@ item.to_bibtex
416
416
  ...
417
417
  ----
418
418
 
419
+ === Export bibliographic item to Citeproc
420
+
421
+ [source,ruby]
422
+ ----
423
+ item.to_citeproc
424
+ => [{"title"=>"Geographic information",
425
+ "edition"=>"1",
426
+ "author"=>[{"family"=>"Bierman", "given"=>"A."}, {"family"=>"Bierman", "given"=>"Forename"}],
427
+ "publisher"=>"Institute of Electrical and Electronics Engineers",
428
+ "publisher-place"=>"bib place",
429
+ ...
430
+ ----
431
+
419
432
  === Exporting bibliographic item to AsciiBib
420
433
 
421
434
  [source,ruby]
@@ -401,30 +401,26 @@ module RelatonBib
401
401
  hash
402
402
  end
403
403
 
404
- # @param bibtex [BibTeX::Bibliography, NilClass]
404
+ #
405
+ # Reander BibTeX
406
+ #
407
+ # @param bibtex [BibTeX::Bibliography, nil]
408
+ #
405
409
  # @return [String]
406
- def to_bibtex(bibtex = nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
407
- item = BibTeX::Entry.new
408
- item.type = bibtex_type
409
- item.key = id
410
- bibtex_title item
411
- item.edition = edition if edition
412
- bibtex_author item
413
- bibtex_contributor item
414
- item.address = place.first.name if place.any?
415
- bibtex_note item
416
- bibtex_relation item
417
- bibtex_extent item
418
- bibtex_date item
419
- bibtex_series item
420
- bibtex_classification item
421
- item.keywords = keyword.map(&:content).join(", ") if keyword.any?
422
- bibtex_docidentifier item
423
- item.timestamp = fetched.to_s if fetched
424
- bibtex_link item
425
- bibtex ||= BibTeX::Bibliography.new
426
- bibtex << item
427
- bibtex.to_s
410
+ #
411
+ def to_bibtex(bibtex = nil)
412
+ bibtext_item(bibtex).to_s
413
+ end
414
+
415
+ #
416
+ # Render citeproc
417
+ #
418
+ # @param bibtex [BibTeX::Bibliography, nil]
419
+ #
420
+ # @return [Hash] citeproc
421
+ #
422
+ def to_citeproc(bibtex = nil)
423
+ bibtext_item(bibtex).to_citeproc.map { |cp| cp.transform_keys(&:to_s) }
428
424
  end
429
425
 
430
426
  # @param lang [String, nil] language code Iso639
@@ -555,13 +551,35 @@ module RelatonBib
555
551
 
556
552
  private
557
553
 
558
- # @return [String]
559
- def bibtex_title(item)
560
- title.each do |t|
561
- case t.type
562
- when "main" then item.tile = t.title.content
563
- end
564
- end
554
+ #
555
+ # Create BibTeX item for this document
556
+ #
557
+ # @param [BibTeX::Bibliography, nil] bibtex <description>
558
+ #
559
+ # @return [BibTeX::Bibliography] BibTeX bibliography
560
+ #
561
+ def bibtext_item(bibtex) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
562
+ item = BibTeX::Entry.new
563
+ item.type = bibtex_type
564
+ item.key = id
565
+ title.to_bibtex item
566
+ item.edition = edition if edition
567
+ bibtex_author item
568
+ bibtex_contributor item
569
+ item.address = place.first.name if place.any?
570
+ bibtex_note item
571
+ bibtex_relation item
572
+ bibtex_extent item
573
+ bibtex_date item
574
+ bibtex_series item
575
+ bibtex_classification item
576
+ item.keywords = keyword.map(&:content).join(", ") if keyword.any?
577
+ bibtex_docidentifier item
578
+ item.timestamp = fetched.to_s if fetched
579
+ bibtex_link item
580
+ bibtex ||= BibTeX::Bibliography.new
581
+ bibtex << item
582
+ bibtex
565
583
  end
566
584
 
567
585
  # @return [String]
@@ -62,6 +62,18 @@ module RelatonBib
62
62
  tl.each { |t| opts[:builder].title { t.to_xml opts[:builder] } }
63
63
  end
64
64
 
65
+ #
66
+ # Add main title ot bibtex entry
67
+ #
68
+ # @param [BibTeX::Entry] item bibtex entry
69
+ #
70
+ def to_bibtex(item)
71
+ tl = titles.detect { |t| t.type == "main" }
72
+ return unless tl
73
+
74
+ item.title = tl.title.content
75
+ end
76
+
65
77
  private
66
78
 
67
79
  # @param lang [String]
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.11.2".freeze
2
+ VERSION = "1.11.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.2
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug