rtex 1.99.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,7 @@ tasks/doc.rake
16
16
  tasks/gem.rake
17
17
  tasks/manifest.rake
18
18
  tasks/post_load.rake
19
+ tasks/rubyforge.rake
19
20
  tasks/setup.rb
20
21
  tasks/test.rake
21
22
  test/document_test.rb
@@ -26,8 +27,5 @@ test/fixtures/fragment.tex.erb
26
27
  test/fixtures/text.textile
27
28
  test/tempdir_test.rb
28
29
  test/test_helper.rb
29
- test/tmp/rtex-071EE944-B2FA-4A3B-9764-1B5143833EB7/document.tex
30
- test/tmp/rtex-592F93A7-6198-4B00-B638-33855344A29B/document.tex
31
- test/tmp/rtex-96736595-5175-4602-9DC1-ABA096CC0E3D/document.tex
32
30
  vendor/instiki/LICENSE
33
31
  vendor/instiki/redcloth_for_tex.rb
@@ -1,9 +1,8 @@
1
1
  = RTeX: TeX/PDF Generation for Ruby
2
2
 
3
- Project homepage: http://rtex.rubyforge.org
3
+ Project homepage (FAQ, manual, documentation, contact info): http://rtex.rubyforge.org
4
4
 
5
- Please file comments and bug reports at http://rubyforge.org/projects/rtex
6
- (in the Forum and the Tracker, respectively).
5
+ Source repository at: http://github.com/bruce/rtex
7
6
 
8
7
  == Dependencies
9
8
 
data/Rakefile CHANGED
@@ -12,6 +12,9 @@ PROJ.libs = %w[]
12
12
  PROJ.ruby_opts = []
13
13
  PROJ.test_opts = []
14
14
 
15
+ PROJ.rdoc_main = 'README.rdoc'
16
+ PROJ.rdoc_include.push 'README.rdoc', 'README_RAILS.rdoc'
17
+
15
18
  PROJ.description = "LaTeX preprocessor for PDF generation; Rails plugin"
16
19
  PROJ.summary = PROJ.description
17
20
 
@@ -4,25 +4,29 @@ require 'document'
4
4
  require 'version'
5
5
 
6
6
  module RTeX
7
-
7
+
8
+ # Load code to initialize RTeX for framework
8
9
  def self.framework(name)
9
10
  require File.dirname(__FILE__) << "/rtex/framework/#{name}"
10
11
  framework = ::RTeX::Framework.const_get(name.to_s.capitalize)
11
12
  framework.setup
12
13
  end
13
14
 
15
+ def self.filters #:nodoc:
16
+ @filters ||= {}
17
+ end
18
+
14
19
  def self.basic_layout #:nodoc:
15
20
  "\\documentclass[12pt]{article}\n\\begin{document}\n<%= yield %>\n\\end{document}"
16
21
  end
17
22
 
23
+ # Define a processing filter
24
+ # call-seq:
25
+ # filter(:name) { |text_to_transform| ... } # => result
18
26
  def self.filter(name, &block)
19
27
  filters[name.to_s] = block
20
28
  end
21
29
 
22
- def self.filters #:nodoc:
23
- @filters ||= {}
24
- end
25
-
26
30
  filter :textile do |source|
27
31
  require File.dirname(__FILE__) << '/../vendor/instiki/redcloth_for_tex'
28
32
  RedClothForTex.new(source).to_tex
@@ -16,12 +16,17 @@ module RTeX
16
16
  class GenerationError < ::StandardError; end
17
17
  class ExecutableNotFoundError < ::StandardError; end
18
18
 
19
+ # Default options
20
+ # [+:preprocess+] Are we preprocessing? Default is +false+
21
+ # [+:preprocessor+] Executable to use during preprocessing (generating TOCs, etc). Default is +latex+
22
+ # [+:shell_redirect+] Option redirection for shell output (eg, +"> /dev/null 2>&1"+ ). Default is +nil+.
23
+ # [+:tmpdir+] Location of temporary directory (default: +Dir.tmpdir+)
19
24
  def self.options
