require "simplecov"
SimpleCov.start do
add_filter "/spec/"
end
require "bundler/setup"
require "asciidoctor"
require "metanorma-iso"
require "rspec/matchers"
require "equivalent-xml"
require "metanorma"
require "metanorma/iso"
require "iev"
require "rexml/document"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
def strip_guid(x)
x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"')
end
def xmlpp(x)
s = ""
f = REXML::Formatters::Pretty.new(2)
f.compact = true
f.write(REXML::Document.new(x),s)
s
end
ASCIIDOC_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib:
HDR
ISOBIB_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:no-isobib-cache:
HDR
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:flush-caches:
HDR
CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
HDR
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:novalid:
:local-cache:
HDR
VALIDATING_BLANK_HDR = <<~"HDR"
= Document title
Author
:docfile: test.adoc
:nodoc:
:no-isobib:
HDR
BOILERPLATE =
HTMLEntities.new.decode(
File.read(File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iso", "boilerplate.xml"), encoding: "utf-8").
gsub(/\{\{ agency \}\}/, "ISO").gsub(/\{\{ docyear \}\}/, Date.today.year.to_s).
gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "").
gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’")
)
BLANK_HDR = <<~"HDR"
For the purposes of this document,
the following terms and definitions apply. ISO and IEC maintain terminological databases for use in
standardization at the following addresses: ISO Online browsing platform: available at
IEC Electropedia: available at
END
HTML_HDR = <<~END