nanoc-bibtex 0.0.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3164093bb8b8ed49e89af0dfb4b8a87a57465155c69dd4207acd3e85431f2397
4
+ data.tar.gz: a0e0dc8ea0b71c8eeae388c3c55848aa1480f03ce9f6f6684c0db2beda8367d1
5
+ SHA512:
6
+ metadata.gz: 1c017733e93674292a547bc5cd54cbd9ad77c2ef8a43418aa5611c5534a1ca96e609df4e0d15e1679fe81aded49a46b9b944822e9e77759a7b06166a34c894cd
7
+ data.tar.gz: 34a34a2d03940ef9c45465d92d300c0c3f75051a8a23ba5aee1ce4c2b37a8f94af320c51fff3e87ec3574a52b88e1a7f14c7be2126ebd11a5333f86509b24ed1
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'nanoc', '~> 4.2'
4
+ gem 'bibtex-ruby', '~> 5.1'
5
+ gem 'latex-decode', '~> 0.2'
6
+
7
+ group :development do
8
+ gem 'bundler', '~> 2.0'
9
+ gem 'jeweler', '~> 2.0'
10
+ end
@@ -0,0 +1,39 @@
1
+ ## About
2
+ Thanks to this gem,
3
+ you can use [BibTeX](http://www.bibtex.org/Format/) files
4
+ as a data source for the static site compiler [nanoc](https://github.com/ddfreyne/nanoc).
5
+
6
+ ## Installation
7
+ First, install the `nanoc-bibtex` gem:
8
+ ```bash
9
+ $ gem install nanoc-bibtex
10
+ ```
11
+
12
+ Then, load the data source on start by including this line in `lib/default.rb`:
13
+ ```ruby
14
+ require 'nanoc/data_sources/bibtex_data_source'
15
+ ```
16
+
17
+ ## Usage
18
+ Modify your `config.yaml` to include your data source:
19
+ ```yaml
20
+ data_sources:
21
+ -
22
+ type: filesystem_unified
23
+ items_root: /
24
+ layouts_root: /
25
+ -
26
+ type: bibtex
27
+ items_root: /publications
28
+ config:
29
+ path: assets/publications/
30
+ exclude:
31
+ - abstract
32
+ ```
33
+ The above example configures your site with an additional `bibtex` data source.
34
+ It will load the entries of each BibTeX file in the folder `assets/publications`
35
+ as items whose path will be `/publications/{citation_key}`.
36
+
37
+ The fields of each item will contain the values of the corresponding BibTeX entry.
38
+ The raw contents of this item will be the BibTeX entry,
39
+ excluding the `abstract` field.
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "nanoc-bibtex"
17
+ gem.homepage = "http://github.com/RubenVerborgh/nanoc-bibtex"
18
+ gem.license = "MIT"
19
+ gem.summary = %Q{BibTeX data source for nanoc.}
20
+ gem.description = gem.summary
21
+ gem.email = "ruben@verborgh.org"
22
+ gem.authors = ["Ruben Verborgh"]
23
+ end
24
+ Jeweler::RubygemsDotOrgTasks.new
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'lib' << 'test'
29
+ test.pattern = 'test/**/test_*.rb'
30
+ test.verbose = true
31
+ end
32
+
33
+ desc "Code coverage detail"
34
+ task :simplecov do
35
+ ENV['COVERAGE'] = "true"
36
+ Rake::Task['test'].execute
37
+ end
38
+
39
+ task :default => :test
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "nanoc-bibtex #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
@@ -1,28 +1,31 @@
1
1
  require 'bibtex'
2
2
 
3
- class BibtexDataSource < Nanoc3::DataSource
3
+ class BibtexDataSource < Nanoc::DataSource
4
4
  identifier :bibtex
5
-
5
+
6
6
  def up
7
7
  @files = Dir[@config[:path].sub(/\/?$/, '/*.bib')];
8
8
  @exclude = {}
9
9
  (@config[:exclude] || []).each { |value| @exclude[value] = true }
10
10
  end
11
-
11
+
12
12
  def items
13
13
  @files.map do |file|
14
+ stat = File.stat file
15
+ file_checksum = stat.size.to_s + '-' + stat.mtime.to_i.to_s
14
16
  entries = BibTeX.open(file)
15
17
  entries.map do |entry|
16
- Nanoc3::Item.new to_bibtex(entry), extract_attributes(entry), entry.key
18
+ new_item lambda { to_bibtex entry }, lambda { extract_attributes entry },
19
+ '/' + entry.key, checksum_data: file_checksum
17
20
  end
18
21
  end.flatten!
19
22
  end
20
23
 
21
24
  def to_bibtex entry
22
- contents = [ "@#{entry.type}{#{entry.key}," ]
25
+ contents = ["@#{entry.type}{#{entry.key},"]
23
26
  entry.each do |key, value|
24
27
  unless @exclude[key.to_s]
25
- unless value =~ /\s|\{|\}|"|,|:/
28
+ if value =~ /^\d+$/ or (key == :month and value =~ /^[a-z]{1,3}$/)
26
29
  contents.push " #{key} = #{value},"
27
30
  else
28
31
  contents.push " #{key} = {#{value}},"
@@ -32,10 +35,15 @@ class BibtexDataSource < Nanoc3::DataSource
32
35
  contents.push "}"
33
36
  contents.join "\n"
34
37
  end
35
-
38
+
36
39
  def extract_attributes entry
37
- attributes = { :key => entry.key }
38
- entry.each { |key, value| attributes[key] = value.convert(:latex) }
40
+ entry = entry.convert(:latex) { |key| key != :url }
41
+ attributes = {
42
+ :bibtex => entry,
43
+ :key => entry.key,
44
+ :type => entry.type,
45
+ }
46
+ entry.each { |key, value| attributes[key] = value }
39
47
  attributes
40
48
  end
41
49
  end
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: nanoc-bibtex 1.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "nanoc-bibtex".freeze
9
+ s.version = "1.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Ruben Verborgh".freeze]
14
+ s.date = "2020-09-17"
15
+ s.description = "BibTeX data source for nanoc.".freeze
16
+ s.email = "ruben@verborgh.org".freeze
17
+ s.extra_rdoc_files = [
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/nanoc/data_sources/bibtex_data_source.rb",
26
+ "nanoc-bibtex.gemspec"
27
+ ]
28
+ s.homepage = "http://github.com/RubenVerborgh/nanoc-bibtex".freeze
29
+ s.licenses = ["MIT".freeze]
30
+ s.rubygems_version = "3.1.2".freeze
31
+ s.summary = "BibTeX data source for nanoc.".freeze
32
+
33
+ if s.respond_to? :specification_version then
34
+ s.specification_version = 4
35
+ end
36
+
37
+ if s.respond_to? :add_runtime_dependency then
38
+ s.add_runtime_dependency(%q<nanoc>.freeze, ["~> 4.2"])
39
+ s.add_runtime_dependency(%q<bibtex-ruby>.freeze, ["~> 5.1"])
40
+ s.add_runtime_dependency(%q<latex-decode>.freeze, ["~> 0.2"])
41
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 2.0"])
42
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.0"])
43
+ else
44
+ s.add_dependency(%q<nanoc>.freeze, ["~> 4.2"])
45
+ s.add_dependency(%q<bibtex-ruby>.freeze, ["~> 5.1"])
46
+ s.add_dependency(%q<latex-decode>.freeze, ["~> 0.2"])
47
+ s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
48
+ s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
49
+ end
50
+ end
51
+
metadata CHANGED
@@ -1,79 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-bibtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ruben Verborgh
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nanoc
16
- requirement: &2161614120 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
19
+ version: '4.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2161614120
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: bibtex-ruby
27
- requirement: &2161608060 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: 2.0.0
33
+ version: '5.1'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *2161608060
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.1'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: latex-decode
38
- requirement: &2161607100 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
- version: 0.0.12
47
+ version: '0.2'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *2161607100
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
47
83
  description: BibTeX data source for nanoc.
48
- email:
49
- - ruben.verborgh@gmail.com
84
+ email: ruben@verborgh.org
50
85
  executables: []
51
86
  extensions: []
52
- extra_rdoc_files: []
87
+ extra_rdoc_files:
88
+ - README.md
53
89
  files:
90
+ - Gemfile
91
+ - README.md
92
+ - Rakefile
93
+ - VERSION
54
94
  - lib/nanoc/data_sources/bibtex_data_source.rb
55
- homepage: http://rubygems.org/gems/nanoc-bibtex
56
- licenses: []
57
- post_install_message:
95
+ - nanoc-bibtex.gemspec
96
+ homepage: http://github.com/RubenVerborgh/nanoc-bibtex
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
58
101
  rdoc_options: []
59
102
  require_paths:
60
103
  - lib
61
104
  required_ruby_version: !ruby/object:Gem::Requirement
62
- none: false
63
105
  requirements:
64
- - - ! '>='
106
+ - - ">="
65
107
  - !ruby/object:Gem::Version
66
108
  version: '0'
67
109
  required_rubygems_version: !ruby/object:Gem::Requirement
68
- none: false
69
110
  requirements:
70
- - - ! '>='
111
+ - - ">="
71
112
  - !ruby/object:Gem::Version
72
113
  version: '0'
73
114
  requirements: []
74
- rubyforge_project:
75
- rubygems_version: 1.8.10
76
- signing_key:
77
- specification_version: 3
115
+ rubygems_version: 3.1.2
116
+ signing_key:
117
+ specification_version: 4
78
118
  summary: BibTeX data source for nanoc.
79
119
  test_files: []