20
25
  @options ||= {
21
26
  :preprocessor => 'latex',
22
27
  :preprocess => false,
23
28
  :processor => 'pdflatex',
24
- # Option redirection for shell output (eg, set to '> /dev/null 2>&1' )
29
+ #
25
30
  :shell_redirect => nil,
26
31
  # Temporary Directory
27
32
  :tempdir => Dir.tmpdir
@@ -37,13 +42,15 @@ module RTeX
37
42
  end
38
43
  end
39
44
 
40
- def source(binding=nil)
45
+ # Get the source for the entire
46
+ def source(binding=nil) #:nodoc:
41
47
  @source ||= wrap_in_layout do
42
48
  filter @erb.result(binding)
43
49
  end
44
50
  end
45
51
 
46
- def filter(text)
52
+ # Process through defined filter
53
+ def filter(text) #:nodoc:
47
54
  return text unless @options[:filter]
48
55
  if (process = RTeX.filters[@options[:filter]])
49
56
  process[text]
@@ -52,7 +59,8 @@ module RTeX
52
59
  end
53
60
  end
54
61
 
55
- def wrap_in_layout
62
+ # Wrap content in optional layout
63
+ def wrap_in_layout #:nodoc:
56
64
  if @options[:layout]
57
65
  ERB.new(@options[:layout]).result(binding)
58
66
  else
@@ -60,19 +68,23 @@ module RTeX
60
68
  end
61
69
  end
62
70
 
71
+ # Generate PDF from
72
+ # call-seq:
73
+ # to_pdf # => PDF in a String
74
+ # to_pdf { |filename| ... }
63
75
  def to_pdf(binding=nil, &file_handler)
64
76
  process_pdf_from(source(binding), &file_handler)
65
77
  end
66
78
 
67
- def processor
79
+ def processor #:nodoc:
68
80
  @processor ||= check_path_for @options[:processor]
69
81
  end
70
82
 
71
- def preprocessor
83
+ def preprocessor #:nodoc:
72
84
  @preprocessor ||= check_path_for @options[:preprocessor]
73
85
  end
74
86
 
75
- def system_path
87
+ def system_path #:nodoc:
76
88
  ENV['PATH']
77
89
  end
78
90
 
@@ -80,6 +92,7 @@ module RTeX
80
92
  private
81
93
  #######
82
94
 
95
+ # Verify existence of executable in search path
83
96
  def check_path_for(command)
84
97
  unless FileTest.executable?(command) || system_path.split(":").any?{ |path| FileTest.executable?(File.join(path, command))}
85
98
  raise ExecutableNotFoundError, command
@@ -87,6 +100,7 @@ module RTeX
87
100
  command
88
101
  end
89
102
 
103
+ # Basic processing
90
104
  def process_pdf_from(input, &file_handler)
91
105
  Tempdir.open(@options[:tempdir]) do |tempdir|
92
106
  prepare input
@@ -103,7 +117,7 @@ module RTeX
103
117
  end
104
118
  end
105
119
 
106
- def process! #:nodoc:
120
+ def process!
107
121
  unless `#{processor} --interaction=nonstopmode '#{source_file}' #{@options[:shell_redirect]}`
108
122
  raise GenerationError, "Could not generate PDF using #{processor}"
109
123
  end
@@ -2,12 +2,14 @@ module RTeX
2
2
 
3
3
  module Escaping
4
4
 
5
+ # Escape text using +replacements+
5
6
  def escape(text)
6
7
  replacements.inject(text) do |corpus, (pattern, replacement)|
7
8
  corpus.gsub(pattern, replacement)
8
9
  end
9
10
  end
10
11
 
12
+ # List of replacements
11
13
  def replacements
12
14
  @replacements ||= [
13
15
  [/([{}])/, '\\\1'],
@@ -1,8 +1,8 @@
1
1
  module RTeX
2
2
 
3
- module Framework
3
+ module Framework #:nodoc:
4
4
 
5
- module Merb
5
+ module Merb #:nodoc:
6
6
 
7
7
  # TODO
8
8
 
@@ -1,8 +1,8 @@
1
1
  require 'tempfile'
2
2
 
3
3
  module RTeX
4
- module Framework
5
- module Rails
4
+ module Framework #:nodoc:
5
+ module Rails #:nodoc:
6
6
 
7
7
  def self.setup
8
8
  RTeX::Document.options[:tempdir] = File.expand_path(File.join(RAILS_ROOT, 'tmp'))
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
 
3
3
  module RTeX
4
4
 
5
- class Tempdir
5
+ class Tempdir #:nodoc:
6
6
 
7
7
  def self.open(parent_path=RTeX::Document.options[:tempdir])
8
8
  tempdir = new(parent_path)
@@ -63,12 +63,10 @@ module RTeX
63
63
  [@major, @minor, @tiny]
64
64
  end
65
65
 
66
- MAJOR = 1
67
- MINOR = 99
66
+ MAJOR = 2
67
+ MINOR = 0
68
68
  TINY = 0
69
69
 
70
- DESCRIPTION = '2.0 Preview 1'
71
-
72
70
  # The current version as a Version instance
73
71
  CURRENT = new(MAJOR, MINOR, TINY)
74
72
  # The current version as a String
@@ -0,0 +1,57 @@
1
+ # $Id$
2
+
3
+ if PROJ.rubyforge_name && HAVE_RUBYFORGE
4
+
5
+ require 'rubyforge'
6
+ require 'rake/contrib/sshpublisher'
7
+
8
+ namespace :gem do
9
+ desc 'Package and upload to RubyForge'
10
+ task :release => [:clobber, :package] do |t|
11
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
+ pkg = "pkg/#{PROJ.spec.full_name}"
14
+
15
+ if $DEBUG then
16
+ puts "release_id = rf.add_release #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
17
+ puts "rf.add_file #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
18
+ end
19
+
20
+ rf = RubyForge.new
21
+ puts 'Logging in'
22
+ rf.login
23
+
24
+ c = rf.userconfig
25
+ c['release_notes'] = PROJ.description if PROJ.description
26
+ c['release_changes'] = PROJ.changes if PROJ.changes
27
+ c['preformatted'] = true
28
+
29
+ files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
+ (PROJ.need_zip ? "#{pkg}.zip" : nil),
31
+ "#{pkg}.gem"].compact
32
+
33
+ puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
+ rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
35
+ end
36
+ end # namespace :gem
37
+
38
+
39
+ namespace :doc do
40
+ desc "Publish RDoc to RubyForge"
41
+ task :release => %w(doc:clobber_rdoc doc:rdoc) do
42
+ config = YAML.load(
43
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
44
+ )
45
+
46
+ host = "#{config['username']}@rubyforge.org"
47
+ remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge_name}/"
48
+ remote_dir << PROJ.rdoc_remote_dir if PROJ.rdoc_remote_dir
49
+ local_dir = PROJ.rdoc_dir
50
+
51
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
+ end
53
+ end # namespace :doc
54
+
55
+ end # if HAVE_RUBYFORGE
56
+
57
+ # EOF
@@ -17,7 +17,7 @@ PROJ.email = nil
17
17
  PROJ.url = nil
