dl-rake-latex 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/ChangeLog +19 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +16 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/bin/gnuplot-latex-fonts +25 -0
- data/lib/rake-latex.rb +25 -0
- data/lib/rake-latex/figures.rb +199 -0
- data/lib/rake-latex/latex.rb +236 -0
- data/lib/rake-latex/vega.rb +75 -0
- data/test/helper.rb +18 -0
- data/test/test_rake-latex.rb +7 -0
- metadata +105 -0
data/.document
ADDED
data/ChangeLog
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
2007-02-26 Douglas Creager <douglas.creager@comlab.ox.ac.uk>
|
2
|
+
|
3
|
+
* lib/rake-latex/figures.rb: Adding "includes" parameter for
|
4
|
+
Gnuplot figures.
|
5
|
+
|
6
|
+
* lib/rake-latex/latex.rb: Only run latex/pdflatex twice *after*
|
7
|
+
bibtex has been run. PS file only depends on DVI file, not on any
|
8
|
+
of the source files.
|
9
|
+
|
10
|
+
* lib/rake-latex/vega.rb: Adding support for vega code listings
|
11
|
+
|
12
|
+
* lib/rake-latex/figures.rb: Adding support for Gnuplot-based
|
13
|
+
figures
|
14
|
+
|
15
|
+
2006-11-28 Douglas Creager <douglas.creager@comlab.ox.ac.uk>
|
16
|
+
|
17
|
+
* Rakefile: Add support for generating .tar.gz archives. Don't
|
18
|
+
require rubygems package to build .tar.gz.
|
19
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "bundler", "~> 1.0.0"
|
10
|
+
gem "jeweler", "~> 1.6.4"
|
11
|
+
end
|
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 David Love
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= rake-latex
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to rake-latex
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 David Love. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
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 is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "dl-rake-latex"
|
18
|
+
gem.homepage = "http://github.com/dlove24/rake-latex"
|
19
|
+
gem.license = "GNU"
|
20
|
+
gem.summary = %Q{Rake LaTeX task developed by the Software Engineering group at the University of Oxford}
|
21
|
+
gem.description = %Q{http://devel.softeng.ox.ac.uk/trac/softeng/wiki/Utilities/RakeLatex}
|
22
|
+
gem.email = "david@homeunix.org.uk"
|
23
|
+
gem.authors = ["David Love"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "rake-latex #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
5.4.0
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Usage:
|
4
|
+
# gnuplot-latex-fonts <gnuplot file> [<font file>...]
|
5
|
+
#
|
6
|
+
# This script runs gnuplot on the file specified by the first
|
7
|
+
# command-line argument. The optional remaining arguments are Type1
|
8
|
+
# font files that are included by the gnuplot file; the script will
|
9
|
+
# use TeX's kpsewhich utility to find where each of these files is
|
10
|
+
# located, and will construct an appropriate GNUPLOT_FONTPATH
|
11
|
+
# environment variable so that gnuplot can find these fonts.
|
12
|
+
|
13
|
+
GNUPLOT_FILE=$1
|
14
|
+
shift
|
15
|
+
|
16
|
+
fontpath () {
|
17
|
+
# Run kpsewhich on each font to find its full location. Use
|
18
|
+
# dirname to extract the directory portion of the path. Use sort
|
19
|
+
# and uniq to filter out duplicate paths, and finally use paste to
|
20
|
+
# glue them together into a PATH-like directory list.
|
21
|
+
for c in `kpsewhich "$@"`; do dirname $c; done | \
|
22
|
+
sort | uniq | paste -s -d : -
|
23
|
+
}
|
24
|
+
|
25
|
+
GNUPLOT_FONTPATH=`fontpath "$@"` gnuplot "$GNUPLOT_FILE"
|
data/lib/rake-latex.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#-----------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Copyright (C) 2004 Douglas Creager
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19
|
+
# 02111-1307 USA
|
20
|
+
#
|
21
|
+
#-----------------------------------------------------------------------
|
22
|
+
|
23
|
+
require 'rake-latex/latex'
|
24
|
+
require 'rake-latex/figures'
|
25
|
+
require 'rake-latex/vega'
|
@@ -0,0 +1,199 @@
|
|
1
|
+
#-----------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007 Douglas Creager
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19
|
+
# 02111-1307 USA
|
20
|
+
#
|
21
|
+
#-----------------------------------------------------------------------
|
22
|
+
|
23
|
+
require 'rake'
|
24
|
+
require 'rake/tasklib'
|
25
|
+
|
26
|
+
module Rake
|
27
|
+
|
28
|
+
class FigureTask < TaskLib
|
29
|
+
|
30
|
+
attr_accessor :name
|
31
|
+
attr_accessor :source
|
32
|
+
attr_accessor :eps
|
33
|
+
attr_accessor :pdf
|
34
|
+
|
35
|
+
def initialize(name)
|
36
|
+
init(name)
|
37
|
+
yield self if block_given?
|
38
|
+
define unless name.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
def init(name)
|
42
|
+
@name = Rake.rootdir + name.to_s.ext(default_source_extension)
|
43
|
+
@source = @name
|
44
|
+
@eps = @source.ext("eps")
|
45
|
+
@pdf = @source.ext("pdf")
|
46
|
+
end
|
47
|
+
|
48
|
+
def define
|
49
|
+
file @eps => [@source] do
|
50
|
+
self.generate_eps
|
51
|
+
end
|
52
|
+
|
53
|
+
file @pdf => [@source] do
|
54
|
+
self.generate_pdf
|
55
|
+
end
|
56
|
+
|
57
|
+
task :figures => [@eps, @pdf]
|
58
|
+
|
59
|
+
task :clean do
|
60
|
+
clean_figures
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
|
66
|
+
def default_source_extension
|
67
|
+
"unknown"
|
68
|
+
end
|
69
|
+
|
70
|
+
def clean_figures
|
71
|
+
rm_f @eps
|
72
|
+
rm_f @pdf
|
73
|
+
end
|
74
|
+
|
75
|
+
def generate_eps
|
76
|
+
raise "FigureTask is abstract"
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_pdf
|
80
|
+
raise "FigureTask is abstract"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class GraffleTask < FigureTask
|
85
|
+
def define
|
86
|
+
super
|
87
|
+
task :graffle => [@eps, @pdf]
|
88
|
+
end
|
89
|
+
|
90
|
+
protected
|
91
|
+
|
92
|
+
def default_source_extension
|
93
|
+
"graffle"
|
94
|
+
end
|
95
|
+
|
96
|
+
def clean_figures
|
97
|
+
end
|
98
|
+
|
99
|
+
def generate_eps
|
100
|
+
sh %{graffle.sh eps #{@source} #{@eps}}
|
101
|
+
end
|
102
|
+
|
103
|
+
def generate_pdf
|
104
|
+
sh %{graffle.sh pdf #{@source} #{@pdf}}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
class DiaTask < FigureTask
|
109
|
+
def define
|
110
|
+
super
|
111
|
+
task @pdf => [@eps]
|
112
|
+
task :graffle => [@eps, @pdf]
|
113
|
+
end
|
114
|
+
|
115
|
+
protected
|
116
|
+
|
117
|
+
def default_source_extension
|
118
|
+
"dia"
|
119
|
+
end
|
120
|
+
|
121
|
+
def generate_eps
|
122
|
+
sh %{dia -l -t eps-builtin -e #{@eps} #{@source}}
|
123
|
+
end
|
124
|
+
|
125
|
+
def generate_pdf
|
126
|
+
sh %{epstopdf #{@eps} -o=#{@pdf}}
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class GnuplotTask < FigureTask
|
131
|
+
attr_accessor :fonts, :includes
|
132
|
+
|
133
|
+
def initialize(name, fonts)
|
134
|
+
init(name, fonts)
|
135
|
+
yield self if block_given?
|
136
|
+
define unless name.nil?
|
137
|
+
end
|
138
|
+
|
139
|
+
def init(name, fonts)
|
140
|
+
super(name)
|
141
|
+
@fonts = fonts
|
142
|
+
@includes = []
|
143
|
+
end
|
144
|
+
|
145
|
+
def define
|
146
|
+
@includes.collect! { |f| Rake.rootdir + f }
|
147
|
+
|
148
|
+
file @eps => [@source] + @includes do
|
149
|
+
self.generate_eps
|
150
|
+
end
|
151
|
+
|
152
|
+
file @pdf => [@eps] do
|
153
|
+
self.generate_pdf
|
154
|
+
end
|
155
|
+
|
156
|
+
task :figures => [@eps, @pdf]
|
157
|
+
|
158
|
+
task :clean do
|
159
|
+
clean_figures
|
160
|
+
end
|
161
|
+
|
162
|
+
task :gnuplot => [@eps, @pdf]
|
163
|
+
end
|
164
|
+
|
165
|
+
protected
|
166
|
+
|
167
|
+
def default_source_extension
|
168
|
+
"gp"
|
169
|
+
end
|
170
|
+
|
171
|
+
def generate_eps
|
172
|
+
dir = pwd
|
173
|
+
cd File.dirname(@source)
|
174
|
+
sh %{gnuplot-latex-fonts #{File.basename(@source)} #{@fonts.join(" ")}}
|
175
|
+
cd dir
|
176
|
+
end
|
177
|
+
|
178
|
+
def generate_pdf
|
179
|
+
sh %{epstopdf #{@eps} -o=#{@pdf}}
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
def graffle(name, &block)
|
186
|
+
t = Rake::GraffleTask.new(name, &block)
|
187
|
+
return t.name
|
188
|
+
end
|
189
|
+
|
190
|
+
def dia(name, &block)
|
191
|
+
t = Rake::DiaTask.new(name, &block)
|
192
|
+
return t.name
|
193
|
+
end
|
194
|
+
|
195
|
+
def gnuplot(name, fonts, &block)
|
196
|
+
fonts = [fonts] if fonts.is_a?(String)
|
197
|
+
t = Rake::GnuplotTask.new(name, fonts, &block)
|
198
|
+
return t.name
|
199
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
#-----------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Copyright (C) 2004 Douglas Creager
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19
|
+
# 02111-1307 USA
|
20
|
+
#
|
21
|
+
#-----------------------------------------------------------------------
|
22
|
+
|
23
|
+
require 'rake'
|
24
|
+
require 'rake/tasklib'
|
25
|
+
|
26
|
+
module Rake
|
27
|
+
|
28
|
+
# Maintain the directory containing the current Rakefile.
|
29
|
+
@@rootdir = nil
|
30
|
+
|
31
|
+
# Called at the start of a Rakefile that contains rules that needs
|
32
|
+
# to know the directory that the Rakefile is in. Adds the current
|
33
|
+
# Rakefile's directory to the beginning of the @@rootdir list.
|
34
|
+
# Should be called with __FILE__ as the parameter. This will take
|
35
|
+
# care of relative links to the file, allowing it to be required
|
36
|
+
# from different current directories.
|
37
|
+
def Rake.startfile(file)
|
38
|
+
@@rootdir = [] if @@rootdir.nil?
|
39
|
+
@@rootdir.unshift(File.dirname(file)+'/')
|
40
|
+
end
|
41
|
+
|
42
|
+
# Called at the end of a Rakefile that contains rules that needs to
|
43
|
+
# know the directory that the Rakefile is in. Removes the current
|
44
|
+
# Rakefile's directory from the beginning of the @@rootdir list.
|
45
|
+
def Rake.endfile()
|
46
|
+
@@rootdir.shift
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the root directory of the current Rakefile.
|
50
|
+
def Rake.rootdir
|
51
|
+
return "./" if @@rootdir.nil? or @@rootdir.empty?
|
52
|
+
return @@rootdir[0]
|
53
|
+
end
|
54
|
+
|
55
|
+
class LatexTask < TaskLib
|
56
|
+
|
57
|
+
attr_accessor :name
|
58
|
+
attr_accessor :need_aux
|
59
|
+
attr_accessor :figures
|
60
|
+
attr_accessor :references
|
61
|
+
attr_accessor :includes
|
62
|
+
attr_accessor :include_dirs
|
63
|
+
attr_accessor :tex
|
64
|
+
attr_accessor :dvi
|
65
|
+
attr_accessor :ps
|
66
|
+
attr_accessor :pdf
|
67
|
+
|
68
|
+
def initialize(name)
|
69
|
+
init(name)
|
70
|
+
yield self if block_given?
|
71
|
+
define unless name.nil?
|
72
|
+
end
|
73
|
+
|
74
|
+
def init(name)
|
75
|
+
@name = Rake.rootdir + name.to_s.ext("tex")
|
76
|
+
@need_aux = true
|
77
|
+
@figures = []
|
78
|
+
@references = []
|
79
|
+
@includes = []
|
80
|
+
@include_dirs = []
|
81
|
+
@latexinputs = nil
|
82
|
+
@pdflatexinputs = nil
|
83
|
+
@bibtexinputs = nil
|
84
|
+
|
85
|
+
@tex = @name
|
86
|
+
@blank = @tex.ext('')
|
87
|
+
@dvi = @tex.ext("dvi")
|
88
|
+
@ps = @tex.ext("ps")
|
89
|
+
@pdf = @tex.ext("pdf")
|
90
|
+
end
|
91
|
+
|
92
|
+
def define
|
93
|
+
@includes.collect! { |f| Rake.rootdir + f }
|
94
|
+
@references.collect! { |f| Rake.rootdir + f }
|
95
|
+
@include_dirs.collect! { |f| File.expand_path(Rake.rootdir + f) }
|
96
|
+
|
97
|
+
@epsfigs = @figures.collect { |f| f.ext('.eps') }
|
98
|
+
@pdffigs = @figures.collect { |f| f.ext('.pdf') }
|
99
|
+
|
100
|
+
file @dvi => [@tex] + @references + @epsfigs + @includes do
|
101
|
+
|task|
|
102
|
+
|
103
|
+
if not @references.empty? then
|
104
|
+
self.run_latex(task, true)
|
105
|
+
self.run_bibtex(task)
|
106
|
+
end
|
107
|
+
|
108
|
+
self.run_latex(task)
|
109
|
+
end
|
110
|
+
|
111
|
+
file @ps => [@dvi] do
|
112
|
+
|task|
|
113
|
+
run_dvips(task)
|
114
|
+
end
|
115
|
+
|
116
|
+
file @pdf => [@tex] + @references + @pdffigs + @includes do
|
117
|
+
|task|
|
118
|
+
|
119
|
+
if not @references.empty? then
|
120
|
+
self.run_pdflatex(task, true)
|
121
|
+
self.run_bibtex(task)
|
122
|
+
end
|
123
|
+
|
124
|
+
self.run_pdflatex(task)
|
125
|
+
end
|
126
|
+
|
127
|
+
task :dvi => @dvi
|
128
|
+
task :ps => @ps
|
129
|
+
task :pdf => @pdf
|
130
|
+
|
131
|
+
task :clean do
|
132
|
+
rm_f @dvi
|
133
|
+
rm_f @ps
|
134
|
+
rm_f @pdf
|
135
|
+
rm_f @tex.ext("aux")
|
136
|
+
rm_f @tex.ext("log")
|
137
|
+
rm_f @tex.ext("toc")
|
138
|
+
|
139
|
+
unless @references.empty? then
|
140
|
+
rm_f @tex.ext("bbl")
|
141
|
+
rm_f @tex.ext("blg")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
protected
|
147
|
+
|
148
|
+
def collect_prereq_dirs(prereqs, exts)
|
149
|
+
dirs_hash = Hash.new
|
150
|
+
dirs = []
|
151
|
+
|
152
|
+
prereqs.each do
|
153
|
+
|f|
|
154
|
+
if exts.include? File.extname(f) then
|
155
|
+
path = File.expand_path(File.dirname(f))
|
156
|
+
if not dirs_hash.include?(path) then
|
157
|
+
dirs.push(path)
|
158
|
+
dirs_hash[path] = true
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
return dirs
|
164
|
+
end
|
165
|
+
|
166
|
+
def make_env(var,dirs)
|
167
|
+
return "" if dirs.nil? or dirs.empty?
|
168
|
+
|
169
|
+
return %{#{var}=#{dirs.join(':')}:\$\{#{var}\}}
|
170
|
+
end
|
171
|
+
|
172
|
+
def run_latex_once
|
173
|
+
sh %{#{@latexinputs} latex #{File.basename(@blank)}}
|
174
|
+
end
|
175
|
+
|
176
|
+
def run_latex(task, once=false)
|
177
|
+
if @latexinputs.nil? then
|
178
|
+
dirs = collect_prereq_dirs(task.prerequisites,['.eps'])
|
179
|
+
dirs |= @include_dirs
|
180
|
+
@latexinputs = make_env('TEXINPUTS',dirs)
|
181
|
+
end
|
182
|
+
|
183
|
+
cd File.dirname(@tex) do
|
184
|
+
run_latex_once
|
185
|
+
run_latex_once if @need_aux and not once
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def run_dvips(task)
|
190
|
+
if @latexinputs.nil? then
|
191
|
+
dirs = collect_prereq_dirs(task.prerequisites,['.eps'])
|
192
|
+
dirs |= @include_dirs
|
193
|
+
@latexinputs = make_env('TEXINPUTS',dirs)
|
194
|
+
end
|
195
|
+
|
196
|
+
sh %{#{@latexinputs} dvips #{@dvi} -o #{@ps}}
|
197
|
+
end
|
198
|
+
|
199
|
+
def run_pdflatex_once
|
200
|
+
sh %{#{@pdflatexinputs} pdflatex #{File.basename(@blank)}}
|
201
|
+
end
|
202
|
+
|
203
|
+
def run_pdflatex(task, once=false)
|
204
|
+
if @pdflatexinputs.nil? then
|
205
|
+
dirs = collect_prereq_dirs(task.prerequisites,['.pdf'])
|
206
|
+
dirs |= @include_dirs
|
207
|
+
@pdflatexinputs = make_env('TEXINPUTS',dirs)
|
208
|
+
end
|
209
|
+
|
210
|
+
cd File.dirname(@tex) do
|
211
|
+
run_pdflatex_once
|
212
|
+
run_pdflatex_once if @need_aux and not once
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def run_bibtex(task)
|
217
|
+
if @bibtexinputs.nil? then
|
218
|
+
dirs = collect_prereq_dirs(task.prerequisites,['.bib'])
|
219
|
+
@bibtexinputs = make_env('BIBINPUTS',dirs)
|
220
|
+
end
|
221
|
+
|
222
|
+
cd File.dirname(@tex) do
|
223
|
+
sh %{#{@bibtexinputs} bibtex #{File.basename(@blank)}}
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
def latex(name,&block)
|
233
|
+
t = Rake::LatexTask.new(name,&block)
|
234
|
+
return t.name
|
235
|
+
end
|
236
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#-----------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Copyright (C) 2007 Douglas Creager
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later
|
9
|
+
# version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free
|
18
|
+
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19
|
+
# 02111-1307 USA
|
20
|
+
#
|
21
|
+
#-----------------------------------------------------------------------
|
22
|
+
|
23
|
+
require 'rake'
|
24
|
+
require 'rake/tasklib'
|
25
|
+
|
26
|
+
module Rake
|
27
|
+
|
28
|
+
VEGA_EXTS = {
|
29
|
+
'relaxng' => 'rnc',
|
30
|
+
'carp' => 'carp',
|
31
|
+
'latex' => 'tex'
|
32
|
+
}
|
33
|
+
|
34
|
+
class VegaTask < TaskLib
|
35
|
+
attr_accessor :name, :source, :dest, :language, :output
|
36
|
+
|
37
|
+
def initialize(name, language, output)
|
38
|
+
init(name, language, output)
|
39
|
+
yield self if block_given?
|
40
|
+
define
|
41
|
+
end
|
42
|
+
|
43
|
+
def init(name, language, output)
|
44
|
+
source_ext = VEGA_EXTS[language]
|
45
|
+
source_file = name.to_s.ext(source_ext)
|
46
|
+
|
47
|
+
dest_ext = VEGA_EXTS[output]
|
48
|
+
dest_file = name.to_s.ext(dest_ext)
|
49
|
+
|
50
|
+
@name = dest_file
|
51
|
+
@source = Rake.rootdir + source_file
|
52
|
+
@dest = Rake.rootdir + dest_file
|
53
|
+
@language = language
|
54
|
+
@output = output
|
55
|
+
end
|
56
|
+
|
57
|
+
def define
|
58
|
+
file @dest => [@source] do
|
59
|
+
sh %{vega -l #{@language} -o #{@output} #{@source} #{@dest}}
|
60
|
+
end
|
61
|
+
|
62
|
+
task :listings => [@dest]
|
63
|
+
|
64
|
+
task :clean do
|
65
|
+
rm_f @dest
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def vega(name, language, output, &block)
|
73
|
+
t = Rake::VegaTask.new(name, language, output, &block)
|
74
|
+
return t.name
|
75
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'rake-latex'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dl-rake-latex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 5
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 5.4.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- David Love
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-08-01 00:00:00 +01:00
|
18
|
+
default_executable: gnuplot-latex-fonts
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
type: :development
|
23
|
+
name: bundler
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 1.0.0
|
33
|
+
requirement: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
prerelease: false
|
36
|
+
type: :development
|
37
|
+
name: jeweler
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 6
|
45
|
+
- 4
|
46
|
+
version: 1.6.4
|
47
|
+
requirement: *id002
|
48
|
+
description: http://devel.softeng.ox.ac.uk/trac/softeng/wiki/Utilities/RakeLatex
|
49
|
+
email: david@homeunix.org.uk
|
50
|
+
executables:
|
51
|
+
- gnuplot-latex-fonts
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- ChangeLog
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.rdoc
|
58
|
+
files:
|
59
|
+
- .document
|
60
|
+
- ChangeLog
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.rdoc
|
65
|
+
- Rakefile
|
66
|
+
- VERSION
|
67
|
+
- bin/gnuplot-latex-fonts
|
68
|
+
- lib/rake-latex.rb
|
69
|
+
- lib/rake-latex/figures.rb
|
70
|
+
- lib/rake-latex/latex.rb
|
71
|
+
- lib/rake-latex/vega.rb
|
72
|
+
- test/helper.rb
|
73
|
+
- test/test_rake-latex.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://github.com/dlove24/rake-latex
|
76
|
+
licenses:
|
77
|
+
- GNU
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
version: "0"
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.3.6
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: Rake LaTeX task developed by the Software Engineering group at the University of Oxford
|
104
|
+
test_files: []
|
105
|
+
|