nanoc-bibtex 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: acde29f2f7793c1d99c26f544d6b3bcd614c773d
4
+ data.tar.gz: ca204dc9ad0ce0f9d74fc61a8fdc65799139b5ce
5
+ SHA512:
6
+ metadata.gz: 0f943035bf64f32d484ff448c0f803cf50c2285e64878b90b5767f5be08b01d9581f49604c4a773250f1bf47e81c6a5ec59c6270d8f6143a4669ed2c249fdab0
7
+ data.tar.gz: d2cdbdbd726dbeacec1ddb17de309e3a1daff1f9613b2dd7861a237ea4d831fe8eb5e95b3985ca3f5672ae730a25d46554c8fc5ed03e6afa6e843fa275328a7c
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'nanoc', '~> 4.0'
4
+ gem 'bibtex-ruby', '~> 4.1'
5
+ gem 'latex-decode', '~> 0.2'
6
+
7
+ group :development do
8
+ gem 'bundler', '~> 1.0'
9
+ gem 'jeweler', '~> 2.0'
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,70 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ bibtex-ruby (4.1.0)
6
+ latex-decode (~> 0.0)
7
+ builder (3.2.2)
8
+ colored (1.2)
9
+ cri (2.7.0)
10
+ colored (~> 1.2)
11
+ descendants_tracker (0.0.4)
12
+ thread_safe (~> 0.3, >= 0.3.1)
13
+ faraday (0.9.2)
14
+ multipart-post (>= 1.2, < 3)
15
+ git (1.2.9.1)
16
+ github_api (0.13.1)
17
+ addressable (~> 2.4.0)
18
+ descendants_tracker (~> 0.0.4)
19
+ faraday (~> 0.8, < 0.10)
20
+ hashie (>= 3.4)
21
+ multi_json (>= 1.7.5, < 2.0)
22
+ oauth2
23
+ hashie (3.4.3)
24
+ highline (1.7.8)
25
+ jeweler (2.0.1)
26
+ builder
27
+ bundler (>= 1.0)
28
+ git (>= 1.2.5)
29
+ github_api
30
+ highline (>= 1.6.15)
31
+ nokogiri (>= 1.5.10)
32
+ rake
33
+ rdoc
34
+ json (1.8.3)
35
+ jwt (1.5.2)
36
+ latex-decode (0.2.2)
37
+ unicode (~> 0.4)
38
+ mini_portile2 (2.0.0)
39
+ multi_json (1.11.2)
40
+ multi_xml (0.5.5)
41
+ multipart-post (2.0.0)
42
+ nanoc (4.1.0)
43
+ cri (~> 2.3)
44
+ nokogiri (1.6.7.1)
45
+ mini_portile2 (~> 2.0.0.rc2)
46
+ oauth2 (1.0.0)
47
+ faraday (>= 0.8, < 0.10)
48
+ jwt (~> 1.0)
49
+ multi_json (~> 1.3)
50
+ multi_xml (~> 0.5)
51
+ rack (~> 1.2)
52
+ rack (1.6.4)
53
+ rake (10.4.2)
54
+ rdoc (4.2.1)
55
+ json (~> 1.4)
56
+ thread_safe (0.3.5)
57
+ unicode (0.4.4.2)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bibtex-ruby (~> 4.1)
64
+ bundler (~> 1.0)
65
+ jeweler (~> 2.0)
66
+ latex-decode (~> 0.2)
67
+ nanoc (~> 4.0)
68
+
69
+ BUNDLED WITH
70
+ 1.11.2
data/README.md ADDED
@@ -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.
data/Rakefile ADDED
@@ -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
+ 0.1.0
@@ -1,25 +1,25 @@
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
14
  entries = BibTeX.open(file)
15
15
  entries.map do |entry|
16
- Nanoc3::Item.new to_bibtex(entry), extract_attributes(entry), entry.key
16
+ new_item to_bibtex(entry), extract_attributes(entry), "/#{entry.key}"
17
17
  end
18
18
  end.flatten!
19
19
  end
20
20
 
21
21
  def to_bibtex entry
22
- contents = [ "@#{entry.type}{#{entry.key}," ]
22
+ contents = ["@#{entry.type}{#{entry.key},"]
23
23
  entry.each do |key, value|
24
24
  unless @exclude[key.to_s]
25
25
  if value =~ /^\d+$/ or (key == :month and value =~ /^[a-z]{1,3}$/)