18
18
  PROJ.version = ENV['VERSION'] || '0.0.0'
19
19
  PROJ.rubyforge_name = nil
20
- PROJ.exclude = %w(tmp$ bak$ ~$ CVS site .svn/ ^pkg/ ^doc/ ^\. ^rails-example/)
20
+ PROJ.exclude = %w(tmp$ bak$ ~$ CVS site .svn/ ^pkg/ ^doc/ ^\. ^rails-example/ ^test/tmp)
21
21
  PROJ.release_name = ENV['RELEASE']
22
22
  PROJ.history_file = 'HISTORY.rdoc'
23
23
  PROJ.manifest_file = 'Manifest.txt'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Williams
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-04-24 00:00:00 -05:00
13
+ date: 2008-05-06 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -22,6 +22,8 @@ executables:
22
22
  extensions: []
23
23
 
24
24
  extra_rdoc_files:
25
+ - README.rdoc
26
+ - README_RAILS.rdoc
25
27
  - bin/rtex
26
28
  files:
27
29
  - HISTORY.rdoc
@@ -42,6 +44,7 @@ files:
42
44
  - tasks/gem.rake
43
45
  - tasks/manifest.rake
44
46
  - tasks/post_load.rake
47
+ - tasks/rubyforge.rake
45
48
  - tasks/setup.rb
46
49
  - tasks/test.rake
47
50
  - test/document_test.rb
@@ -52,9 +55,6 @@ files:
52
55
  - test/fixtures/text.textile
53
56
  - test/tempdir_test.rb
54
57
  - test/test_helper.rb
55
- - test/tmp/rtex-071EE944-B2FA-4A3B-9764-1B5143833EB7/document.tex
56
- - test/tmp/rtex-592F93A7-6198-4B00-B638-33855344A29B/document.tex
57
- - test/tmp/rtex-96736595-5175-4602-9DC1-ABA096CC0E3D/document.tex
58
58
  - vendor/instiki/LICENSE
59
59
  - vendor/instiki/redcloth_for_tex.rb
60
60
  has_rdoc: true
