asciidoctor-bibliography 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.oss-guides.rubocop.yml +8 -12
- data/.travis.yml +8 -0
- data/asciidoctor-bibliography.gemspec +3 -2
- data/lib/asciidoctor-bibliography/asciidoctor/bibliographer_preprocessor.rb +5 -1
- data/lib/asciidoctor-bibliography/citation.rb +2 -1
- data/lib/asciidoctor-bibliography/citation_item.rb +1 -1
- data/lib/asciidoctor-bibliography/database.rb +6 -7
- data/lib/asciidoctor-bibliography/version.rb +1 -1
- data/spec/sanity_spec.rb +120 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a347f15409faab328c514fa0f6e63e3f583af11
|
4
|
+
data.tar.gz: 0b6b7cba4b713bb56415d847f3d4ef385d0bb85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c0a0935001b19eccf5b76e9b0453e9ac81888e27fbdfffc47929bde2d0580ae7cd80b4ec19a7e8c82ec62c06261d694371fe5f30ec9c4c47dc1b9d86e2848a
|
7
|
+
data.tar.gz: 1c6f3ca017bd84ffd4ac2a649717a57abab9882c3aa1995e743563988c3c350a511e794d2941b6b155cf6859bb77b9ee69d889c56c3de405d1b5de99d454c19e
|
data/.oss-guides.rubocop.yml
CHANGED
@@ -78,7 +78,7 @@ Style/Encoding:
|
|
78
78
|
SupportedStyles:
|
79
79
|
- when_needed
|
80
80
|
- always
|
81
|
-
|
81
|
+
Naming/FileName:
|
82
82
|
Description: Use snake_case for source file names.
|
83
83
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
84
84
|
Enabled: false
|
@@ -159,7 +159,7 @@ Style/MethodDefParentheses:
|
|
159
159
|
SupportedStyles:
|
160
160
|
- require_parentheses
|
161
161
|
- require_no_parentheses
|
162
|
-
|
162
|
+
Naming/MethodName:
|
163
163
|
Description: Use the configured style when naming methods.
|
164
164
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
|
165
165
|
Enabled: true
|
@@ -200,7 +200,7 @@ Style/PercentQLiterals:
|
|
200
200
|
SupportedStyles:
|
201
201
|
- lower_case_q
|
202
202
|
- upper_case_q
|
203
|
-
|
203
|
+
Naming/PredicateName:
|
204
204
|
Description: Check the names of predicate methods.
|
205
205
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
206
206
|
Enabled: true
|
@@ -321,7 +321,7 @@ Style/TrivialAccessors:
|
|
321
321
|
- to_str
|
322
322
|
- to_s
|
323
323
|
- to_sym
|
324
|
-
|
324
|
+
Naming/VariableName:
|
325
325
|
Description: Use the configured style when naming variables.
|
326
326
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
|
327
327
|
Enabled: true
|
@@ -460,7 +460,7 @@ Style/SymbolArray:
|
|
460
460
|
Description: Use %i or %I for arrays of symbols.
|
461
461
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-i
|
462
462
|
Enabled: false
|
463
|
-
|
463
|
+
Naming/AccessorMethodName:
|
464
464
|
Description: Check the naming of accessor methods for get_/set_.
|
465
465
|
Enabled: false
|
466
466
|
Style/Alias:
|
@@ -475,7 +475,7 @@ Style/AsciiComments:
|
|
475
475
|
Description: Use only ascii symbols in comments.
|
476
476
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-comments
|
477
477
|
Enabled: false
|
478
|
-
|
478
|
+
Naming/AsciiIdentifiers:
|
479
479
|
Description: Use only ascii symbols in identifiers.
|
480
480
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-identifiers
|
481
481
|
Enabled: false
|
@@ -504,7 +504,7 @@ Style/CharacterLiteral:
|
|
504
504
|
Description: Checks for uses of character literals.
|
505
505
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-character-literals
|
506
506
|
Enabled: false
|
507
|
-
|
507
|
+
Naming/ClassAndModuleCamelCase:
|
508
508
|
Description: Use CamelCase for classes and modules.
|
509
509
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#camelcase-classes
|
510
510
|
Enabled: true
|
@@ -520,7 +520,7 @@ Style/ColonMethodCall:
|
|
520
520
|
Description: 'Do not use :: for method call.'
|
521
521
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#double-colons
|
522
522
|
Enabled: false
|
523
|
-
|
523
|
+
Naming/ConstantName:
|
524
524
|
Description: Constants should use SCREAMING_SNAKE_CASE.
|
525
525
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#screaming-snake-case
|
526
526
|
Enabled: true
|
@@ -613,10 +613,6 @@ Style/OneLineConditional:
|
|
613
613
|
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
614
614
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
615
615
|
Enabled: false
|
616
|
-
Style/OpMethod:
|
617
|
-
Description: When defining binary operators, name the argument other.
|
618
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#other-arg
|
619
|
-
Enabled: false
|
620
616
|
Style/PerlBackrefs:
|
621
617
|
Description: Avoid Perl-style regex back references.
|
622
618
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
data/.travis.yml
CHANGED
@@ -2,3 +2,11 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
4
|
- 2.3.0
|
5
|
+
before_script:
|
6
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
7
|
+
- chmod +x ./cc-test-reporter
|
8
|
+
- ./cc-test-reporter before-build
|
9
|
+
script:
|
10
|
+
- bundle exec rspec
|
11
|
+
after_script:
|
12
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
11
11
|
spec.email = ["open.source@ribose.com"]
|
12
12
|
|
13
13
|
spec.summary = 'Citations and bibliography the "asciidoctor-way"'
|
14
|
-
spec.description = <<~
|
14
|
+
spec.description = <<~SPEC
|
15
15
|
asciidoctor-bibliography lets you handle citations and bibliography the "asciidoctor-way"!
|
16
16
|
|
17
17
|
Its syntax is designed to be native-asciidoctor:
|
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
24
24
|
Citation output styles are fully bridged to the CSL library, supporting formats such as IEEE, APA, Chicago, DIN and ISO 690.
|
25
25
|
|
26
26
|
The `bibliography::[]` command generates a full reference list that adheres to your configured citation style.
|
27
|
-
|
27
|
+
SPEC
|
28
|
+
|
28
29
|
spec.homepage = "https://github.com/riboseinc/asciidoctor-bibliography"
|
29
30
|
spec.license = "MIT"
|
30
31
|
|
@@ -12,8 +12,12 @@ module AsciidoctorBibliography
|
|
12
12
|
document.bibliographer.options =
|
13
13
|
::AsciidoctorBibliography::Options.new_from_reader reader
|
14
14
|
|
15
|
+
database_filepath =
|
16
|
+
File.expand_path document.bibliographer.options.database,
|
17
|
+
document.base_dir
|
18
|
+
|
15
19
|
document.bibliographer.database =
|
16
|
-
::AsciidoctorBibliography::Database.new
|
20
|
+
::AsciidoctorBibliography::Database.new database_filepath
|
17
21
|
|
18
22
|
processed_lines = process_lines reader.read_lines, document.bibliographer
|
19
23
|
reader.unshift_lines processed_lines
|
@@ -20,13 +20,14 @@ module AsciidoctorBibliography
|
|
20
20
|
@uuid = SecureRandom.uuid
|
21
21
|
@macro = macro
|
22
22
|
@citation_items = []
|
23
|
+
# rubocop:disable Performance/HashEachMethods
|
23
24
|
target_and_attributes_list_pairs.compact.each_slice(2).each do |_target, attribute_list|
|
24
25
|
@citation_items << CitationItem.new do |cite|
|
25
26
|
# NOTE: we're not doing anything with targets right now.
|
26
|
-
# cite.target = _target
|
27
27
|
cite.parse_attribute_list attribute_list
|
28
28
|
end
|
29
29
|
end
|
30
|
+
# rubocop:enable Performance/HashEachMethods
|
30
31
|
end
|
31
32
|
|
32
33
|
def render(bibliographer)
|
@@ -4,7 +4,7 @@ module AsciidoctorBibliography
|
|
4
4
|
class CitationItem
|
5
5
|
LOCATORS = CiteProc::CitationItem.labels.map(&:to_s).push("locator").freeze
|
6
6
|
|
7
|
-
attr_accessor :key, :target, :positional_attributes, :named_attributes
|
7
|
+
attr_accessor :key, :target, :positional_attributes, :named_attributes
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
yield self if block_given?
|
@@ -4,14 +4,14 @@ require_relative "errors"
|
|
4
4
|
module AsciidoctorBibliography
|
5
5
|
# This is an array of citeproc entries.
|
6
6
|
class Database < Array
|
7
|
-
def initialize(*
|
8
|
-
|
9
|
-
append
|
7
|
+
def initialize(*filepaths)
|
8
|
+
filepaths.each do |filepath|
|
9
|
+
append filepath
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def append(
|
14
|
-
concat Database.load(
|
13
|
+
def append(filepath)
|
14
|
+
concat Database.load(filepath)
|
15
15
|
end
|
16
16
|
|
17
17
|
def find_entry_by_id(id)
|
@@ -23,8 +23,7 @@ module AsciidoctorBibliography
|
|
23
23
|
result
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.load(
|
27
|
-
filepath = File.expand_path filename
|
26
|
+
def self.load(filepath)
|
28
27
|
raise Errors::Database::FileNotFound, filepath unless File.exist?(filepath)
|
29
28
|
|
30
29
|
fileext = File.extname filepath
|
data/spec/sanity_spec.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require "asciidoctor"
|
2
|
+
|
3
|
+
def setup_tmpdir(method_name = :tmpdir)
|
4
|
+
let(method_name) { File.join Dir.tmpdir, "asciidoctor-bibliography_tests" }
|
5
|
+
|
6
|
+
around(:each) do |example|
|
7
|
+
FileUtils.rm_rf method(method_name).call
|
8
|
+
FileUtils.mkdir_p method(method_name).call
|
9
|
+
example.run
|
10
|
+
FileUtils.rm_rf method(method_name).call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup_main_document(_path, content)
|
15
|
+
input_path = File.join(tmpdir, "main.adoc")
|
16
|
+
output_path = File.join(tmpdir, "main.html")
|
17
|
+
File.open(input_path, "w") { |file| file.write content }
|
18
|
+
[input_path, output_path]
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup_file(_path, name, content)
|
22
|
+
File.open(File.join(tmpdir, name), "w") { |file| file.write content }
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_bibliography(content)
|
26
|
+
let(:bibliography_path) do
|
27
|
+
File.join(tmpdir, "bibliography.bibtex")
|
28
|
+
end
|
29
|
+
|
30
|
+
before do
|
31
|
+
File.open(bibliography_path, "w") { |file| file.write content }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "asciidoctor integration" do
|
36
|
+
setup_tmpdir
|
37
|
+
|
38
|
+
setup_bibliography <<~BIBTEX
|
39
|
+
@article{Foo00,
|
40
|
+
author = {Foo Bar},
|
41
|
+
title = {Title},
|
42
|
+
publisher = {Publisher},
|
43
|
+
year = {2000}
|
44
|
+
}
|
45
|
+
BIBTEX
|
46
|
+
|
47
|
+
describe "testing procedure" do
|
48
|
+
it "works in the trivial case" do
|
49
|
+
input_path, output_path = setup_main_document tmpdir, <<~'ADOC'
|
50
|
+
Hello World.
|
51
|
+
ADOC
|
52
|
+
|
53
|
+
expect { `asciidoctor #{input_path}` }.to_not raise_exception
|
54
|
+
expect(File.read(output_path)).to match <<~'BODY'
|
55
|
+
<div id="content">
|
56
|
+
<div class="paragraph">
|
57
|
+
<p>Hello World.</p>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
BODY
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "single file usage" do
|
65
|
+
it "works with a single file, a citation and the bibliography" do
|
66
|
+
input_path, output_path = setup_main_document tmpdir, <<~ADOC
|
67
|
+
:bibliography-database: #{bibliography_path}
|
68
|
+
|
69
|
+
Hello World. cite:[Foo00]
|
70
|
+
|
71
|
+
bibliography::[]
|
72
|
+
ADOC
|
73
|
+
|
74
|
+
expect { `asciidoctor -r asciidoctor-bibliography #{input_path} --trace` }.to_not raise_exception
|
75
|
+
expect(File.read(output_path)).to include <<~'BODY'
|
76
|
+
<div id="content">
|
77
|
+
<div class="paragraph">
|
78
|
+
<p>Hello World. (<a href="#bibliography-Foo00">Bar, 2000</a>)</p>
|
79
|
+
</div>
|
80
|
+
<div class="paragraph">
|
81
|
+
<p><a id="bibliography-Foo00"></a>Bar, F. (2000). Title.</p>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
BODY
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "nested files usage" do
|
89
|
+
it "works with a single file, a citation and the bibliography" do
|
90
|
+
setup_file tmpdir, "nested.adoc", <<~ADOC
|
91
|
+
This is content from a nested file. cite:[Foo00]
|
92
|
+
|
93
|
+
bibliography::[]
|
94
|
+
ADOC
|
95
|
+
|
96
|
+
input_path, output_path = setup_main_document tmpdir, <<~ADOC
|
97
|
+
:bibliography-database: #{bibliography_path}
|
98
|
+
|
99
|
+
Hello World. cite:[Foo00]
|
100
|
+
|
101
|
+
include::nested.adoc[]
|
102
|
+
ADOC
|
103
|
+
|
104
|
+
expect { `asciidoctor -r asciidoctor-bibliography #{input_path} --trace` }.to_not raise_exception
|
105
|
+
expect(File.read(output_path)).to include <<~'BODY'
|
106
|
+
<div id="content">
|
107
|
+
<div class="paragraph">
|
108
|
+
<p>Hello World. (<a href="#bibliography-Foo00">Bar, 2000</a>)</p>
|
109
|
+
</div>
|
110
|
+
<div class="paragraph">
|
111
|
+
<p>This is content from a nested file. (<a href="#bibliography-Foo00">Bar, 2000</a>)</p>
|
112
|
+
</div>
|
113
|
+
<div class="paragraph">
|
114
|
+
<p><a id="bibliography-Foo00"></a>Bar, F. (2000). Title.</p>
|
115
|
+
</div>
|
116
|
+
</div>
|
117
|
+
BODY
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
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.4.
|
4
|
+
version: 0.4.4
|
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-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -297,6 +297,7 @@ files:
|
|
297
297
|
- spec/fixtures/database.unk
|
298
298
|
- spec/macros_spec.rb
|
299
299
|
- spec/options_spec.rb
|
300
|
+
- spec/sanity_spec.rb
|
300
301
|
- spec/spec_helper.rb
|
301
302
|
- spec/throwaway_spec.rb
|
302
303
|
homepage: https://github.com/riboseinc/asciidoctor-bibliography
|