asciidoctor-bibliography 0.0.1.dev → 0.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/.gitignore +1 -1
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +0 -18
- data/README.adoc +45 -4
- data/Rakefile +6 -0
- data/asciidoctor-bibliography.gemspec +9 -6
- data/lib/asciidoctor-bibliography.rb +1 -1
- data/lib/asciidoctor-bibliography/asciidoctor/bibliographer_preprocessor.rb +13 -9
- data/lib/asciidoctor-bibliography/citation.rb +12 -2
- data/lib/asciidoctor-bibliography/formatters/tex.rb +35 -8
- data/lib/asciidoctor-bibliography/helpers.rb +1 -0
- data/lib/asciidoctor-bibliography/index.rb +20 -2
- data/lib/asciidoctor-bibliography/version.rb +1 -1
- data/samples/sample-authoryear.adoc +2 -0
- data/samples/sample-authoryear.html +4 -1
- data/spec/helpers_spec.rb +71 -0
- data/spec/spec_helper.rb +107 -0
- metadata +63 -18
- data/Gemfile.lock +0 -41
- data/samples/.byebug_history +0 -245
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24be1ddb4ec69d1ffabf68e2fc7cf1c628be6130
|
4
|
+
data.tar.gz: b0abf289da6967d4da9e1aeb75acfadc3a4a5f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46db6e6d83b1faa86df2d69d521a7f1810e0f7bd53ee6abe339328c425aff40b7fe9f804c94fe6fb6d93a5afc19f241311e79caf333fce6fcc12cd5f4a610dc
|
7
|
+
data.tar.gz: dc999d205e2c1d919489ba773eb37ea42253eb4b922e40a9abca0109e76ded8e8446cfe9276959ab92c1dffd8831fb81e610fa425a5910a8f2ae1919769ec52f
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,21 +1,3 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/riboseinc/asciidoctor-bibliography" }
|
4
|
-
|
5
3
|
gemspec
|
6
|
-
|
7
|
-
# gem 'asciidoctor'
|
8
|
-
|
9
|
-
# gem 'bibtex-ruby'
|
10
|
-
# gem 'latex-decode'
|
11
|
-
|
12
|
-
# gem 'byebug'
|
13
|
-
|
14
|
-
# gem 'citeproc-ruby'
|
15
|
-
# gem 'csl-styles'
|
16
|
-
|
17
|
-
|
18
|
-
# s.add_runtime_dependency('bibliography-ruby', "~> 4")
|
19
|
-
# s.add_runtime_dependency('citeproc-ruby')
|
20
|
-
# s.add_runtime_dependency('csl-styles', '~> 1')
|
21
|
-
# s.add_runtime_dependency('latex-decode', '~> 0.2')
|
data/README.adoc
CHANGED
@@ -21,25 +21,66 @@ gem "asciidoctor-bibliography"
|
|
21
21
|
|
22
22
|
And then execute:
|
23
23
|
|
24
|
-
[source,
|
24
|
+
[source,console]
|
25
25
|
----
|
26
26
|
$ bundle install
|
27
27
|
----
|
28
28
|
|
29
29
|
Or install it yourself as:
|
30
30
|
|
31
|
-
[source,
|
31
|
+
[source,console]
|
32
32
|
----
|
33
33
|
$ gem install asciidoctor-bibliography
|
34
34
|
----
|
35
35
|
|
36
36
|
== Configure
|
37
37
|
|
38
|
-
|
38
|
+
In your document header, define the following below the title.
|
39
|
+
|
40
|
+
----
|
41
|
+
= Latex Macros In Bibtex Items
|
42
|
+
:bibliography-database: first.bib
|
43
|
+
:bibliography-database: second.bib
|
44
|
+
:bibliography-reference-style: ieee
|
45
|
+
----
|
39
46
|
|
40
47
|
== Usage
|
41
48
|
|
42
|
-
|
49
|
+
Include asciidoctor-bibliography in your chain:
|
50
|
+
|
51
|
+
[source,console]
|
52
|
+
----
|
53
|
+
$ asciidoctor -r asciidoctor-bibliography main.adoc
|
54
|
+
----
|
55
|
+
|
56
|
+
Add citation commands within your AsciiDoc:
|
57
|
+
|
58
|
+
----
|
59
|
+
Searching Function (see cite:guo2009[])
|
60
|
+
----
|
61
|
+
|
62
|
+
List out bibliography:
|
63
|
+
|
64
|
+
----
|
65
|
+
bibliography::[]
|
66
|
+
----
|
67
|
+
|
68
|
+
== Example
|
69
|
+
|
70
|
+
----
|
71
|
+
= Latex Macros In Bibtex Items
|
72
|
+
:bibliography-database: reference.bib
|
73
|
+
:bibliography-reference-style: ieee
|
74
|
+
|
75
|
+
== Contents
|
76
|
+
|
77
|
+
This is a paper "Validation and Verificaton of Computer Forensic Software
|
78
|
+
tools -- Searching Function" (see cite:guo2009[]).
|
79
|
+
|
80
|
+
== Bibliography
|
81
|
+
|
82
|
+
bibliography::[]
|
83
|
+
----
|
43
84
|
|
44
85
|
== Development
|
45
86
|
|
data/Rakefile
ADDED
@@ -26,12 +26,15 @@ END
|
|
26
26
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
27
27
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
|
28
28
|
|
29
|
-
spec.
|
29
|
+
spec.add_dependency "asciidoctor"
|
30
|
+
spec.add_dependency "citeproc-ruby"
|
31
|
+
spec.add_dependency "csl-styles", "~> 1"
|
32
|
+
spec.add_dependency "latex-decode", "~> 0.2"
|
33
|
+
spec.add_dependency "bibtex-ruby"
|
30
34
|
|
31
|
-
spec.add_development_dependency "
|
32
|
-
spec.add_development_dependency "bibtex-ruby"
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
33
36
|
spec.add_development_dependency "byebug"
|
34
|
-
spec.add_development_dependency "
|
35
|
-
spec.add_development_dependency "
|
36
|
-
spec.add_development_dependency "
|
37
|
+
spec.add_development_dependency "rspec"
|
38
|
+
spec.add_development_dependency "rake"
|
39
|
+
spec.add_development_dependency "simplecov"
|
37
40
|
end
|
@@ -11,15 +11,7 @@ module AsciidoctorBibliography
|
|
11
11
|
module Asciidoctor
|
12
12
|
class BibliographerPreprocessor < ::Asciidoctor::Extensions::Preprocessor
|
13
13
|
def process document, reader
|
14
|
-
|
15
|
-
# We peek at the document attributes we need, without perturbing the parsing flow.
|
16
|
-
# NOTE: we're in a preprocessor and they haven't been parsed yet; doing it manually.
|
17
|
-
document_attributes =
|
18
|
-
::Asciidoctor::Parser
|
19
|
-
.parse(reader, ::Asciidoctor::Document.new, header_only: true)
|
20
|
-
.attributes
|
21
|
-
# We extract only the ones we recognize.
|
22
|
-
document.bibliographer.options = Hash[Helpers.slice(document_attributes, 'bibliography-citation-style', 'bibliography-order', 'bibliography-reference-style', 'bibliography-database').map {|k, v| [k.sub(/^bibliography-/, ''), v] }]
|
14
|
+
set_bibliographer_options(document, reader)
|
23
15
|
|
24
16
|
# We're handling single database/formatters; generalization will be straightforward when needed.
|
25
17
|
document.bibliographer.database = Database.new(document.bibliographer.options['database'])
|
@@ -63,6 +55,18 @@ module AsciidoctorBibliography
|
|
63
55
|
processed_lines.flatten!
|
64
56
|
reader = ::Asciidoctor::Reader.new processed_lines
|
65
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def set_bibliographer_options(document, reader)
|
62
|
+
# We peek at the document attributes we need, without perturbing the parsing flow.
|
63
|
+
# NOTE: we're in a preprocessor and they haven't been parsed yet; doing it manually.
|
64
|
+
document_attributes =
|
65
|
+
::Asciidoctor::Parser
|
66
|
+
.parse(reader, ::Asciidoctor::Document.new, header_only: true)
|
67
|
+
.attributes
|
68
|
+
document.bibliographer.options = Hash[Helpers.slice(document_attributes, 'bibliography-citation-style', 'bibliography-order', 'bibliography-reference-style', 'bibliography-database').map {|k, v| [k.sub(/^bibliography-/, ''), v] }]
|
69
|
+
end
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -5,6 +5,7 @@ module AsciidoctorBibliography
|
|
5
5
|
class Citation
|
6
6
|
TEX_MACROS_NAMES = Formatters::TeX::MACROS.keys.map { |s| Regexp.escape s }.concat(['fullcite']).join('|')
|
7
7
|
REGEXP = /\\?(#{TEX_MACROS_NAMES}):(?:(\S*?)?\[(|.*?[^\\])\])(?:\+(\S*?)?\[(|.*?[^\\])\])*/
|
8
|
+
REF_ATTRIBUTES = %i[chapter page section clause]
|
8
9
|
|
9
10
|
# No need for a fully fledged class right now.
|
10
11
|
Cite = Struct.new(:key, :occurrence_index, :target, :positional_attributes, :named_attributes)
|
@@ -33,10 +34,19 @@ module AsciidoctorBibliography
|
|
33
34
|
|
34
35
|
def render(bibliographer)
|
35
36
|
if macro == 'fullcite'
|
36
|
-
# NOTE: we reinstantiate to avoid tracking used keys.
|
37
37
|
formatter = Formatters::CSL.new(bibliographer.options['reference-style'])
|
38
|
-
|
38
|
+
|
39
|
+
# NOTE: being able to overwrite a more general family of attributes would be neat.
|
40
|
+
mergeable_attributes = Helpers.slice(cites.first.named_attributes || {}, *(REF_ATTRIBUTES.map(&:to_s)))
|
41
|
+
|
42
|
+
# reject empty values
|
43
|
+
mergeable_attributes.reject! do |key, value|
|
44
|
+
value.nil? || value.empty?
|
45
|
+
end
|
39
46
|
# TODO: as is, cites other than the first are simply ignored.
|
47
|
+
database_entry = bibliographer.database.find { |e| e['id'] == cites.first.key }
|
48
|
+
database_entry.merge!(mergeable_attributes)
|
49
|
+
formatter.import([database_entry])
|
40
50
|
'{empty}' + Helpers.html_to_asciidoc(formatter.render(:bibliography, id: cites.first.key).join)
|
41
51
|
elsif Formatters::TeX::MACROS.keys.include? macro
|
42
52
|
bibliographer.citation_formatter.render(self)
|
@@ -114,23 +114,49 @@ module AsciidoctorBibliography
|
|
114
114
|
[@opening_bracket, string, @closing_bracket].compact.join
|
115
115
|
end
|
116
116
|
|
117
|
+
def find_entry(key)
|
118
|
+
entry = @database.find{ |h| h['id'] == key }
|
119
|
+
if entry.nil?
|
120
|
+
raise StandardError, "Can't find entry: #{key}"
|
121
|
+
end
|
122
|
+
entry
|
123
|
+
end
|
124
|
+
|
117
125
|
def year(cite)
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
issued.
|
126
|
+
entry = find_entry(cite.key)
|
127
|
+
issued = entry['issued']
|
128
|
+
|
129
|
+
if issued.nil?
|
130
|
+
puts "asciidoctor-bibliography: citation (#{cite.key}) has no 'issued' information"
|
131
|
+
return ""
|
132
|
+
end
|
133
|
+
|
134
|
+
date_parts = issued['date-parts']
|
135
|
+
return "" if date_parts.nil?
|
136
|
+
|
137
|
+
return "" if date_parts.first.nil?
|
138
|
+
date_parts.first.first
|
122
139
|
end
|
123
140
|
|
124
141
|
def extra(cite)
|
125
142
|
na = cite.named_attributes
|
126
143
|
extra = []
|
127
144
|
return extra if na.nil?
|
128
|
-
|
129
|
-
|
130
|
-
|
145
|
+
|
146
|
+
Citation::REF_ATTRIBUTES.each do |sym|
|
147
|
+
next if na[sym.to_s].nil?
|
148
|
+
extra << ref_content(sym, na[sym.to_s])
|
149
|
+
end
|
150
|
+
|
131
151
|
extra
|
132
152
|
end
|
133
153
|
|
154
|
+
# TODO: should this be configurable?
|
155
|
+
# TODO RT: Yes, and i18n!
|
156
|
+
def ref_content(sym, content)
|
157
|
+
"#{sym.to_s.capitalize} #{content}"
|
158
|
+
end
|
159
|
+
|
134
160
|
def authors(mode, cite)
|
135
161
|
case mode
|
136
162
|
when :full
|
@@ -143,7 +169,8 @@ module AsciidoctorBibliography
|
|
143
169
|
end
|
144
170
|
|
145
171
|
def authors_list(cite)
|
146
|
-
|
172
|
+
entry = find_entry(cite.key)
|
173
|
+
authors = entry['author']
|
147
174
|
return [] if authors.nil?
|
148
175
|
authors.map{ |h| h['family'] }.compact
|
149
176
|
end
|
@@ -15,14 +15,24 @@ module AsciidoctorBibliography
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def render(bibliographer)
|
18
|
-
|
18
|
+
unsorted_lines = []
|
19
19
|
bibliographer.occurring_keys.each_with_index do |target, index|
|
20
20
|
line = '{empty}'
|
21
21
|
line << "[#{index + 1}] " if bibliographer.options['citation-style'] == 'numbers'
|
22
22
|
line << render_entry(target, bibliographer.index_formatter)
|
23
|
-
|
23
|
+
if bibliographer.options['order'] == 'alphabetical'
|
24
|
+
sortable_index = first_author_family_name(target, bibliographer)
|
25
|
+
elsif bibliographer.options['order'] == 'appearance'
|
26
|
+
sortable_index = index
|
27
|
+
else # defaults to appearance
|
28
|
+
sortable_index = index
|
29
|
+
end
|
30
|
+
|
31
|
+
unsorted_lines << { line: line, sortable_index: sortable_index }
|
24
32
|
end
|
25
33
|
|
34
|
+
lines = unsorted_lines.sort_by { |l| l[:sortable_index] }.map { |l| l[:line] }
|
35
|
+
|
26
36
|
# Intersperse the lines with empty ones to render as paragraphs.
|
27
37
|
lines.join("\n\n").lines.map(&:strip)
|
28
38
|
end
|
@@ -38,6 +48,14 @@ module AsciidoctorBibliography
|
|
38
48
|
def render_entry(target, formatter)
|
39
49
|
"anchor:#{render_entry_id(target)}[]#{render_entry_label(target, formatter)}"
|
40
50
|
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def first_author_family_name(key, bibliographer)
|
55
|
+
authors = bibliographer.database.find{ |h| h['id'] == key }['author']
|
56
|
+
return "" if authors.nil?
|
57
|
+
authors.map{ |h| h['family'] }.compact.first # TODO: is the first also alphabetically the first?
|
58
|
+
end
|
41
59
|
end
|
42
60
|
end
|
43
61
|
|
@@ -453,6 +453,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
453
453
|
<p>Anderson, J. R., D. Bothell, M. D. Byrne, S. Douglass, C. Lebiere, and Y. L. Qin. 2004. “An Integrated Theory of the Mind.” <em>Psychological Review</em> 111 (4): 1036–60. (fullcite, single)</p>
|
454
454
|
</div>
|
455
455
|
<div class="paragraph">
|
456
|
+
<p>Anderson, J. R., D. Bothell, M. D. Byrne, S. Douglass, C. Lebiere, and Y. L. Qin. 2004. “An Integrated Theory of the Mind.” <em>Psychological Review</em> 111 (4): 123. (fullcite, single)</p>
|
457
|
+
</div>
|
458
|
+
<div class="paragraph">
|
456
459
|
<p><a href="#bibliography-Anderson04">Anderson et al. (2004)</a> (citet, single)</p>
|
457
460
|
</div>
|
458
461
|
<div class="paragraph">
|
@@ -543,7 +546,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
543
546
|
</div>
|
544
547
|
<div id="footer">
|
545
548
|
<div id="footer-text">
|
546
|
-
Last updated 2017-08-
|
549
|
+
Last updated 2017-08-22 23:24:34 CEST
|
547
550
|
</div>
|
548
551
|
</div>
|
549
552
|
</body>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'asciidoctor-bibliography/helpers'
|
2
|
+
|
3
|
+
describe AsciidoctorBibliography::Helpers do
|
4
|
+
describe '.slice' do
|
5
|
+
it 'finds one or more existing keys' do
|
6
|
+
expect(subject.slice({ foo: 'bar', baz: 'qux' }, :foo)).to eq({ foo: 'bar' })
|
7
|
+
expect(subject.slice({ foo: 'bar', baz: 'qux' }, :foo, :baz)).to eq({ foo: 'bar', baz: 'qux' })
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns nil for missing keys' do
|
11
|
+
expect(subject.slice({}, :foo)).to eq({ foo: nil })
|
12
|
+
expect(subject.slice({ foo: 'bar' }, :bar)).to eq({ bar: nil })
|
13
|
+
expect(subject.slice({ foo: 'bar' }, :foo, :baz)).to eq({ foo: 'bar', baz: nil })
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.join_nonempty' do
|
18
|
+
it 'ignores nils' do
|
19
|
+
expect(subject.join_nonempty([nil], '-')).to eq('')
|
20
|
+
expect(subject.join_nonempty(['foo', nil], '-')).to eq('foo')
|
21
|
+
expect(subject.join_nonempty([nil, 'bar'], '-')).to eq('bar')
|
22
|
+
expect(subject.join_nonempty(['foo', nil, 'bar'], '-')).to eq('foo-bar')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'ignores empty strings' do
|
26
|
+
expect(subject.join_nonempty([''], '-')).to eq('')
|
27
|
+
expect(subject.join_nonempty(['foo', ''], '-')).to eq('foo')
|
28
|
+
expect(subject.join_nonempty(['', 'bar'], '-')).to eq('bar')
|
29
|
+
expect(subject.join_nonempty(['foo', '', 'bar'], '-')).to eq('foo-bar')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.html_to_asciidoc' do
|
34
|
+
it 'converts italic' do
|
35
|
+
expect(subject.html_to_asciidoc('This is <i>italic</i>.')).to eq('This is _italic_.')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'converts bold' do
|
39
|
+
expect(subject.html_to_asciidoc('This is <b>bold</b>.')).to eq('This is *bold*.')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'drops spans' do
|
43
|
+
expect(subject.html_to_asciidoc('This is a <span attribute="value">span</span>.'))
|
44
|
+
.to eq('This is a span.')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'drops curly brackets' do
|
48
|
+
expect(subject.html_to_asciidoc('This is {bracketed}.'))
|
49
|
+
.to eq('This is bracketed.')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.to_sentence' do
|
54
|
+
let(:new_options) { { words_connector: '1',
|
55
|
+
two_words_connector: '2',
|
56
|
+
last_word_connector: '3' } }
|
57
|
+
|
58
|
+
it 'concatenates arbitrary arrays' do
|
59
|
+
expect(subject.to_sentence([])).to eq('')
|
60
|
+
expect(subject.to_sentence(['foo'])).to eq('foo')
|
61
|
+
expect(subject.to_sentence(['foo', 'bar'])).to eq('foo and bar')
|
62
|
+
expect(subject.to_sentence(['foo', 'bar', 'baz'])).to eq('foo, bar, and baz')
|
63
|
+
expect(subject.to_sentence(['foo', 'bar', 'baz', 'qux'])).to eq('foo, bar, baz, and qux')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'accepts custom separators' do
|
67
|
+
expect(subject.to_sentence(['foo', 'bar'], new_options)).to eq('foo2bar')
|
68
|
+
expect(subject.to_sentence(['foo', 'bar', 'baz'], new_options)).to eq('foo1bar3baz')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter "/spec/"
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'asciidoctor-bibliography'
|
7
|
+
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
11
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
12
|
+
# files.
|
13
|
+
#
|
14
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
15
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
16
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
17
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
18
|
+
# a separate helper file that requires the additional dependencies and performs
|
19
|
+
# the additional setup, and require it from the spec files that actually need
|
20
|
+
# it.
|
21
|
+
#
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# rspec-expectations config goes here. You can use an alternate
|
25
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
+
# assertions if you prefer.
|
27
|
+
config.expect_with :rspec do |expectations|
|
28
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
+
# and `failure_message` of custom matchers include text for helper methods
|
30
|
+
# defined using `chain`, e.g.:
|
31
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
+
# # => "be bigger than 2 and smaller than 4"
|
33
|
+
# ...rather than:
|
34
|
+
# # => "be bigger than 2"
|
35
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
+
end
|
37
|
+
|
38
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
+
config.mock_with :rspec do |mocks|
|
41
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
+
# a real object. This is generally recommended, and will default to
|
43
|
+
# `true` in RSpec 4.
|
44
|
+
mocks.verify_partial_doubles = true
|
45
|
+
end
|
46
|
+
|
47
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
48
|
+
# have no way to turn it off -- the option exists only for backwards
|
49
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
50
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
51
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
52
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
53
|
+
|
54
|
+
# The settings below are suggested to provide a good initial experience
|
55
|
+
# with RSpec, but feel free to customize to your heart's content.
|
56
|
+
=begin
|
57
|
+
# This allows you to limit a spec run to individual examples or groups
|
58
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
59
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
60
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
61
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
62
|
+
config.filter_run_when_matching :focus
|
63
|
+
|
64
|
+
# Allows RSpec to persist some state between runs in order to support
|
65
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
66
|
+
# you configure your source control system to ignore this file.
|
67
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
68
|
+
|
69
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
70
|
+
# recommended. For more details, see:
|
71
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
72
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
73
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
74
|
+
config.disable_monkey_patching!
|
75
|
+
|
76
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
77
|
+
# be too noisy due to issues in dependencies.
|
78
|
+
config.warnings = true
|
79
|
+
|
80
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
81
|
+
# file, and it's useful to allow more verbose output when running an
|
82
|
+
# individual spec file.
|
83
|
+
if config.files_to_run.one?
|
84
|
+
# Use the documentation formatter for detailed output,
|
85
|
+
# unless a formatter has already been configured
|
86
|
+
# (e.g. via a command-line flag).
|
87
|
+
config.default_formatter = "doc"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Print the 10 slowest examples and example groups at the
|
91
|
+
# end of the spec run, to help surface which specs are running
|
92
|
+
# particularly slow.
|
93
|
+
config.profile_examples = 10
|
94
|
+
|
95
|
+
# Run specs in random order to surface order dependencies. If you find an
|
96
|
+
# order dependency and want to debug it, you can fix the order by providing
|
97
|
+
# the seed, which is printed after each run.
|
98
|
+
# --seed 1234
|
99
|
+
config.order = :random
|
100
|
+
|
101
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
102
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
103
|
+
# test failures related to randomization by passing the same `--seed` value
|
104
|
+
# as the one that triggered the failure.
|
105
|
+
Kernel.srand config.seed
|
106
|
+
=end
|
107
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-bibliography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: asciidoctor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: citeproc-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: csl-styles
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: latex-decode
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.2'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bibtex-ruby
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,13 +73,27 @@ dependencies:
|
|
45
73
|
- - ">="
|
46
74
|
- !ruby/object:Gem::Version
|
47
75
|
version: '0'
|
48
|
-
type: :
|
76
|
+
type: :runtime
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - ">="
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.14'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.14'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: byebug
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +109,7 @@ dependencies:
|
|
67
109
|
- !ruby/object:Gem::Version
|
68
110
|
version: '0'
|
69
111
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
112
|
+
name: rspec
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
72
114
|
requirements:
|
73
115
|
- - ">="
|
@@ -81,7 +123,7 @@ dependencies:
|
|
81
123
|
- !ruby/object:Gem::Version
|
82
124
|
version: '0'
|
83
125
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
126
|
+
name: rake
|
85
127
|
requirement: !ruby/object:Gem::Requirement
|
86
128
|
requirements:
|
87
129
|
- - ">="
|
@@ -95,7 +137,7 @@ dependencies:
|
|
95
137
|
- !ruby/object:Gem::Version
|
96
138
|
version: '0'
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
140
|
+
name: simplecov
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
100
142
|
requirements:
|
101
143
|
- - ">="
|
@@ -121,10 +163,12 @@ extensions: []
|
|
121
163
|
extra_rdoc_files: []
|
122
164
|
files:
|
123
165
|
- ".gitignore"
|
166
|
+
- ".rspec"
|
167
|
+
- ".travis.yml"
|
124
168
|
- Gemfile
|
125
|
-
- Gemfile.lock
|
126
169
|
- LICENSE.txt
|
127
170
|
- README.adoc
|
171
|
+
- Rakefile
|
128
172
|
- SYNTAX.adoc
|
129
173
|
- asciidoctor-bibliography.gemspec
|
130
174
|
- deprecated/asciidoctor-bibliography/asciidoctor/bibliographer_postprocessor.rb
|
@@ -152,7 +196,6 @@ files:
|
|
152
196
|
- lib/asciidoctor-bibliography/helpers.rb
|
153
197
|
- lib/asciidoctor-bibliography/index.rb
|
154
198
|
- lib/asciidoctor-bibliography/version.rb
|
155
|
-
- samples/.byebug_history
|
156
199
|
- samples/biblio.bib
|
157
200
|
- samples/latex_macros_in_bibtex/reference.bib
|
158
201
|
- samples/latex_macros_in_bibtex/sample.adoc
|
@@ -160,6 +203,8 @@ files:
|
|
160
203
|
- samples/sample-authoryear.html
|
161
204
|
- samples/sample-numbers.adoc
|
162
205
|
- samples/sample-numbers.html
|
206
|
+
- spec/helpers_spec.rb
|
207
|
+
- spec/spec_helper.rb
|
163
208
|
homepage: https://github.com/riboseinc/asciidoctor-bibliography
|
164
209
|
licenses:
|
165
210
|
- MIT
|
@@ -175,9 +220,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
220
|
version: 2.0.0
|
176
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
222
|
requirements:
|
178
|
-
- - "
|
223
|
+
- - ">="
|
179
224
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
225
|
+
version: '0'
|
181
226
|
requirements: []
|
182
227
|
rubyforge_project:
|
183
228
|
rubygems_version: 2.5.2
|
data/Gemfile.lock
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
asciidoctor-bibliography (0.0.1.dev)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
asciidoctor (1.5.6.1)
|
10
|
-
bibtex-ruby (4.4.4)
|
11
|
-
latex-decode (~> 0.0)
|
12
|
-
byebug (9.0.6)
|
13
|
-
citeproc (1.0.5)
|
14
|
-
namae (~> 0.8)
|
15
|
-
citeproc-ruby (1.1.7)
|
16
|
-
citeproc (>= 1.0.4, < 2.0)
|
17
|
-
csl (~> 1.4)
|
18
|
-
csl (1.4.5)
|
19
|
-
namae (~> 0.7)
|
20
|
-
csl-styles (1.0.1.8)
|
21
|
-
csl (~> 1.0)
|
22
|
-
latex-decode (0.2.2)
|
23
|
-
unicode (~> 0.4)
|
24
|
-
namae (0.11.3)
|
25
|
-
unicode (0.4.4.4)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
asciidoctor
|
32
|
-
asciidoctor-bibliography!
|
33
|
-
bibtex-ruby
|
34
|
-
bundler (~> 1.14)
|
35
|
-
byebug
|
36
|
-
citeproc-ruby
|
37
|
-
csl-styles
|
38
|
-
latex-decode
|
39
|
-
|
40
|
-
BUNDLED WITH
|
41
|
-
1.15.3
|
data/samples/.byebug_history
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
c
|
2
|
-
q
|
3
|
-
puts processed_lines
|
4
|
-
q
|
5
|
-
puts processed_lines
|
6
|
-
processed_lines
|
7
|
-
q
|
8
|
-
puts processed_lines.lines.map(&:chomp)
|
9
|
-
processed_lines.lines.map(&:chomp)
|
10
|
-
processed_lines.lines
|
11
|
-
processed_lines
|
12
|
-
q
|
13
|
-
Helpers.html_to_asciidoc form
|
14
|
-
form
|
15
|
-
q
|
16
|
-
document.bibliographer.options
|
17
|
-
q
|
18
|
-
Hash[document_attributes]
|
19
|
-
ENV
|
20
|
-
document_attributes
|
21
|
-
document_attributes.to_hash
|
22
|
-
document_attributes.to_h
|
23
|
-
document_attributes
|
24
|
-
q
|
25
|
-
cites.first.key
|
26
|
-
cites.first
|
27
|
-
cites
|
28
|
-
q
|
29
|
-
self.macro
|
30
|
-
self
|
31
|
-
q
|
32
|
-
output
|
33
|
-
q
|
34
|
-
@closing_bracket
|
35
|
-
q
|
36
|
-
bibpunct.scan(/{.*?}/)
|
37
|
-
bibpunct.scan(/{*.?}/)
|
38
|
-
puts bibpunct
|
39
|
-
bibpunct = '{[}{\\]}{,}{n}{,}{,}'
|
40
|
-
bibpunct.length
|
41
|
-
bibpunct = '{[}{]}{,}{n}{,}{,}'
|
42
|
-
bibpunct.length
|
43
|
-
bibpunct = '{[}{\\]}{,}{n}{,}{,}'
|
44
|
-
bibpunct.scan(/{*.?}/)
|
45
|
-
bibpunct = '{[}{\\]}{,}{n}{,}{,}'
|
46
|
-
'\'
|
47
|
-
bibpunct = '{[}{\]}{,}{n}{,}{,}'
|
48
|
-
bibpunct.scan(/{*.?}/)
|
49
|
-
bibpunct = '{[}{\\]}{,}{n}{,}{,}'
|
50
|
-
bibpunct.scan(/{*.?}/)
|
51
|
-
bibpunct = '{[}{\]}{,}{n}{,}{,}'
|
52
|
-
bibpunct.scan(/{*.?}/)
|
53
|
-
bibpunct.scan(/{*.?}/).map { |s| s[1..-2] }
|
54
|
-
@closing_bracket
|
55
|
-
q
|
56
|
-
@closing_bracket
|
57
|
-
@opening_bracket
|
58
|
-
bracket "wot asd"
|
59
|
-
bracket "wot"
|
60
|
-
bracket(cetera)
|
61
|
-
label
|
62
|
-
citation.xref(cite.key, label)
|
63
|
-
output
|
64
|
-
q
|
65
|
-
y
|
66
|
-
rend
|
67
|
-
q
|
68
|
-
rend
|
69
|
-
q
|
70
|
-
rend
|
71
|
-
q
|
72
|
-
rend
|
73
|
-
q
|
74
|
-
rend
|
75
|
-
q
|
76
|
-
document.bibliographer.citations.last.cites.last.occurrence_index
|
77
|
-
document.bibliographer.citations.last.cites.last
|
78
|
-
document.bibliographer.citations.last.cites
|
79
|
-
document.bibliographer.citations.last
|
80
|
-
document.bibliographer.citations
|
81
|
-
document.bibliographer
|
82
|
-
q
|
83
|
-
citations.first.cites.first
|
84
|
-
citations.first.cites.first.target = "FOO"
|
85
|
-
citations.first.cites.first.target
|
86
|
-
citations.first.cites.first
|
87
|
-
citations.first.cites
|
88
|
-
citations.first
|
89
|
-
citations
|
90
|
-
q
|
91
|
-
document.bibliographer.citations.first.uuid
|
92
|
-
document.bibliographer.citations.first
|
93
|
-
document.bibliographer.citations
|
94
|
-
reader.lines.join("\n").lines.map(&:chomp)
|
95
|
-
reader.lines.join("\n").lines
|
96
|
-
reader.lines.join("\n")
|
97
|
-
reader.lines
|
98
|
-
reader
|
99
|
-
reader.lines
|
100
|
-
reader
|
101
|
-
q
|
102
|
-
reader.processed_lines
|
103
|
-
reader.lines
|
104
|
-
reader
|
105
|
-
processed_lines.join("\n").lines
|
106
|
-
processed_lines.join('\n').lines
|
107
|
-
processed_lines.join('\n')
|
108
|
-
processed_lines.join('"\n')
|
109
|
-
processed_lines.join
|
110
|
-
q
|
111
|
-
processed_lines
|
112
|
-
q
|
113
|
-
bibliographer.cited_keys.index(cite.key)q
|
114
|
-
bibliographer.cited_keys.index(cite.key)
|
115
|
-
bibliographer.cited_keys
|
116
|
-
bibliographer
|
117
|
-
q
|
118
|
-
document
|
119
|
-
cite
|
120
|
-
q
|
121
|
-
cite.named_attributes || {}
|
122
|
-
cite.named_attributes
|
123
|
-
extra(cite)
|
124
|
-
c
|
125
|
-
cetera
|
126
|
-
c
|
127
|
-
cetera
|
128
|
-
c
|
129
|
-
cetera
|
130
|
-
n
|
131
|
-
c
|
132
|
-
[year(cite)].concat(extra(cite)).join(@years_separator + ' ')
|
133
|
-
[year(cite)].concat(extra(cite))
|
134
|
-
q
|
135
|
-
extra
|
136
|
-
extr
|
137
|
-
q
|
138
|
-
cite.named_attributes['page']
|
139
|
-
cite.named_attributes
|
140
|
-
cite
|
141
|
-
q
|
142
|
-
y
|
143
|
-
cq
|
144
|
-
c
|
145
|
-
q
|
146
|
-
ct.key
|
147
|
-
ct
|
148
|
-
q
|
149
|
-
ct
|
150
|
-
n
|
151
|
-
ct
|
152
|
-
q
|
153
|
-
ct[:attributes][:named]['pagea']
|
154
|
-
ct[:attributes][:named]['page']
|
155
|
-
ct[:attributes][:named]['page]
|
156
|
-
ct[:attributes][:named]
|
157
|
-
ct[:named]
|
158
|
-
ct[:named]['page']
|
159
|
-
ct
|
160
|
-
q
|
161
|
-
ct[:key]
|
162
|
-
ct.key
|
163
|
-
ct
|
164
|
-
cite
|
165
|
-
ct
|
166
|
-
q
|
167
|
-
document.bibliographer.citations
|
168
|
-
q
|
169
|
-
TeXFormatter::DEFAULTS
|
170
|
-
TeXFormatter
|
171
|
-
q
|
172
|
-
@opening_bracket
|
173
|
-
bibpunct
|
174
|
-
q
|
175
|
-
Citation::DEFAULTS[cite.macro][:type]
|
176
|
-
q
|
177
|
-
Citation::DEFAULTS['citet'][:type]
|
178
|
-
Citation::DEFAULTS['citet'][:tyep]
|
179
|
-
Citation::DEFAULTS['citet']
|
180
|
-
Citation::DEFAULTS[cite.macro]
|
181
|
-
Citation::DEFAULTS[cite.macro][:type]
|
182
|
-
q
|
183
|
-
continue
|
184
|
-
Citation::DEFAULTS['citet']
|
185
|
-
Citation::DEFAULTS[:cite]
|
186
|
-
Citation::DEFAULTS['cite']
|
187
|
-
Citation::DEFAULTS
|
188
|
-
Citation
|
189
|
-
cite.macro
|
190
|
-
cite
|
191
|
-
q
|
192
|
-
c
|
193
|
-
q
|
194
|
-
[].empty?
|
195
|
-
[].blank?
|
196
|
-
[].any?
|
197
|
-
@database.find{ |h| h['id'] == ct[:key] }['issued']['date-parts'].first.first
|
198
|
-
@database.find{ |h| h['id'] == ct[:key] }['issued']['date-parts'].first
|
199
|
-
@database.find{ |h| h['id'] == ct[:key] }['issued']['date-parts']
|
200
|
-
@database.find{ |h| h['id'] == ct[:key] }['issued']
|
201
|
-
@database.find{ |h| h['id'] == ct[:key] }
|
202
|
-
ct
|
203
|
-
q
|
204
|
-
continue
|
205
|
-
c
|
206
|
-
q
|
207
|
-
cite
|
208
|
-
q
|
209
|
-
Helpers.to_sentence(authors_family_names)
|
210
|
-
n
|
211
|
-
Helpers.to_sentence(authors_family_names)
|
212
|
-
q
|
213
|
-
Helpers.to_sentence(authors_family_names)
|
214
|
-
n
|
215
|
-
c
|
216
|
-
ci.key
|
217
|
-
ci
|
218
|
-
c
|
219
|
-
cite.cites
|
220
|
-
cite
|
221
|
-
c
|
222
|
-
@database.find{ |h| h['id'] == 'asd' }
|
223
|
-
@database.find{ |h| h['id'] == c.key }
|
224
|
-
@database.find{ |h| h['id'] == c.key }['author']
|
225
|
-
q
|
226
|
-
cite.cites.first[:key]
|
227
|
-
cite.cites.first['key']
|
228
|
-
cite.cites
|
229
|
-
cite.cites.key
|
230
|
-
cite
|
231
|
-
@database.find { |h| h['id'] == 'Anderson04' }['author'].map { |h| h['family'] }.compact
|
232
|
-
@database.find { |h| h['id'] == 'Anderson04' }['author'].map { |h| h['family'] }
|
233
|
-
@database.find { |h| h['id'] == 'Anderson04' }['author']
|
234
|
-
@database.find { |h| h['id'] == 'Anderson04' }
|
235
|
-
self.find { |h| h['id'] == 'Anderson04' }
|
236
|
-
@database.
|
237
|
-
cite
|
238
|
-
q
|
239
|
-
c
|
240
|
-
q
|
241
|
-
self.find { |h| h['id'] == 'Lane12a' }
|
242
|
-
self.find(id: 'Lane12a').first
|
243
|
-
self.find(id: 'Lane12a')
|
244
|
-
self.find
|
245
|
-
self
|