@@ -1,48 +0,0 @@
1
- % This percent indicates a comment.
2
- % This is a very simple latex article that introduces the way
3
- % equations are typeset. Do this in linux:
4
- %
5
- % latex first.tex
6
- % latex first.tex
7
- % xdvi first.dvi
8
- % dvips -o first.ps first.dvi
9
- % gv first.ps
10
- % lpr first.ps
11
- % pdflatex first.tex
12
- % acroread first.pdf
13
- \documentclass[12pt]{article}
14
- \title{First \LaTeX}
15
- \author{Foo}
16
- \date{\today}
17
-
18
- \begin{document}
19
-
20
- \maketitle
21
-
22
- \abstract{This is a very simple example of using \LaTeX\ for typesetting.
23
- The procedure for typesetting equations is introduced.}
24
-
25
- \section{A few equations}
26
- Equations can be typeset inline like so: $\vec{F}=m\vec{a}$ .
27
- Equations can also be separated form the text: $$ \vec{F}=m\vec{a} \ . $$
28
- Notice the punctuation, the ``.'', had to be included with the equation.
29
- Equations can also have a number assigned and a label attached,
30
- as in the following:
31
- \begin{equation}
32
- \frac{D\vec{\omega}}{Dt} =
33
- ( \vec{\omega} + \vec{\Omega}) \cdot \nabla \vec{U}
34
- + \frac{1}{\rho^2} \nabla \rho \times \nabla p
35
- + \nu \nabla^2 \vec{\omega}
36
- \label{vorteq}
37
- \end{equation}
38
- The vorticity equation (\ref{vorteq}) is referenced by label,
39
- not by number. The numbers may change as the document grows and
40
- more equations are added.
41
-
42
- New paragraphs are indicated with a blank line in the source code.
43
-
44
- \section{The End}
45
-
46
- Further examples of \LaTeX\ can be found at {\tt it.metr.ou.edu}
47
-
48
- \end{document}
@@ -1,48 +0,0 @@
1
- % This percent indicates a comment.
2
- % This is a very simple latex article that introduces the way
3
- % equations are typeset. Do this in linux:
4
- %
5
- % latex first.tex
6
- % latex first.tex
7
- % xdvi first.dvi
8
- % dvips -o first.ps first.dvi
9
- % gv first.ps
10
- % lpr first.ps
11
- % pdflatex first.tex
12
- % acroread first.pdf
13
- \documentclass[12pt]{article}
14
- \title{First \LaTeX}
15
- \author{}
16
- \date{\today}
17
-
18
- \begin{document}
19
-
20
- \maketitle
21
-
22
- \abstract{This is a very simple example of using \LaTeX\ for typesetting.
23
- The procedure for typesetting equations is introduced.}
24
-
25
- \section{A few equations}
26
- Equations can be typeset inline like so: $\vec{F}=m\vec{a}$ .
27
- Equations can also be separated form the text: $$ \vec{F}=m\vec{a} \ . $$
28
- Notice the punctuation, the ``.'', had to be included with the equation.
29
- Equations can also have a number assigned and a label attached,
30
- as in the following:
31
- \begin{equation}
32
- \frac{D\vec{\omega}}{Dt} =
33
- ( \vec{\omega} + \vec{\Omega}) \cdot \nabla \vec{U}
34
- + \frac{1}{\rho^2} \nabla \rho \times \nabla p
35
- + \nu \nabla^2 \vec{\omega}
36
- \label{vorteq}
37
- \end{equation}
38
- The vorticity equation (\ref{vorteq}) is referenced by label,
39
- not by number. The numbers may change as the document grows and
40
- more equations are added.
41
-
42
- New paragraphs are indicated with a blank line in the source code.
43
-
44
- \section{The End}
45
-
46
- Further examples of \LaTeX\ can be found at {\tt it.metr.ou.edu}
47
-
48
- \end{document}
@@ -1,48 +0,0 @@
1
- % This percent indicates a comment.
2
- % This is a very simple latex article that introduces the way
3
- % equations are typeset. Do this in linux:
4
- %
5
- % latex first.tex
6
- % latex first.tex
7
- % xdvi first.dvi
8
- % dvips -o first.ps first.dvi
9
- % gv first.ps
10
- % lpr first.ps
11
- % pdflatex first.tex
12
- % acroread first.pdf
13
- \documentclass[12pt]{article}
14
- \title{First \LaTeX}
15
- \author{Foo}
16
- \date{\today}
17
-
18
- \begin{document}
19
-
20
- \maketitle
21
-
22
- \abstract{This is a very simple example of using \LaTeX\ for typesetting.
23
- The procedure for typesetting equations is introduced.}
24
-
25
- \section{A few equations}
26
- Equations can be typeset inline like so: $\vec{F}=m\vec{a}$ .
27
- Equations can also be separated form the text: $$ \vec{F}=m\vec{a} \ . $$
28
- Notice the punctuation, the ``.'', had to be included with the equation.
29
- Equations can also have a number assigned and a label attached,
30
- as in the following:
31
- \begin{equation}
32
- \frac{D\vec{\omega}}{Dt} =
33
- ( \vec{\omega} + \vec{\Omega}) \cdot \nabla \vec{U}
34
- + \frac{1}{\rho^2} \nabla \rho \times \nabla p
35
- + \nu \nabla^2 \vec{\omega}
36
- \label{vorteq}
37
- \end{equation}
38
- The vorticity equation (\ref{vorteq}) is referenced by label,
39
- not by number. The numbers may change as the document grows and
40
- more equations are added.
41
-
42
- New paragraphs are indicated with a blank line in the source code.
43
-
44
- \section{The End}
45
-
46
- Further examples of \LaTeX\ can be found at {\tt it.metr.ou.edu}
47
-
48
- \end{document}