@@ -32,10 +32,15 @@ class BibtexDataSource < Nanoc3::DataSource
32
32
  contents.push "}"
33
33
  contents.join "\n"
34
34
  end
35
-
35
+
36
36
  def extract_attributes entry
37
- attributes = { :key => entry.key }
38
- entry.each { |key, value| attributes[key] = value.convert(:latex) }
37
+ entry = entry.convert :latex
38
+ attributes = {
39
+ :bibtex => entry,
40
+ :key => entry.key,
41
+ :type => entry.type,
42
+ }
43
+ entry.each { |key, value| attributes[key] = value }
39
44
  attributes
40
45
  end
41
46
  end
@@ -0,0 +1,58 @@
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 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "nanoc-bibtex"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Ruben Verborgh"]
14
+ s.date = "2015-12-29"
15
+ s.description = "BibTeX data source for nanoc."
16
+ s.email = "ruben@verborgh.org"
17
+ s.extra_rdoc_files = [
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/nanoc/data_sources/bibtex_data_source.rb",
27
+ "nanoc-bibtex.gemspec"
28
+ ]
29
+ s.homepage = "http://github.com/RubenVerborgh/nanoc-bibtex"
30
+ s.licenses = ["MIT"]
31
+ s.rubygems_version = "2.4.5.1"
32
+ s.summary = "BibTeX data source for nanoc."
33
+
34
+ if s.respond_to? :specification_version then
35
+ s.specification_version = 4
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ s.add_runtime_dependency(%q<nanoc>, ["~> 4.0"])
39
+ s.add_runtime_dependency(%q<bibtex-ruby>, ["~> 4.1"])
40
+ s.add_runtime_dependency(%q<latex-decode>, ["~> 0.2"])
41
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
42
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
43
+ else
44
+ s.add_dependency(%q<nanoc>, ["~> 4.0"])
45
+ s.add_dependency(%q<bibtex-ruby>, ["~> 4.1"])
46
+ s.add_dependency(%q<latex-decode>, ["~> 0.2"])
47
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<nanoc>, ["~> 4.0"])
52
+ s.add_dependency(%q<bibtex-ruby>, ["~> 4.1"])
53
+ s.add_dependency(%q<latex-decode>, ["~> 0.2"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
56
+ end
57
+ end
58
+
metadata CHANGED
@@ -1,95 +1,121 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-bibtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ruben Verborgh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-17 00:00:00.000000000 Z
11
+ date: 2015-12-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nanoc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
19
+ version: '4.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0
26
+ version: '4.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bibtex-ruby
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 2.0.0
33
+ version: '4.1'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 2.0.0
40
+ version: '4.1'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: latex-decode
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 0.0.12
47
+ version: '0.2'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: 0.0.12
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: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.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'
62
83
  description: BibTeX data source for nanoc.
63
- email:
64
- - ruben.verborgh@gmail.com
84
+ email: ruben@verborgh.org
65
85
  executables: []
66
86
  extensions: []
67
- extra_rdoc_files: []
87
+ extra_rdoc_files:
88
+ - README.md
68
89
  files:
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - README.md
93
+ - Rakefile
94
+ - VERSION
69
95
  - lib/nanoc/data_sources/bibtex_data_source.rb
70
- homepage: http://rubygems.org/gems/nanoc-bibtex
71
- licenses: []
96
+ - nanoc-bibtex.gemspec
97
+ homepage: http://github.com/RubenVerborgh/nanoc-bibtex
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
72
101
  post_install_message:
73
102
  rdoc_options: []
74
103
  require_paths:
75
104
  - lib
76
105
  required_ruby_version: !ruby/object:Gem::Requirement
77
- none: false
78
106
  requirements:
79
- - - ! '>='
107
+ - - ">="
80
108
  - !ruby/object:Gem::Version
81
109
  version: '0'
82
110
  required_rubygems_version: !ruby/object:Gem::Requirement
83
- none: false
84
111
  requirements:
85
- - - ! '>='
112
+ - - ">="
86
113
  - !ruby/object:Gem::Version
87
114
  version: '0'
88
115
  requirements: []
89
116
  rubyforge_project:
90
- rubygems_version: 1.8.23
117
+ rubygems_version: 2.4.5.1
91
118
  signing_key:
92
- specification_version: 3
119
+ specification_version: 4
93
120
  summary: BibTeX data source for nanoc.
94
121
  test_files: []
95
- has_rdoc: