Class: Antex::Job
Overview
This class is the beating heart of Antex.
The simplest usage of this gem involves three steps:
# 1. Get a LaTeX snippet and initialize a job.
job = Antex::Job.new snippet: "Hello, \TeX world!"
# 2. Run the job!
job.run!
# 3. Do something neat with your new SVG file and its typesetting metrics.
job.files(:svg) # => "./.antex-cache/eb64793dafe3bbd963dc663385a22096.svg"
job.set_box.measures # => {:ex=>1, :wd=>17.03..., :mt=>-0.05..., ...}
The DEFAULTS are tuned to work with a basic latexmk/dvisvgm pipeline. To get started with customization. you’ll want to read the (not yet well documented) YAML source loaded into the constant at the github repo.
Constant Summary collapse
- DEFAULTS =
YAML.load_file(File.join(File.dirname(__FILE__), 'defaults.yml'), permitted_classes: [Regexp]).freeze
Instance Attribute Summary collapse
-
#dirs ⇒ Hash
readonly
The dirs paths rendered from the options.
-
#files ⇒ Hash
readonly
The files paths rendered from the options.
-
#hash ⇒ String
readonly
The unique hash identifying the job.
-
#options ⇒ Hash
readonly
The initialization options.
- #set_box ⇒ SetBox? readonly
Instance Method Summary collapse
-
#initialize(snippet: '', options: Antex::Job::DEFAULTS) ⇒ Job
constructor
A new instance of Job.
-
#run! ⇒ Object
Run the job, compile the
TeXsnippet and calculate the #set_box.
Methods included from LiquidHelpers
Constructor Details
#initialize(snippet: '', options: Antex::Job::DEFAULTS) ⇒ Job
Returns a new instance of Job.
52 53 54 55 56 57 58 59 60 |
# File 'lib/antex/job.rb', line 52 def initialize(snippet: '', options: Antex::Job::DEFAULTS) @options = @snippet = snippet prepare_code prepare_hash prepare_dirs prepare_files end |
Instance Attribute Details
#dirs ⇒ Hash (readonly)
Returns the dirs paths rendered from the options.
39 40 41 |
# File 'lib/antex/job.rb', line 39 def dirs @dirs end |
#files ⇒ Hash (readonly)
Returns the files paths rendered from the options.
42 43 44 |
# File 'lib/antex/job.rb', line 42 def files @files end |
#hash ⇒ String (readonly)
Returns the unique hash identifying the job.
45 46 47 |
# File 'lib/antex/job.rb', line 45 def hash @hash end |
#options ⇒ Hash (readonly)
Returns the initialization options.
36 37 38 |
# File 'lib/antex/job.rb', line 36 def @options end |
Instance Method Details
#run! ⇒ Object
Run the job, compile the TeX snippet and calculate the #set_box.
63 64 65 66 67 68 |
# File 'lib/antex/job.rb', line 63 def run! create_dirs write_code run_pipeline! load_set_box end |