class LTX::Config
Load config from project.yaml
Constants
- DEFAULT_MAIN_TEX
- DEFAULT_PROJECT_YAML
- MISSING_MAIN_ERROR
Attributes
compile_dir[R]
compiler[R]
main[R]
timeout[R]
title[R]
version[R]
version_prefix[R]
Public Class Methods
new()
click to toggle source
# File lib/ltx/config.rb, line 20 def initialize @config = load_config fetch_settings end
Public Instance Methods
root()
click to toggle source
# File lib/ltx/config.rb, line 25 def root File.dirname(@main) end
Private Instance Methods
fetch(name, n, default)
click to toggle source
# File lib/ltx/config.rb, line 36 def fetch(name, n, default) ARGV.fetch(n, @config.fetch(name, default)) end
fetch_compile_dir()
click to toggle source
# File lib/ltx/config.rb, line 58 def fetch_compile_dir base = File.basename(@main, '.*') File.absolute_path(fetch('compile_dir', 2, "tmp-#{base}")) end
fetch_main(mainfile = DEFAULT_MAIN_TEX)
click to toggle source
# File lib/ltx/config.rb, line 52 def fetch_main(mainfile = DEFAULT_MAIN_TEX) main = File.absolute_path(fetch('main', 0, mainfile)) raise MISSING_MAIN_ERROR unless File.exist?(main) main end
fetch_settings()
click to toggle source
# File lib/ltx/config.rb, line 40 def fetch_settings @main = fetch_main @compiler = fetch('compiler', 1, 'pdflatex') @compile_dir = fetch_compile_dir @timeout = fetch('timeout', 3, 60_000) @version = fetch('version', 5, '') @version_prefix = fetch('version_prefix', 5, ' - v') @title = fetch_title end
fetch_title()
click to toggle source
# File lib/ltx/config.rb, line 63 def fetch_title title = fetch('title', 4, 'output') if @version.nil? || @version == '' title else "#{title}#{@version_prefix}#{@version}" end end
load_config(file = DEFAULT_PROJECT_YAML)
click to toggle source
# File lib/ltx/config.rb, line 31 def load_config(file = DEFAULT_PROJECT_YAML) config_file = File.join(Dir.pwd, file) File.exist?(config_file) ? YAML.load_file(file) : {} end