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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a54dc9ae017f2210a577ed1f065f62fb012ac6d8
4
- data.tar.gz: 5e382f6eaf3989f42feb0a8b90f1dcf1d1289d08
3
+ metadata.gz: 5a347f15409faab328c514fa0f6e63e3f583af11
4
+ data.tar.gz: 0b6b7cba4b713bb56415d847f3d4ef385d0bb85e
5
5
  SHA512:
6
- metadata.gz: dcaaba5e5312d238298156007f7d73180f63c45903eba25079e491779265bcf84f4c95ad23bbc00e4808c97e72e3b0a92c15efec44590b0b2b3b41cd4ee4634f
7
- data.tar.gz: '0089c34a2ffd99fdf2838a87cd58b99fd85c279932960f0f7ec3e46b7fa6e97e819803cbd3499aab666cb1bac77d73224d3ad7e14ab50d122b51aef74901e04d'
6
+ metadata.gz: 19c0a0935001b19eccf5b76e9b0453e9ac81888e27fbdfffc47929bde2d0580ae7cd80b4ec19a7e8c82ec62c06261d694371fe5f30ec9c4c47dc1b9d86e2848a
7
+ data.tar.gz: 1c6f3ca017bd84ffd4ac2a649717a57abab9882c3aa1995e743563988c3c350a511e794d2941b6b155cf6859bb77b9ee69d889c56c3de405d1b5de99d454c19e
@@ -78,7 +78,7 @@ Style/Encoding:
78
78
  SupportedStyles:
79
79
  - when_needed
80
80
  - always
81
- Style/FileName:
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
- Style/MethodName:
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
- Style/PredicateName:
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
- Style/VariableName:
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
- Style/AccessorMethodName:
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
- Style/AsciiIdentifiers:
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
- Style/ClassAndModuleCamelCase:
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
- Style/ConstantName:
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 = <<~END
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
- END
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 document.bibliographer.options.database
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, :locators
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(*filenames)
8
- filenames.each do |filename|
9
- append filename
7
+ def initialize(*filepaths)
8
+ filepaths.each do |filepath|
9
+ append filepath
10
10
  end
11
11
  end
12
12
 
13
- def append(filename)
14
- concat Database.load(filename)
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(filename)
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
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorBibliography
2
- VERSION = "0.4.3".freeze
2
+ VERSION = "0.4.4".freeze
3
3
  end
@@ -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.3
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-09-30 00:00:00.000000000 Z
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