asciidoctor-bibliography 0.7.3 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 0aebe410aec21707e9acf513afd0913792a76cd806cff5eb24312ab294e08c4d
4
- data.tar.gz: fdffc4aee122f017599de6c51db1b53fd5fd9f006014dea11a420a21c3e85155
2
+ SHA1:
3
+ metadata.gz: 568b3aeefaaaf19618322048145162faeb1b9d41
4
+ data.tar.gz: d87637a8e50c389f004fefa1022ad95d5a2eb405
5
5
  SHA512:
6
- metadata.gz: 210e7f614e817d141c7c7ffe92a3163a1e70a219a5bdc65e5f663ce3d1d53702bbc49ec1f51f95091b99d9e8f668f64854f980e7ce2eb4660bff031b451cfa7f
7
- data.tar.gz: c78c2e60e930cd7b0737f9fa0e6d74314b407c641b6b7d9ade6df8e8ab10a98059f444e607305de5ada16334e9d65c9ebe12e10f6282d3efbd604561ec23fe8f
6
+ metadata.gz: fc4c7d5c15773821a9a0dded3dcda41d34072e3b7f645a683f7bef429dace26e5ec5009f4baceaa7e47d49051127dd9a683b38823efdb33f2beb8c3abbf0f40a
7
+ data.tar.gz: 77b89168013c0a5d62a84f1a7a47b49741dc82cab82f740e76ba1665b0b0f6589480d59f2a37f54cc991f3de092950a5fac0e716d3e3d2f8c7e29f360609b1de
data/README.adoc CHANGED
@@ -199,6 +199,13 @@ Currently only the `BibTeX` format is supported, with `.bib` or `.bibtex` extens
199
199
  are safe to use: unknown attributes will be silently ignored. If the file has `.biblatex`
200
200
  extension the you will receive a warning on compilation.
201
201
 
202
+ If you need to include multiple databases, you can simply list their names.
203
+ Wildcards are allowed too:
204
+
205
+ [source,asciidoc]
206
+ ----
207
+ :bibliography-database: db1.bib db2.bib ../dbs/*.bibtex
208
+ ----
202
209
 
203
210
  === Styling
204
211
 
@@ -12,12 +12,8 @@ module AsciidoctorBibliography
12
12
  document.bibliographer.options =
13
13
  ::AsciidoctorBibliography::Options.build document, reader
14
14
 
15
- database_filepath =
16
- File.expand_path document.bibliographer.options.database,
17
- document.base_dir
18
-
19
15
  document.bibliographer.database =
20
- ::AsciidoctorBibliography::Database.new database_filepath
16
+ ::AsciidoctorBibliography::Database.new *expand_db_globs(document)
21
17
 
22
18
  processed_lines = process_lines reader.read_lines, document.bibliographer
23
19
  reader.unshift_lines processed_lines
@@ -63,6 +59,19 @@ module AsciidoctorBibliography
63
59
  end
64
60
  end.flatten
65
61
  end
62
+
63
+ def expand_db_globs(document)
64
+ glob_pattern(
65
+ document.bibliographer.options.database,
66
+ document.base_dir,
67
+ )
68
+ end
69
+
70
+ def glob_pattern(pattern_string, base_dir)
71
+ pattern_string.split(/(?<!\\)\s+/).map do |pattern|
72
+ Dir.chdir(base_dir) { Dir.glob(pattern) }
73
+ end.flatten
74
+ end
66
75
  end
67
76
  end
68
77
  end
@@ -13,6 +13,8 @@ module AsciidoctorBibliography
13
13
 
14
14
  def append(filepath)
15
15
  concat Database.load(filepath)
16
+ ensure_no_conflicts!
17
+ self
16
18
  end
17
19
 
18
20
  def find_entry_by_id(id)
@@ -37,5 +39,15 @@ module AsciidoctorBibliography
37
39
  raise Errors::Database::UnsupportedFormat, fileext
38
40
  end
39
41
  end
42
+
43
+ private
44
+
45
+ def ensure_no_conflicts!
46
+ ids = map { |entry| entry["id"] }
47
+ conflicting_ids = ids.select { |id| ids.count(id) > 1 }.uniq.sort
48
+ raise Errors::Database::ConflictingIds, <<~MESSAGE if conflicting_ids.any?
49
+ Conflicting ids were found during database import: #{conflicting_ids}.
50
+ MESSAGE
51
+ end
40
52
  end
41
53
  end
@@ -11,6 +11,7 @@ module AsciidoctorBibliography
11
11
  class UnsupportedFormat < Error; end
12
12
  class FileNotFound < Error; end
13
13
  class IdNotFound < Error; end
14
+ class ConflictingIds < Error; end
14
15
  end
15
16
  end
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.7.3".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
@@ -42,6 +42,12 @@ describe AsciidoctorBibliography::Database do
42
42
  expect { db.append("spec/fixtures/database.bib") }.to(change { db.length })
43
43
  expect { db.append("spec/fixtures/database.bibtex") }.to(change { db.length })
44
44
  end
45
+
46
+ it "raises error if conflicting ids are found" do
47
+ db.append("spec/fixtures/database.bib")
48
+ expect { db.append("spec/fixtures/database.bib") }.
49
+ to raise_exception AsciidoctorBibliography::Errors::Database::ConflictingIds
50
+ end
45
51
  end
46
52
 
47
53
  describe ".load" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-bibliography
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2018-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -326,7 +326,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
326
  - !ruby/object:Gem::Version
327
327
  version: '0'
328
328
  requirements: []
329
- rubygems_version: 3.0.3
329
+ rubyforge_project:
330
+ rubygems_version: 2.6.14
330
331
  signing_key:
331
332
  specification_version: 4
332
333
  summary: Citations and bibliography the "asciidoctor-way"