nanoc-bibtex 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,41 @@
1
+ require 'bibtex'
2
+
3
+ class BibtexDataSource < Nanoc3::DataSource
4
+ identifier :bibtex
5
+
6
+ def up
7
+ @files = Dir[@config[:path].sub(/\/?$/, '/*.bib')];
8
+ @exclude = {}
9
+ (@config[:exclude] || []).each { |value| @exclude[value] = true }
10
+ end
11
+
12
+ def items
13
+ @files.map do |file|
14
+ entries = BibTeX.open(file)
15
+ entries.map do |entry|
16
+ Nanoc3::Item.new to_bibtex(entry), extract_attributes(entry), entry.key
17
+ end
18
+ end.flatten!
19
+ end
20
+
21
+ def to_bibtex entry
22
+ contents = [ "@#{entry.type}{#{entry.key}," ]
23
+ entry.each do |key, value|
24
+ unless @exclude[key.to_s]
25
+ unless value =~ /\s|\{|\}|"|,|:/
26
+ contents.push " #{key} = #{value},"
27
+ else
28
+ contents.push " #{key} = {#{value}},"
29
+ end
30
+ end
31
+ end
32
+ contents.push "}"
33
+ contents.join "\n"
34
+ end
35
+
36
+ def extract_attributes entry
37
+ attributes = { :key => entry.key }
38
+ entry.each { |key, value| attributes[key] = value.convert(:latex) }
39
+ attributes
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanoc-bibtex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ruben Verborgh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nanoc
16
+ requirement: &2161614120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2161614120
25
+ - !ruby/object:Gem::Dependency
26
+ name: bibtex-ruby
27
+ requirement: &2161608060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2161608060
36
+ - !ruby/object:Gem::Dependency
37
+ name: latex-decode
38
+ requirement: &2161607100 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.12
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2161607100
47
+ description: BibTeX data source for nanoc.
48
+ email:
49
+ - ruben.verborgh@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/nanoc/data_sources/bibtex_data_source.rb
55
+ homepage: http://rubygems.org/gems/nanoc-bibtex
56
+ licenses: []
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.10
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: BibTeX data source for nanoc.
79
+ test_files: []