middleman-bibtex 0.1.0 → 0.2.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 +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +8 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +63 -43
- data/README.md +21 -25
- data/Rakefile +10 -1
- data/lib/middleman-bibtex/version.rb +2 -1
- data/lib/middleman-bibtex.rb +47 -28
- data/middleman-bibtex.gemspec +2 -2
- data/spec/bibtex_spec.rb +128 -0
- data/spec/fixtures/test.bib +27 -0
- data/spec/spec_helper.rb +3 -0
- metadata +15 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22a56b668bb2b8aea72faf37588cece920981b6b
|
|
4
|
+
data.tar.gz: 8bc2db3cb2a7cf7669124b50587cb7a00695d0f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bbcb96d3e16132359d1f1139414ba11edbd1d91f7e6fcb9452a99c54dd9b29d1848b855e0a55d181d86c97f4ea45a87138525924d3fdc84899956df9247e8bb
|
|
7
|
+
data.tar.gz: 6d127f13911ad968fb58e0cf21f1a66933ac6a52282a08ba8789cf5c0c843666ee08a60c8a60850ef02dd4464cf7726c5b80ae10ad0b09a2d22eb981e7f4b8dd
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
middleman-
|
|
4
|
+
middleman-bibtex (0.2.0)
|
|
5
5
|
bibtex-ruby
|
|
6
6
|
citeproc-ruby (~> 0.0.6)
|
|
7
7
|
middleman-core (~> 3)
|
|
@@ -9,80 +9,100 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (4.
|
|
13
|
-
i18n (~> 0.
|
|
12
|
+
activesupport (4.2.5.2)
|
|
13
|
+
i18n (~> 0.7)
|
|
14
14
|
json (~> 1.7, >= 1.7.7)
|
|
15
15
|
minitest (~> 5.1)
|
|
16
|
-
thread_safe (~> 0.
|
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
17
17
|
tzinfo (~> 1.1)
|
|
18
|
-
bibtex-ruby (4.0
|
|
18
|
+
bibtex-ruby (4.2.0)
|
|
19
19
|
latex-decode (~> 0.0)
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
capybara (2.4.4)
|
|
21
|
+
mime-types (>= 1.16)
|
|
22
|
+
nokogiri (>= 1.3.3)
|
|
23
|
+
rack (>= 1.0.0)
|
|
24
|
+
rack-test (>= 0.5.4)
|
|
25
|
+
xpath (~> 2.0)
|
|
22
26
|
citeproc-ruby (0.0.6)
|
|
23
27
|
logging (~> 1.5)
|
|
24
28
|
nokogiri (~> 1.5)
|
|
29
|
+
diff-lcs (1.2.5)
|
|
25
30
|
erubis (2.7.0)
|
|
26
|
-
ffi (1.9.
|
|
27
|
-
hooks (0.4.
|
|
28
|
-
uber (~> 0.0.
|
|
29
|
-
i18n (0.
|
|
30
|
-
json (1.8.
|
|
31
|
-
latex-decode (0.
|
|
31
|
+
ffi (1.9.10)
|
|
32
|
+
hooks (0.4.1)
|
|
33
|
+
uber (~> 0.0.14)
|
|
34
|
+
i18n (0.7.0)
|
|
35
|
+
json (1.8.3)
|
|
36
|
+
latex-decode (0.2.2)
|
|
32
37
|
unicode (~> 0.4)
|
|
33
|
-
listen (
|
|
34
|
-
celluloid (>= 0.15.2)
|
|
38
|
+
listen (3.0.6)
|
|
35
39
|
rb-fsevent (>= 0.9.3)
|
|
36
|
-
rb-inotify (>= 0.9)
|
|
37
|
-
little-plugger (1.1.
|
|
40
|
+
rb-inotify (>= 0.9.7)
|
|
41
|
+
little-plugger (1.1.4)
|
|
38
42
|
logging (1.8.2)
|
|
39
43
|
little-plugger (>= 1.1.3)
|
|
40
44
|
multi_json (>= 1.8.4)
|
|
41
|
-
middleman-core (3.
|
|
42
|
-
activesupport (~> 4.1
|
|
45
|
+
middleman-core (3.4.1)
|
|
46
|
+
activesupport (~> 4.1)
|
|
43
47
|
bundler (~> 1.1)
|
|
48
|
+
capybara (~> 2.4.4)
|
|
44
49
|
erubis
|
|
45
50
|
hooks (~> 0.3)
|
|
46
|
-
i18n (~> 0.
|
|
47
|
-
listen (
|
|
51
|
+
i18n (~> 0.7.0)
|
|
52
|
+
listen (~> 3.0.3)
|
|
48
53
|
padrino-helpers (~> 0.12.3)
|
|
49
54
|
rack (>= 1.4.5, < 2.0)
|
|
50
|
-
rack-test (~> 0.6.2)
|
|
51
55
|
thor (>= 0.15.2, < 2.0)
|
|
52
56
|
tilt (~> 1.4.1, < 2.0)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
mime-types (3.0)
|
|
58
|
+
mime-types-data (~> 3.2015)
|
|
59
|
+
mime-types-data (3.2016.0221)
|
|
60
|
+
mini_portile2 (2.0.0)
|
|
61
|
+
minitest (5.8.4)
|
|
62
|
+
multi_json (1.11.2)
|
|
63
|
+
nokogiri (1.6.7.2)
|
|
64
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
65
|
+
padrino-helpers (0.12.5)
|
|
59
66
|
i18n (~> 0.6, >= 0.6.7)
|
|
60
|
-
padrino-support (= 0.12.
|
|
67
|
+
padrino-support (= 0.12.5)
|
|
61
68
|
tilt (~> 1.4.1)
|
|
62
|
-
padrino-support (0.12.
|
|
69
|
+
padrino-support (0.12.5)
|
|
63
70
|
activesupport (>= 3.1)
|
|
64
|
-
rack (1.
|
|
65
|
-
rack-test (0.6.
|
|
71
|
+
rack (1.6.4)
|
|
72
|
+
rack-test (0.6.3)
|
|
66
73
|
rack (>= 1.0)
|
|
67
|
-
rake (10.
|
|
68
|
-
rb-fsevent (0.9.
|
|
69
|
-
rb-inotify (0.9.
|
|
74
|
+
rake (10.5.0)
|
|
75
|
+
rb-fsevent (0.9.7)
|
|
76
|
+
rb-inotify (0.9.7)
|
|
70
77
|
ffi (>= 0.5.0)
|
|
78
|
+
rspec (3.4.0)
|
|
79
|
+
rspec-core (~> 3.4.0)
|
|
80
|
+
rspec-expectations (~> 3.4.0)
|
|
81
|
+
rspec-mocks (~> 3.4.0)
|
|
82
|
+
rspec-core (3.4.3)
|
|
83
|
+
rspec-support (~> 3.4.0)
|
|
84
|
+
rspec-expectations (3.4.0)
|
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
86
|
+
rspec-support (~> 3.4.0)
|
|
87
|
+
rspec-mocks (3.4.1)
|
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
89
|
+
rspec-support (~> 3.4.0)
|
|
90
|
+
rspec-support (3.4.1)
|
|
71
91
|
thor (0.19.1)
|
|
72
|
-
thread_safe (0.3.
|
|
92
|
+
thread_safe (0.3.5)
|
|
73
93
|
tilt (1.4.1)
|
|
74
|
-
timers (1.1.0)
|
|
75
94
|
tzinfo (1.2.2)
|
|
76
95
|
thread_safe (~> 0.1)
|
|
77
|
-
uber (0.0.
|
|
78
|
-
unicode (0.4.4.
|
|
79
|
-
|
|
96
|
+
uber (0.0.15)
|
|
97
|
+
unicode (0.4.4.2)
|
|
98
|
+
xpath (2.0.0)
|
|
99
|
+
nokogiri (~> 1.3)
|
|
80
100
|
|
|
81
101
|
PLATFORMS
|
|
82
102
|
ruby
|
|
83
103
|
|
|
84
104
|
DEPENDENCIES
|
|
85
|
-
bundler
|
|
86
|
-
middleman-
|
|
105
|
+
bundler
|
|
106
|
+
middleman-bibtex!
|
|
87
107
|
rake
|
|
88
|
-
|
|
108
|
+
rspec
|
data/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
# Middleman-
|
|
1
|
+
# Middleman-bibtex
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
site generator
|
|
5
|
-
|
|
3
|
+
An extension for the [Middleman](http://middlemanapp.com/) static
|
|
4
|
+
site generator for formating BibTeX bibliographies. This is a fork
|
|
5
|
+
of the extension
|
|
6
|
+
[middleman-citation](https://github.com/gabysbrain/middleman-citation)
|
|
7
|
+
which offers similar functionailty.
|
|
6
8
|
|
|
7
9
|
An example of a Middleman template using this plugin is available at
|
|
8
|
-
<
|
|
10
|
+
<http://soliton.vm.bytemark.co.uk/pub/jjg/en/mathematics/papers/>.
|
|
9
11
|
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
12
14
|
Add this line to your Gemfile:
|
|
13
15
|
|
|
14
|
-
gem 'middleman-
|
|
16
|
+
gem 'middleman-bibtex'
|
|
15
17
|
|
|
16
18
|
And then execute:
|
|
17
19
|
|
|
@@ -19,18 +21,18 @@ And then execute:
|
|
|
19
21
|
|
|
20
22
|
Or install it yourself as:
|
|
21
23
|
|
|
22
|
-
$ gem install middleman-
|
|
24
|
+
$ gem install middleman-bibtex
|
|
23
25
|
|
|
24
26
|
## Configuration
|
|
25
27
|
|
|
26
28
|
In your `config.rb` file for your site add:
|
|
27
29
|
|
|
28
|
-
require 'middleman-
|
|
30
|
+
require 'middleman-bibtex'
|
|
29
31
|
|
|
30
|
-
activate :
|
|
31
|
-
opts.
|
|
32
|
-
opts.style
|
|
33
|
-
opts.format = 'html'
|
|
32
|
+
activate :bibtex do |opts|
|
|
33
|
+
opts.path = '/path/to/your.bib' # path to a bibtex file
|
|
34
|
+
opts.style = 'ieee' # style from citeproc-styles
|
|
35
|
+
opts.format = 'html' # output format
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
## Usage
|
|
@@ -50,32 +52,26 @@ templates.
|
|
|
50
52
|
For extra control on the output, one can use:
|
|
51
53
|
|
|
52
54
|
* `citation_entry(key)`: Return the unformatted entry (a hash)
|
|
53
|
-
corresponding to the BibTeX citation key.
|
|
55
|
+
corresponding to the BibTeX citation key.
|
|
54
56
|
|
|
55
57
|
* `citation_formatted(entry)`: Format an unformatted entry.
|
|
56
58
|
|
|
57
59
|
In fact the `citation` method is implemented using these:
|
|
58
60
|
|
|
59
61
|
def citation(key)
|
|
60
|
-
|
|
61
|
-
citation_formatted(entry)
|
|
62
|
+
citation_formatted(citation_entry(key))
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
The point is that one can interrogate the unformatted entry to
|
|
65
66
|
add extra formatting: The following code adds a DOI link if the
|
|
66
67
|
entry matching the `key` has a `URL` field containing the DOI.
|
|
67
68
|
|
|
68
|
-
entry
|
|
69
|
+
entry = citation_entry(key)
|
|
69
70
|
entry_html = citation_formatted(entry)
|
|
70
|
-
|
|
71
|
-
doi_link =
|
|
71
|
+
unless (doi_url = entry['URL']).nil? then
|
|
72
|
+
doi_link = format('(%s)', link_to('doi', doi_url))
|
|
72
73
|
end
|
|
73
74
|
[entry_html, doi_link].compact.join(' ')
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
1. Fork it
|
|
78
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
79
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
80
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
81
|
-
5. Create new Pull Request
|
|
76
|
+
[](https://badge.fury.io/rb/middleman-bibtex)
|
|
77
|
+
[](https://travis-ci.org/jjgreen/middleman-bibtex)
|
data/Rakefile
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
desc 'run rspec tests'
|
|
5
|
+
RSpec::Core::RakeTask.new do |spec|
|
|
6
|
+
spec.pattern = 'spec/*_spec.rb'
|
|
7
|
+
spec.rspec_opts = ['--color', '--format', 'documentation']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require 'rake/clean'
|
data/lib/middleman-bibtex.rb
CHANGED
|
@@ -3,58 +3,77 @@ require 'middleman-core'
|
|
|
3
3
|
require 'bibtex'
|
|
4
4
|
require 'citeproc'
|
|
5
5
|
|
|
6
|
+
module BibtexHelper
|
|
7
|
+
extend self
|
|
8
|
+
|
|
9
|
+
def citations_search(bib, search_key, author = nil)
|
|
10
|
+
entries_matching_key = bib.query(search_key)
|
|
11
|
+
entries =
|
|
12
|
+
if author then
|
|
13
|
+
search_by_author(entries_matching_key, author)
|
|
14
|
+
else
|
|
15
|
+
entries_matching_key
|
|
16
|
+
end
|
|
17
|
+
entries
|
|
18
|
+
.sort_by { |x| x.year.to_i }
|
|
19
|
+
.map(&:key)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def citation_formatted(entry, style, format)
|
|
23
|
+
CiteProc.process(entry, :style => style, :format => format)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def citation_entry(bib, key)
|
|
27
|
+
unless entry = bib[key] then
|
|
28
|
+
message = format('No entry for key %s', key)
|
|
29
|
+
raise Middleman::Bibtex::KeyNotFound, message
|
|
30
|
+
end
|
|
31
|
+
entry.convert_latex.to_citeproc
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def search_by_author(entries, author)
|
|
35
|
+
bib_author = BibTeX::Name.parse(author)
|
|
36
|
+
entries.select do |e|
|
|
37
|
+
e.respond_to?(:author) &&
|
|
38
|
+
e.author &&
|
|
39
|
+
e.author.include?(bib_author)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
6
45
|
module Middleman
|
|
7
46
|
|
|
8
47
|
class BibtexExtension < Middleman::Extension
|
|
9
48
|
|
|
10
|
-
option :
|
|
49
|
+
option :path, nil, 'Path to the bibtex file'
|
|
11
50
|
option :style, 'chicago-author-date', 'BibTeX style'
|
|
12
51
|
option :format, 'html', 'Bibliography format'
|
|
13
52
|
|
|
14
|
-
def initialize(app, options_hash={}, &block)
|
|
53
|
+
def initialize(app, options_hash = {}, &block)
|
|
15
54
|
super
|
|
16
|
-
app.set(:
|
|
17
|
-
app.set(:cite_style,
|
|
55
|
+
app.set(:bib, BibTeX.open(options.path))
|
|
56
|
+
app.set(:cite_style, options.style)
|
|
18
57
|
app.set(:cite_format, options.format)
|
|
19
58
|
end
|
|
20
59
|
|
|
21
60
|
helpers do
|
|
22
61
|
|
|
23
62
|
def citations_search(search_key, author = nil)
|
|
24
|
-
|
|
25
|
-
entries =
|
|
26
|
-
if author then
|
|
27
|
-
search_by_author(entries_matching_key, author)
|
|
28
|
-
else
|
|
29
|
-
entries_matching_key
|
|
30
|
-
end
|
|
31
|
-
entries.sort { |x, y| y.year.to_i <=> x.year.to_i }.map(&:key)
|
|
63
|
+
BibtexHelper.citation_search(bib, search_key, author)
|
|
32
64
|
end
|
|
33
65
|
|
|
34
66
|
def citation_entry(key)
|
|
35
|
-
|
|
67
|
+
BibtexHelper.citation_entry(bib, key)
|
|
36
68
|
end
|
|
37
69
|
|
|
38
70
|
def citation_formatted(entry)
|
|
39
|
-
|
|
71
|
+
BibtexHelper.citation_formatted(entry, cite_style, cite_format)
|
|
40
72
|
end
|
|
41
73
|
|
|
42
74
|
def citation(key)
|
|
43
|
-
|
|
44
|
-
citation_formatted(entry)
|
|
75
|
+
citation_formatted(citation_entry(key))
|
|
45
76
|
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def search_by_author(entries, author)
|
|
50
|
-
bib_author = BibTeX::Name.parse(author)
|
|
51
|
-
entries.select do |e|
|
|
52
|
-
e.respond_to?(:author) &&
|
|
53
|
-
e.author &&
|
|
54
|
-
e.author.include?(bib_author)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
77
|
end
|
|
59
78
|
end
|
|
60
79
|
end
|
data/middleman-bibtex.gemspec
CHANGED
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_runtime_dependency 'citeproc-ruby', ['~> 0.0.6']
|
|
26
26
|
spec.add_runtime_dependency 'middleman-core', ['~> 3']
|
|
27
27
|
|
|
28
|
-
spec.add_development_dependency 'bundler'
|
|
28
|
+
spec.add_development_dependency 'bundler'
|
|
29
29
|
spec.add_development_dependency 'rake'
|
|
30
|
-
spec.add_development_dependency '
|
|
30
|
+
spec.add_development_dependency 'rspec'
|
|
31
31
|
end
|
data/spec/bibtex_spec.rb
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'bibtex'
|
|
2
|
+
require 'middleman-bibtex'
|
|
3
|
+
require_relative 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe BibtexHelper, 'helpers' do
|
|
6
|
+
let(:bib){ BibTeX.open(fixture('test.bib'), :filter => :latex) }
|
|
7
|
+
|
|
8
|
+
describe 'citation_entry' do
|
|
9
|
+
|
|
10
|
+
context 'for a key not in the bibliography' do
|
|
11
|
+
|
|
12
|
+
it 'should raise' do
|
|
13
|
+
expect {
|
|
14
|
+
BibtexHelper.citation_entry(bib, 'no-such')
|
|
15
|
+
}.to raise_error(Middleman::Bibtex::KeyNotFound)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context 'for a key in the bibliography' do
|
|
20
|
+
|
|
21
|
+
it 'should not raise' do
|
|
22
|
+
expect {
|
|
23
|
+
BibtexHelper.citation_entry(bib, 'godel:1933')
|
|
24
|
+
}.to_not raise_error
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'the return value' do
|
|
28
|
+
let(:result) { BibtexHelper.citation_entry(bib, 'godel:1933') }
|
|
29
|
+
|
|
30
|
+
it 'should be a Hash' do
|
|
31
|
+
expect(result).to be_a Hash
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'should have the expected keys' do
|
|
35
|
+
expect(result.keys)
|
|
36
|
+
.to match_array ['author',
|
|
37
|
+
'container-title',
|
|
38
|
+
'id',
|
|
39
|
+
'issued',
|
|
40
|
+
'page',
|
|
41
|
+
'title',
|
|
42
|
+
'type',
|
|
43
|
+
'volume']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should correctly split the author name' do
|
|
47
|
+
expect(result['author'])
|
|
48
|
+
.to match_array [ {'family' => 'Gödel', 'given' => 'K.'} ]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe 'citation_formatted' do
|
|
55
|
+
let(:entry) { BibtexHelper.citation_entry(bib, 'godel:1933') }
|
|
56
|
+
let(:result) { BibtexHelper.citation_formatted(entry, 'ieee', 'html') }
|
|
57
|
+
|
|
58
|
+
it 'should return a String' do
|
|
59
|
+
expect(result).to be_a String
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should have the expected author' do
|
|
63
|
+
expect(result).to match /K. Gödel/
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe 'citation_search' do
|
|
68
|
+
|
|
69
|
+
shared_examples 'the expected search results' do
|
|
70
|
+
|
|
71
|
+
it 'should be an Array' do
|
|
72
|
+
expect(subject).to be_an Array
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'should have the expected number of elements' do
|
|
76
|
+
expect(subject.length).to eq results.length
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'should have String elements' do
|
|
80
|
+
subject.each { |item| expect(item).to be_a String }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should have the expected elements' do
|
|
84
|
+
expect(subject).to match_array results
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'should be in year order' do
|
|
88
|
+
expect(subject).to eq results
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'when search_term and author are nil' do
|
|
93
|
+
it_should_behave_like 'the expected search results' do
|
|
94
|
+
let(:subject) {
|
|
95
|
+
BibtexHelper.citations_search(bib, nil, nil)
|
|
96
|
+
}
|
|
97
|
+
let(:results) { ['godel:1933', 'turing:1936', 'turing:1946'] }
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context 'when search_term is "@article", but author is nil' do
|
|
102
|
+
it_should_behave_like 'the expected search results' do
|
|
103
|
+
let(:subject) {
|
|
104
|
+
BibtexHelper.citations_search(bib, '@article', nil)
|
|
105
|
+
}
|
|
106
|
+
let(:results) { ['godel:1933', 'turing:1936'] }
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context 'when search_term is nil, but author is given' do
|
|
111
|
+
it_should_behave_like 'the expected search results' do
|
|
112
|
+
let(:subject) {
|
|
113
|
+
BibtexHelper.citations_search(bib, nil, 'A. M. Turing')
|
|
114
|
+
}
|
|
115
|
+
let(:results) { ['turing:1936', 'turing:1946'] }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
context 'when search_term is "@article" and author is given' do
|
|
120
|
+
it_should_behave_like 'the expected search results' do
|
|
121
|
+
let(:subject) {
|
|
122
|
+
BibtexHelper.citations_search(bib, '@article', 'A. M. Turing')
|
|
123
|
+
}
|
|
124
|
+
let(:results) { ['turing:1936'] }
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@Article{godel:1933,
|
|
2
|
+
author = {K. G\"{o}del},
|
|
3
|
+
title = {\"{U}ber formal unentschedibare Sätze der
|
|
4
|
+
Principia Mathematica und verwandter Systeme, I},
|
|
5
|
+
journal = {Monatsh. Math. Phys.},
|
|
6
|
+
year = 1931,
|
|
7
|
+
volume = 38,
|
|
8
|
+
pages = {173--198}}
|
|
9
|
+
|
|
10
|
+
@Article{turing:1936,
|
|
11
|
+
author = {A. M. Turing},
|
|
12
|
+
title = {On Computable Numbers, with an Application to the
|
|
13
|
+
{Entscheidungsproblem}},
|
|
14
|
+
journal = {Proc. London Math. Soc. (2)},
|
|
15
|
+
volume = 42,
|
|
16
|
+
pages = {230--265},
|
|
17
|
+
year = 1936
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@TechReport{turing:1946,
|
|
21
|
+
author = {A. M. Turing},
|
|
22
|
+
title = {Proposed Electronic Calculator},
|
|
23
|
+
type = {Report},
|
|
24
|
+
institution = {National Physical Laboratory},
|
|
25
|
+
pages = 48,
|
|
26
|
+
year = 1946
|
|
27
|
+
}
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: middleman-bibtex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- J. J. Green
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-03-
|
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bibtex-ruby
|
|
@@ -56,16 +56,16 @@ dependencies:
|
|
|
56
56
|
name: bundler
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rake
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -81,7 +81,7 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - ">="
|
|
@@ -105,6 +105,7 @@ extensions: []
|
|
|
105
105
|
extra_rdoc_files: []
|
|
106
106
|
files:
|
|
107
107
|
- ".gitignore"
|
|
108
|
+
- ".travis.yml"
|
|
108
109
|
- Gemfile
|
|
109
110
|
- Gemfile.lock
|
|
110
111
|
- LICENSE
|
|
@@ -113,6 +114,9 @@ files:
|
|
|
113
114
|
- lib/middleman-bibtex.rb
|
|
114
115
|
- lib/middleman-bibtex/version.rb
|
|
115
116
|
- middleman-bibtex.gemspec
|
|
117
|
+
- spec/bibtex_spec.rb
|
|
118
|
+
- spec/fixtures/test.bib
|
|
119
|
+
- spec/spec_helper.rb
|
|
116
120
|
homepage: https://github.com/jjgreen/middleman-bibtex
|
|
117
121
|
licenses:
|
|
118
122
|
- MIT
|
|
@@ -137,4 +141,7 @@ rubygems_version: 2.2.2
|
|
|
137
141
|
signing_key:
|
|
138
142
|
specification_version: 4
|
|
139
143
|
summary: Middleman extension for bibtex bibliographies
|
|
140
|
-
test_files:
|
|
144
|
+
test_files:
|
|
145
|
+
- spec/bibtex_spec.rb
|
|
146
|
+
- spec/fixtures/test.bib
|
|
147
|
+
- spec/spec_helper.rb
|