latex-flow 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +7 -0
- data/bin/latex-flow +3 -0
- data/latex-flow.gemspec +32 -0
- data/lib/latex-flow.rb +3 -0
- data/lib/latex-flow/cli.rb +77 -0
- data/lib/latex-flow/cli/archive.rb +20 -0
- data/lib/latex-flow/cli/archives.rb +19 -0
- data/lib/latex-flow/cli/bibtex.rb +15 -0
- data/lib/latex-flow/cli/build.rb +130 -0
- data/lib/latex-flow/cli/clean.rb +14 -0
- data/lib/latex-flow/cli/dvipdfm.rb +15 -0
- data/lib/latex-flow/cli/generic.rb +13 -0
- data/lib/latex-flow/cli/latex.rb +15 -0
- data/lib/latex-flow/cli/version.rb +12 -0
- data/lib/latex-flow/tools.rb +4 -0
- data/lib/latex-flow/tools/bibtex.rb +22 -0
- data/lib/latex-flow/tools/dvipdfm.rb +19 -0
- data/lib/latex-flow/tools/generic.rb +47 -0
- data/lib/latex-flow/tools/latex.rb +39 -0
- data/lib/latex-flow/version.rb +3 -0
- data/spec/latex-box_spec.rb +10 -0
- data/spec/spec_helper.rb +2 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e7e12cbaffabc46749844ed1401f5fdbd63852b
|
4
|
+
data.tar.gz: 2914930270bffd4ac1eb67b8757280a0b7c45ae7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f47a732657755250fff0368455e9396599a9d0eb3b19ae825662f8398c34482d664ba440fb39a56dccf6516b2b1ae45a2a3bf43a08c14743b3469c287d795fe
|
7
|
+
data.tar.gz: 6089da5b131e472c3ea90f336f188122b620ea5bb8e93346cb60f2d981b9abcc1f56e98ec26ee7b90b6e54b706c3fc2647647a497b9e1341aaef0b12c00d8853
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 s032047
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
[![Version](https://img.shields.io/gem/v/latex-flow.svg)](https://rubygems.org/gems/latex-flow)
|
2
|
+
|
3
|
+
# latex-flow
|
4
|
+
|
5
|
+
Latex-flow is a command-line tool to support LaTeX's workflow.
|
6
|
+
|
7
|
+
**This is a beta version.**
|
8
|
+
|
9
|
+
## Features
|
10
|
+
|
11
|
+
- **Command Wrapper** for LaTeX, BibTex, and Dvipdfm
|
12
|
+
- **Syntax Highlight of Logs** for LaTeX, BibTeX, and Dvipdfm
|
13
|
+
- **Automated build** by monitoring change of source files (*.tex|*.bib)
|
14
|
+
- **Archiving** of source files
|
15
|
+
- TODO: **LaTeX's template manager and repository**
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
$ gem install latex-flow
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Automated Build
|
24
|
+
|
25
|
+
```
|
26
|
+
$ ls
|
27
|
+
main.tex main.bib
|
28
|
+
$ latex-flow build main --auto --color --verbose
|
29
|
+
```
|
30
|
+
|
31
|
+
### Environment Variables
|
32
|
+
|
33
|
+
- `LATEX`
|
34
|
+
- `BIBTEX`
|
35
|
+
- `DVIPDFM`
|
36
|
+
|
37
|
+
#### Example
|
38
|
+
|
39
|
+
```
|
40
|
+
LATEX='platex -kanji=utf8 -halt-on-error' BIBTEX='pbibtex -kanji=utf8' DVIPDFM='dvipdfmx' latex-flow build main --auto --color --verbose
|
41
|
+
```
|
42
|
+
|
43
|
+
### Help
|
44
|
+
|
45
|
+
```
|
46
|
+
$ latex-flow help
|
47
|
+
Commands:
|
48
|
+
latex-flow archive TAG # Archive files into ./archives/1404138641-[TAG].zip
|
49
|
+
latex-flow archives # Show a list of archives in ./archives/
|
50
|
+
latex-flow bibtex TARGET [OPTIONS] # Execute the bibtex command
|
51
|
+
latex-flow build TARGET [OPTIONS] # Build a pdf file
|
52
|
+
latex-flow clean # Remove any temporary files
|
53
|
+
latex-flow dvipdfm TARGET [OPTIONS] # Execute the dvipdfm command
|
54
|
+
latex-flow help [COMMAND] # Describe available commands or one specific command
|
55
|
+
latex-flow latex TARGET [OPTIONS] # Execute the latex command
|
56
|
+
latex-flow version # Show LatexFlow's version information
|
57
|
+
|
58
|
+
Options:
|
59
|
+
-V, [--verbose=Enable verbose output mode], [--no-verbose]
|
60
|
+
-C, [--color=Enable color output mode], [--no-color]
|
61
|
+
```
|
data/Rakefile
ADDED
data/bin/latex-flow
ADDED
data/latex-flow.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'latex-flow/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "latex-flow"
|
8
|
+
spec.version = LatexFlow::VERSION
|
9
|
+
spec.authors = ["Masayuki Higashino"]
|
10
|
+
spec.email = ["mh.on.web@gmail.com"]
|
11
|
+
spec.summary = %q{Latex-flow is a command-line tool to support LaTeX's workflow.}
|
12
|
+
spec.description = %q{Latex-flow is a command-line tool to support LaTeX's workflow.}
|
13
|
+
spec.homepage = "https://github.com/mh61503891/latex-flow"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "systemu"
|
23
|
+
spec.add_dependency "watchr"
|
24
|
+
spec.add_dependency "highline"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
|
31
|
+
spec.post_install_message = "Nyanpass~!"
|
32
|
+
end
|
data/lib/latex-flow.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module LatexFlow
|
4
|
+
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
class_option :verbose, type:'boolean', banner:'Enable verbose output mode', aliases:'-V'
|
8
|
+
class_option :color, type:'boolean', banner:'Enable color output mode', aliases:'-C'
|
9
|
+
|
10
|
+
desc 'version', 'Show LatexFlow\'s version information'
|
11
|
+
def version
|
12
|
+
require 'latex-flow/cli/version'
|
13
|
+
CLI::Version.new(options).run
|
14
|
+
end
|
15
|
+
map %w(-v --version) => :version
|
16
|
+
|
17
|
+
desc 'clean', 'Remove any temporary files'
|
18
|
+
def clean
|
19
|
+
require 'latex-flow/cli/clean'
|
20
|
+
CLI::Clean.new(options).run
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'archive TAG', "Archive files into ./archives/#{Time.new.to_i}-[TAG].zip"
|
24
|
+
def archive(tag)
|
25
|
+
require 'latex-flow/cli/archive'
|
26
|
+
CLI::Archive.new(options.merge(tag:tag)).run
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'archives', 'Show a list of archives in ./archives/'
|
30
|
+
def archives
|
31
|
+
require 'latex-flow/cli/archives'
|
32
|
+
CLI::Archives.new(options).run
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'latex TARGET [OPTIONS]', 'Execute the latex command'
|
36
|
+
def latex(target)
|
37
|
+
require 'latex-flow/cli/latex'
|
38
|
+
CLI::LaTeX.new(options.merge({target:target})).run
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'bibtex TARGET [OPTIONS]', 'Execute the bibtex command'
|
42
|
+
def bibtex(target)
|
43
|
+
require 'latex-flow/cli/bibtex'
|
44
|
+
CLI::BibTeX.new(options.merge({target:target})).run
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'dvipdfm TARGET [OPTIONS]', 'Execute the dvipdfm command'
|
48
|
+
def dvipdfm(target)
|
49
|
+
require 'latex-flow/cli/dvipdfm'
|
50
|
+
CLI::Dvipdfm.new(options.merge({target:target})).run
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'build TARGET [OPTIONS]', 'Build a pdf file'
|
54
|
+
method_option :auto, type:'boolean'
|
55
|
+
method_option 'latex-max-count', type:'numeric', banner:'<count>', default:5
|
56
|
+
def build(target)
|
57
|
+
require 'latex-flow/cli/build'
|
58
|
+
CLI::Build.new(options.merge({target:target})).run
|
59
|
+
end
|
60
|
+
|
61
|
+
# TODO
|
62
|
+
# desc 'info [OPTIONS]', 'Show information of the LaTeX\'s project'
|
63
|
+
# def info
|
64
|
+
# end
|
65
|
+
|
66
|
+
# TODO
|
67
|
+
# desc 'new NAME [OPTIONS]', 'Create a new LaTeX\'s project from a template specified by NAME'
|
68
|
+
# def new(name)
|
69
|
+
# end
|
70
|
+
|
71
|
+
# TODO
|
72
|
+
# desc 'searh QUERY [OPTIONS]', 'Search and Display LaTeX\'s templates by QUERY on remote repositories'
|
73
|
+
# def search(query)
|
74
|
+
# end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
|
3
|
+
module LatexFlow
|
4
|
+
class CLI::Archive < CLI::Generic
|
5
|
+
|
6
|
+
def run
|
7
|
+
require 'rake/packagetask'
|
8
|
+
tag = @options[:tag]
|
9
|
+
version = Time.new.to_i.to_s
|
10
|
+
Rake::PackageTask.new(tag, version) do |p|
|
11
|
+
p.package_dir = "./archives"
|
12
|
+
p.package_files.include("**")
|
13
|
+
p.package_files.exclude('archives')
|
14
|
+
p.need_zip = true
|
15
|
+
end
|
16
|
+
Rake::Task[:package].invoke
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
|
3
|
+
module LatexFlow
|
4
|
+
class CLI::Archives < CLI::Generic
|
5
|
+
|
6
|
+
def run
|
7
|
+
Dir.glob(File.join('archives', '*.zip')).map{ |archive|
|
8
|
+
basename = File.basename(archive)
|
9
|
+
time = basename.scan(/\A.+\-(\d+)\..+\Z/).first.first.to_i
|
10
|
+
[time, archive]
|
11
|
+
}.sort_by{ |time, archive|
|
12
|
+
time
|
13
|
+
}.each do |time, archive|
|
14
|
+
puts "#{Time.at(time.to_i)}\t#{archive}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
require 'latex-flow/tools/bibtex'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class CLI::BibTeX < CLI::Generic
|
6
|
+
|
7
|
+
def run
|
8
|
+
t = Tools::BibTeX.new("#{ENV.fetch('BIBTEX', 'bibtex')} #{@options[:target]}")
|
9
|
+
t.run
|
10
|
+
$stderr.puts t.messages(color:@options[:color]) if @options[:verbose]
|
11
|
+
exit(false) if !t.success?
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
|
3
|
+
module LatexFlow
|
4
|
+
class CLI::Build < CLI::Generic
|
5
|
+
|
6
|
+
def run
|
7
|
+
@options[:auto] ? auto_build : build
|
8
|
+
end
|
9
|
+
|
10
|
+
def build
|
11
|
+
task
|
12
|
+
end
|
13
|
+
|
14
|
+
def auto_build
|
15
|
+
require 'watchr'
|
16
|
+
require 'digest/md5'
|
17
|
+
|
18
|
+
@executor = Class.new {
|
19
|
+
def submit(path, &task)
|
20
|
+
current_hash = Digest::MD5.file(path).to_s
|
21
|
+
@hashes ||= {}
|
22
|
+
if @hashes[path] != current_hash
|
23
|
+
task.call()
|
24
|
+
@hashes[path] = current_hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}.new
|
28
|
+
|
29
|
+
script = Watchr::Script.new
|
30
|
+
script.watch('.*\.tex|.*\.bib') do |m|
|
31
|
+
@executor.submit(m[0]) do
|
32
|
+
task
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
Watchr::Controller.new(script, Watchr.handler.new).run
|
37
|
+
end
|
38
|
+
|
39
|
+
def task
|
40
|
+
(@options['latex-max-count']).times do
|
41
|
+
# latex
|
42
|
+
require 'latex-flow/tools/latex'
|
43
|
+
latex = Tools::LaTeX.new("#{ENV.fetch('LATEX', 'latex -halt-on-error')} #{@options[:target]}")
|
44
|
+
latex.run
|
45
|
+
$stderr.puts latex.messages(color:@options[:color]) if @options[:verbose]
|
46
|
+
return if !latex.success?
|
47
|
+
# bibtex
|
48
|
+
if use_bibtex? && latex.need_bibtex?
|
49
|
+
require 'latex-flow/tools/bibtex'
|
50
|
+
bibtex = Tools::BibTeX.new("#{ENV.fetch('BIBTEX', 'bibtex')} #{@options[:target]}")
|
51
|
+
bibtex.run
|
52
|
+
$stderr.puts bibtex.messages(color:@options[:color]) if @options[:verbose]
|
53
|
+
return if !bibtex.success?
|
54
|
+
next
|
55
|
+
else
|
56
|
+
break if !latex.next?
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# dvipdfm
|
61
|
+
require 'latex-flow/tools/dvipdfm'
|
62
|
+
dvipdfm = Tools::Dvipdfm.new("#{ENV.fetch('DVIPDFM', 'dvipdfm')} #{@options[:target]}")
|
63
|
+
dvipdfm.run
|
64
|
+
$stderr.puts dvipdfm.messages(color:@options[:color]) if @options[:verbose]
|
65
|
+
return if !dvipdfm.success?
|
66
|
+
|
67
|
+
|
68
|
+
# # latex
|
69
|
+
# require 'latex-flow/tools/latex'
|
70
|
+
# latex = Tools::LaTeX.new("#{ENV.fetch('LATEX', 'latex -halt-on-error')} #{@options[:target]}")
|
71
|
+
# latex.run
|
72
|
+
# $stderr.puts latex.messages(color:@options[:color]) if @options[:verbose]
|
73
|
+
# return if !latex.success?
|
74
|
+
|
75
|
+
|
76
|
+
# # bibtex
|
77
|
+
# if use_bibtex?
|
78
|
+
# require 'latex-flow/tools/bibtex'
|
79
|
+
# bibtex = Tools::BibTeX.new("#{ENV.fetch('BIBTEX', 'bibtex')} #{@options[:target]}")
|
80
|
+
# bibtex.run
|
81
|
+
# $stderr.puts bibtex.messages(color:@options[:color]) if @options[:verbose]
|
82
|
+
# return if !bibtex.success?
|
83
|
+
# end
|
84
|
+
|
85
|
+
# # latex(loop)
|
86
|
+
# if latex.next?
|
87
|
+
# (@options['latex-max-count']-2).times do
|
88
|
+
# require 'latex-flow/tools/latex'
|
89
|
+
# latex = Tools::LaTeX.new("#{ENV.fetch('LATEX', 'latex -halt-on-error')} #{@options[:target]}")
|
90
|
+
# latex.run
|
91
|
+
# $stderr.puts latex.messages(color:@options[:color]) if @options[:verbose]
|
92
|
+
# return if !latex.success?
|
93
|
+
# latex.next? ? next : break
|
94
|
+
# end
|
95
|
+
# end
|
96
|
+
|
97
|
+
# dvipdfm
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
def latex
|
102
|
+
require 'latex-flow/tools/latex'
|
103
|
+
latex = Tools::LaTeX.new("#{ENV.fetch('LATEX', 'latex -halt-on-error')} #{@options[:target]}")
|
104
|
+
latex.run
|
105
|
+
$stderr.puts latex.messages(color:@options[:color]) if @options[:verbose]
|
106
|
+
latex.success?
|
107
|
+
end
|
108
|
+
|
109
|
+
def bibtex
|
110
|
+
require 'latex-flow/tools/bibtex'
|
111
|
+
bibtex = Tools::BibTeX.new("#{ENV.fetch('BIBTEX', 'bibtex')} #{@options[:target]}")
|
112
|
+
bibtex.run
|
113
|
+
$stderr.puts bibtex.messages(color:@options[:color]) if @options[:verbose]
|
114
|
+
bibtex.success?
|
115
|
+
end
|
116
|
+
|
117
|
+
def dvipdfm
|
118
|
+
require 'latex-flow/tools/dvipdfm'
|
119
|
+
dvipdfm = Tools::Dvipdfm.new("#{ENV.fetch('DVIPDFM', 'dvipdfm')} #{@options[:target]}")
|
120
|
+
dvipdfm.run
|
121
|
+
$stderr.puts dvipdfm.messages(color:@options[:color]) if @options[:verbose]
|
122
|
+
dvipdfm.success?
|
123
|
+
end
|
124
|
+
|
125
|
+
def use_bibtex?
|
126
|
+
@use_bibtex ||= !File.read(@options[:target] + '.tex').scan(/(^[^%\n]*?\\bibliography\{.+?\}.*$)/).flatten.empty?
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class CLI::Clean < CLI::Generic
|
6
|
+
|
7
|
+
# TODO: support verbose
|
8
|
+
def run
|
9
|
+
CLEAN.include(%w{aux log dvi bbl blg toc lof lot fdb_latexmk fls out bb xbb DS_Store}.map{|e|"**/*.#{e}"})
|
10
|
+
Rake::Task[:clean].execute
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
require 'latex-flow/tools/dvipdfm'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class CLI::Dvipdfm < CLI::Generic
|
6
|
+
|
7
|
+
def run
|
8
|
+
t = Tools::Dvipdfm.new("#{ENV.fetch('DVIPDFM', 'dvipdfm')} #{@options[:target]}")
|
9
|
+
t.run
|
10
|
+
$stderr.puts t.messages(color:@options[:color]) if @options[:verbose]
|
11
|
+
exit(false) if !t.success?
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'latex-flow/cli/generic'
|
2
|
+
require 'latex-flow/tools/latex'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class CLI::LaTeX < CLI::Generic
|
6
|
+
|
7
|
+
def run
|
8
|
+
t = Tools::LaTeX.new("#{ENV.fetch('LATEX', 'latex -halt-on-error')} #{@options[:target]}")
|
9
|
+
t.run
|
10
|
+
$stderr.puts t.messages(color:@options[:color]) if @options[:verbose]
|
11
|
+
exit(false) if !t.success?
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'latex-flow/tools/generic'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class Tools::BibTeX < Tools::Generic
|
6
|
+
|
7
|
+
def initialize(command)
|
8
|
+
super(command)
|
9
|
+
end
|
10
|
+
|
11
|
+
def messages_with_color
|
12
|
+
messages.dup.tap do |m|
|
13
|
+
m.gsub!(/\A.+$/, HighLine.new.color('\0', :green))
|
14
|
+
m.gsub!(/^Warning/, HighLine.new.color('\0', :yellow))
|
15
|
+
m.gsub!(/(There were \d+ warnings)/, HighLine.new.color('\0', :red))
|
16
|
+
# for pBibTex
|
17
|
+
m.gsub!(/(There were \d+ error messages)/, HighLine.new.color('\0', :red))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'latex-flow/tools/generic'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class Tools::Dvipdfm < Tools::Generic
|
6
|
+
|
7
|
+
def initialize(command)
|
8
|
+
super(command)
|
9
|
+
end
|
10
|
+
|
11
|
+
def messages_with_color
|
12
|
+
messages.dup.tap do |m|
|
13
|
+
m.gsub!(/.* -> .*/, HighLine.new.color('\0', :green))
|
14
|
+
m.gsub!(/\*\* ERROR \*\*/, HighLine.new.color('\0', :red))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'systemu'
|
2
|
+
|
3
|
+
module LatexFlow
|
4
|
+
module Tools
|
5
|
+
class Generic
|
6
|
+
|
7
|
+
attr_reader :command, :process, :stdout, :stderr
|
8
|
+
|
9
|
+
def initialize(command)
|
10
|
+
@command = command
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
@process, @stdout, @stderr = systemu(@command)
|
15
|
+
end
|
16
|
+
|
17
|
+
def success?
|
18
|
+
@process.success?
|
19
|
+
end
|
20
|
+
|
21
|
+
def stdout
|
22
|
+
@stdout
|
23
|
+
end
|
24
|
+
|
25
|
+
def stdout_with_color
|
26
|
+
@stdout
|
27
|
+
end
|
28
|
+
|
29
|
+
def stderr
|
30
|
+
@stderr
|
31
|
+
end
|
32
|
+
|
33
|
+
def stderr_with_color
|
34
|
+
@stderr
|
35
|
+
end
|
36
|
+
|
37
|
+
def messages(color:false)
|
38
|
+
color ? messages_with_color : @stdout + $/ + @stderr
|
39
|
+
end
|
40
|
+
|
41
|
+
def messages_with_color
|
42
|
+
@stdout + $/ + @stderr
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'latex-flow/tools/generic'
|
2
|
+
require 'highline'
|
3
|
+
|
4
|
+
module LatexFlow
|
5
|
+
class Tools::LaTeX < Tools::Generic
|
6
|
+
|
7
|
+
def initialize(command)
|
8
|
+
super(command)
|
9
|
+
end
|
10
|
+
|
11
|
+
def messages_with_color
|
12
|
+
messages.dup.tap do |m|
|
13
|
+
m.gsub!(/\A.+$/, HighLine.new.color('\0', :green))
|
14
|
+
m.gsub!(/^Document Class:/ , HighLine.new.color('\0', :green))
|
15
|
+
m.gsub!(/^LaTeX Font Warning:/, HighLine.new.color('\0', :yellow))
|
16
|
+
m.gsub!(/^(LaTeX Warning)(: Citation)/, HighLine.new.color('\1', :yellow) + '\2')
|
17
|
+
m.gsub!(/^(LaTeX Warning)(: Reference)/, HighLine.new.color('\1', :yellow) + '\2')
|
18
|
+
m.gsub!(/^(LaTeX Warning)(: Label\(s\))/, HighLine.new.color('\1', :yellow) + '\2')
|
19
|
+
m.gsub!(/^No file .+\.bbl\./, HighLine.new.color('\0', :red))
|
20
|
+
m.gsub!(/^(LaTeX Warning:)( There were undefined references\.)/, HighLine.new.color('\1', :red) + '\2')
|
21
|
+
m.gsub!(/^! LaTeX Error:/, HighLine.new.color('\0', :red))
|
22
|
+
# platex
|
23
|
+
m.gsub!(/^warning:/, HighLine.new.color('\0', :yellow))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def next?
|
28
|
+
stdout =~ /LaTeX Warning: Label\(s\) may have changed\./
|
29
|
+
end
|
30
|
+
|
31
|
+
def need_bibtex?
|
32
|
+
return true if stdout =~ /No file .+?\.bbl/
|
33
|
+
return true if messages =~ /^LaTeX Warning: Citation/
|
34
|
+
return true if messages =~ /^LaTeX Warning: Label\(s\) may have changed\./
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: latex-flow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masayuki Higashino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: systemu
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: watchr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Latex-flow is a command-line tool to support LaTeX's workflow.
|
126
|
+
email:
|
127
|
+
- mh.on.web@gmail.com
|
128
|
+
executables:
|
129
|
+
- latex-flow
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- .travis.yml
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/latex-flow
|
141
|
+
- latex-flow.gemspec
|
142
|
+
- lib/latex-flow.rb
|
143
|
+
- lib/latex-flow/cli.rb
|
144
|
+
- lib/latex-flow/cli/archive.rb
|
145
|
+
- lib/latex-flow/cli/archives.rb
|
146
|
+
- lib/latex-flow/cli/bibtex.rb
|
147
|
+
- lib/latex-flow/cli/build.rb
|
148
|
+
- lib/latex-flow/cli/clean.rb
|
149
|
+
- lib/latex-flow/cli/dvipdfm.rb
|
150
|
+
- lib/latex-flow/cli/generic.rb
|
151
|
+
- lib/latex-flow/cli/latex.rb
|
152
|
+
- lib/latex-flow/cli/version.rb
|
153
|
+
- lib/latex-flow/tools.rb
|
154
|
+
- lib/latex-flow/tools/bibtex.rb
|
155
|
+
- lib/latex-flow/tools/dvipdfm.rb
|
156
|
+
- lib/latex-flow/tools/generic.rb
|
157
|
+
- lib/latex-flow/tools/latex.rb
|
158
|
+
- lib/latex-flow/version.rb
|
159
|
+
- spec/latex-box_spec.rb
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
homepage: https://github.com/mh61503891/latex-flow
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message: Nyanpass~!
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.0.14
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: Latex-flow is a command-line tool to support LaTeX's workflow.
|
185
|
+
test_files:
|
186
|
+
- spec/latex-box_spec.rb
|
187
|
+
- spec/spec_helper.rb
|