Module: Metanorma::Compile::CompileOptions
- Included in:
- Metanorma::Compile
- Defined in:
- lib/metanorma/compile/compile_options.rb
Instance Method Summary collapse
- #extract_dir_options(options, options_in_file, filename) ⇒ Object
- #extract_extension_options(opt, doc_opt) ⇒ Object
- #extract_extensions(options) ⇒ Object
- #extract_flavor_options(options, options_in_file) ⇒ Object
- #extract_options(filename, options) ⇒ Object
- #extract_xml_options(file) ⇒ Object
- #font_install(opt) ⇒ Object
- #get_extensions(options) ⇒ Object
- #options_in_file(filename) ⇒ Object
- #require_libraries(options) ⇒ Object
Instance Method Details
#extract_dir_options(options, options_in_file, filename) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/metanorma/compile/compile_options.rb', line 54 def (, , filename) filename.is_a?(Tempfile) and return dir = filename.sub(%r(/[^/]+$), "/") [:relaton] and [:relaton] ||= File.join(dir, [:relaton]) [:sourcecode] and [:sourcecode] ||= File.join(dir, [:sourcecode]) end |
#extract_extension_options(opt, doc_opt) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/metanorma/compile/compile_options.rb', line 32 def (opt, doc_opt) opt[:extension_keys] == [:all] and opt[:extension_keys] = [] ext = opt[:extension_keys] || [] doc_opt[:extensions] == "all" and doc_opt[:extensions] = "" ext1 = (doc_opt[:extensions] || "").split(/, */).map(&:to_sym) !ext1.empty? && ext.empty? and opt[:extension_keys] = ext1 opt[:extension_keys]&.empty? and opt[:extension_keys] = nil end |
#extract_extensions(options) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/metanorma/compile/compile_options.rb', line 75 def extract_extensions() [:extension_keys] ||= @processor.output_formats.reduce([]) { |memo, (k, _)| memo << k } [:extension_keys].reduce([]) do |memo, e| if @processor.output_formats[e] then memo << e else unsupported_format_error(e) memo end end end |
#extract_flavor_options(options, options_in_file) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/metanorma/compile/compile_options.rb', line 47 def (, ) [:type] ||= [:type] [:type] = [:type]&.to_sym [:supplied_type] = [:type] t = @registry.alias([:type]) and [:type] = t end |
#extract_options(filename, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/metanorma/compile/compile_options.rb', line 20 def (filename, ) o = (filename) (, o) (, o, filename) (, o) [:format] ||= :asciidoc [:filename] = filename [:fontlicenseagreement] ||= "no-install-fonts" [:novalid] = o[:novalid] if o[:novalid] end |
#extract_xml_options(file) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/metanorma/compile/compile_options.rb', line 10 def (file) xml = Nokogiri::XML(file, &:huge) if xml.root @registry..each do |k, v| return { type: k } if v == xml.root.name end end {} end |
#font_install(opt) ⇒ Object
87 88 89 90 91 |
# File 'lib/metanorma/compile/compile_options.rb', line 87 def font_install(opt) @fontist_installed or Util::FontistHelper.install_fonts(@processor, opt) @fontist_installed = true end |
#get_extensions(options) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/metanorma/compile/compile_options.rb', line 65 def get_extensions() ext = extract_extensions() !ext.include?(:presentation) && ext.any? do |e| @processor.use_presentation_xml(e) end and ext << :presentation !ext.include?(:rxl) && [:site_generate] and ext << :rxl ext end |
#options_in_file(filename) ⇒ Object
41 42 43 44 45 |
# File 'lib/metanorma/compile/compile_options.rb', line 41 def (filename) content = read_file(filename) Metanorma::Input::Asciidoc.new.(content) .merge((content)) end |
#require_libraries(options) ⇒ Object
6 7 8 |
# File 'lib/metanorma/compile/compile_options.rb', line 6 def require_libraries() &.dig(:require)&.each { |r| require r } end |