Skip to content

Commit

Permalink
Consistent Module naming: metanorma/metanorma#367
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Oct 9, 2024
1 parent 7e4b0c3 commit 7299711
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 106 deletions.
1 change: 1 addition & 0 deletions Gemfile.devel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc", branch: "feature/ext-flavor"
4 changes: 2 additions & 2 deletions lib/isodoc/iho/base_convert.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module IsoDoc
module IHO
module Iho
module BaseConvert
# terms not defined in standoc
def error_parse(node, out)
Expand All @@ -11,7 +11,7 @@ def error_parse(node, out)
end

def configuration
Metanorma::IHO.configuration
Metanorma::Iho.configuration
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/iho/html_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "init"

module IsoDoc
module IHO
module Iho
class HtmlConvert < IsoDoc::Generic::HtmlConvert

include BaseConvert
Expand Down
6 changes: 3 additions & 3 deletions lib/isodoc/iho/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "xref"

module IsoDoc
module IHO
module Iho
module Init
def metadata_init(lang, script, locale, labels)
@meta = Metadata.new(lang, script, locale, labels)
Expand All @@ -18,12 +18,12 @@ def i18n_init(lang, script, locale, i18nyaml = nil)
@i18n = I18n.new(
lang, script, locale: locale,
i18nyaml: i18nyaml ||
Metanorma::IHO.configuration.i18nyaml || @i18nyaml
Metanorma::Iho.configuration.i18nyaml || @i18nyaml
)
end

def bibrenderer(options = {})
::Relaton::Render::IHO::General.new(options.merge(language: @lang,
::Relaton::Render::Iho::General.new(options.merge(language: @lang,
i18nhash: @i18n.get))
end

Expand Down
4 changes: 2 additions & 2 deletions lib/isodoc/iho/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "isodoc"

module IsoDoc
module IHO
module Iho

class Metadata < IsoDoc::Generic::Metadata
def configuration
Metanorma::IHO.configuration
Metanorma::Iho.configuration
end

def series(xml, _out)
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/iho/pdf_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "base_convert"

module IsoDoc
module IHO
module Iho
# A {Converter} implementation that generates PDF HTML output, and a
# document schema encapsulation of the document for validation
class PdfConvert < IsoDoc::Generic::PdfConvert
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/iho/presentation_xml_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative "../../relaton/render/general"

module IsoDoc
module IHO
module Iho
class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
def norm_ref_entry_code(ordinal, _idents, _ids, _standard, _datefn, _bib)
"[#{ordinal}]<tab/>"
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/iho/word_convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "init"

module IsoDoc
module IHO
module Iho
# A {Converter} implementation that generates Word output, and a document
# schema encapsulation of the document for validation
class WordConvert < IsoDoc::Generic::WordConvert
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/iho/xref.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "isodoc/generic/xref"

module IsoDoc
module IHO
module Iho
class Counter < IsoDoc::XrefGen::Counter
end

Expand Down
2 changes: 1 addition & 1 deletion lib/metanorma-iho.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

if defined? Metanorma::Registry
require_relative "metanorma/iho"
Metanorma::Registry.instance.register(Metanorma::IHO::Processor)
Metanorma::Registry.instance.register(Metanorma::Iho::Processor)
end
4 changes: 2 additions & 2 deletions lib/metanorma/iho.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "metanorma/iho/processor"

module Metanorma
module IHO
module Iho

class Configuration < Metanorma::Generic::Configuration
def initialize(*args)
Expand All @@ -29,4 +29,4 @@ def configure
configure {}
end
end
Metanorma::Registry.instance.register(Metanorma::IHO::Processor)
Metanorma::Registry.instance.register(Metanorma::Iho::Processor)
13 changes: 13 additions & 0 deletions lib/metanorma/iho/biblio-standoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ standards defining organization, and that is rendered in a distinct manner</a:do
from other documents in the same doctype</a:documentation>
</ref>
</optional>
<ref name="flavor">
<a:documentation>Flavour of Metanorma used to process this document</a:documentation>
</ref>
<optional>
<ref name="editorialgroup">
<a:documentation>Groups associated with the production of the standards document, typically within
Expand Down Expand Up @@ -113,6 +116,16 @@ a standards definition organization</a:documentation>
<define name="DocumentSubtype">
<text/>
</define>
<define name="flavor">
<element name="flavor">
<ref name="MetanormaFlavor"/>
</element>
</define>
<define name="MetanormaFlavor">
<a:documentation>This is in fact an enum, as of this writing: standoc iso generic ietf ieee itu nist ogc csa cc iho ribose jis iec bsi bipm plateau.
However we prefer not to hardcode it, given ongoing extension.</a:documentation>
<text/>
</define>
<define name="editorialgroup">
<a:documentation>A group associated with the production of the standards document, typically within
a standards definition organization</a:documentation>
Expand Down
31 changes: 19 additions & 12 deletions lib/metanorma/iho/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1382,18 +1382,7 @@ Applies whether the resource has already been created or not, and whether it is
<define name="bdate">
<a:documentation>Significant date in the lifecycle of the bibliographic item, including its production and its access</a:documentation>
<element name="date">
<attribute name="type">
<a:documentation>The phase of the production of or access to a bibliographic item</a:documentation>
<choice>
<ref name="BibliographicDateType"/>
<text/>
</choice>
</attribute>
<optional>
<attribute name="text">
<a:documentation>An optional textual description of the date, especially when a Gregorian date is not applicable</a:documentation>
</attribute>
</optional>
<ref name="bDateAttributes"/>
<optional>
<choice>
<group>
Expand All @@ -1416,6 +1405,20 @@ Applies whether the resource has already been created or not, and whether it is
</optional>
</element>
</define>
<define name="bDateAttributes">
<attribute name="type">
<a:documentation>The phase of the production of or access to a bibliographic item</a:documentation>
<choice>
<ref name="BibliographicDateType"/>
<text/>
</choice>
</attribute>
<optional>
<attribute name="text">
<a:documentation>An optional textual description of the date, especially when a Gregorian date is not applicable</a:documentation>
</attribute>
</optional>
</define>
<define name="docidentifier">
<a:documentation>An identifier of a bibliographic item in an international standard scheme</a:documentation>
<element name="docidentifier">
Expand Down Expand Up @@ -1884,6 +1887,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
<value>hasAnnotation</value>
<value>draftOf</value>
<value>hasDraft</value>
<value>preliminaryDraftOf</value>
<value>hasPreliminaryDraft</value>
<value>revisionDraftOf</value>
<value>hasRevisionDraft</value>
<value>editionOf</value>
<value>hasEdition</value>
<value>updates</value>
Expand Down
14 changes: 7 additions & 7 deletions lib/metanorma/iho/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "metanorma/generic/converter"

module Metanorma
module IHO
module Iho
class Converter < Metanorma::Generic::Converter
XML_ROOT_TAG = "iho-standard".freeze
XML_NAMESPACE = "https://www.metanorma.org/ns/iho".freeze
Expand Down Expand Up @@ -97,27 +97,27 @@ def metadata_version(node, xml)
end

def configuration
Metanorma::IHO.configuration
Metanorma::Iho.configuration
end

def presentation_xml_converter(node)
IsoDoc::IHO::PresentationXMLConvert
IsoDoc::Iho::PresentationXMLConvert
.new(html_extract_attributes(node)
.merge(output_formats: ::Metanorma::IHO::Processor.new.output_formats))
.merge(output_formats: ::Metanorma::Iho::Processor.new.output_formats))
end

def html_converter(node)
IsoDoc::IHO::HtmlConvert.new(html_extract_attributes(node))
IsoDoc::Iho::HtmlConvert.new(html_extract_attributes(node))
end

def pdf_converter(node)
return nil if node.attr("no-pdf")

IsoDoc::IHO::PdfConvert.new(pdf_extract_attributes(node))
IsoDoc::Iho::PdfConvert.new(pdf_extract_attributes(node))
end

def doc_converter(node)
IsoDoc::IHO::WordConvert.new(doc_extract_attributes(node))
IsoDoc::Iho::WordConvert.new(doc_extract_attributes(node))
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/metanorma/iho/processor.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require "metanorma/processor"

module Metanorma
module IHO
module Iho
class Processor < Metanorma::Generic::Processor
def configuration
Metanorma::IHO.configuration
Metanorma::Iho.configuration
end

def output_formats
Expand All @@ -16,20 +16,20 @@ def output_formats
end

def version
"Metanorma::IHO #{Metanorma::IHO::VERSION}"
"Metanorma::Iho #{Metanorma::Iho::VERSION}"
end

def output(isodoc_node, inname, outname, format, options={})
options_preprocess(options)
case format
when :html
IsoDoc::IHO::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
IsoDoc::Iho::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
when :doc
IsoDoc::IHO::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
IsoDoc::Iho::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
when :pdf
IsoDoc::IHO::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
IsoDoc::Iho::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
when :presentation
IsoDoc::IHO::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
IsoDoc::Iho::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
else
super
end
Expand Down
1 change: 1 addition & 0 deletions lib/metanorma/iho/relaton-iho.rng
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<optional>
<ref name="docsubtype"/>
</optional>
<ref name="flavor"/>
<zeroOrMore>
<ref name="editorialgroup"/>
</zeroOrMore>
Expand Down
2 changes: 1 addition & 1 deletion lib/metanorma/iho/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Metanorma
module IHO
module Iho
VERSION = "1.0.4".freeze
end
end
2 changes: 1 addition & 1 deletion lib/relaton/render/fields.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Relaton
module Render
module IHO
module Iho
class Fields < ::Relaton::Render::Fields
def edition_fields_format(hash)
super
Expand Down
6 changes: 3 additions & 3 deletions lib/relaton/render/general.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

module Relaton
module Render
module IHO
module Iho
class General < ::Relaton::Render::IsoDoc::General
def config_loc
YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
end

def klass_initialize(_options)
super
@fieldsklass = Relaton::Render::IHO::Fields
@parseklass = Relaton::Render::IHO::Parse
@fieldsklass = Relaton::Render::Iho::Fields
@parseklass = Relaton::Render::Iho::Parse
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton/render/parse.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Relaton
module Render
module IHO
module Iho
class Parse < ::Relaton::Render::Parse
def uri(doc)
uri = nil
Expand Down
2 changes: 1 addition & 1 deletion metanorma-iho.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "metanorma/iho/version"

Gem::Specification.new do |spec|
spec.name = "metanorma-iho"
spec.version = Metanorma::IHO::VERSION
spec.version = Metanorma::Iho::VERSION
spec.authors = ["Ribose Inc."]
spec.email = ["[email protected]"]

Expand Down
14 changes: 7 additions & 7 deletions spec/isodoc/html_convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"..", "..", "lib", "isodoc", "iho", "html"
)).cleanpath.to_s

RSpec.describe IsoDoc::IHO do
RSpec.describe IsoDoc::Iho do
it "processes default metadata" do
csdc = IsoDoc::IHO::HtmlConvert.new({})
csdc = IsoDoc::Iho::HtmlConvert.new({})
input = <<~"INPUT"
<iho-standard xmlns="https://open.ribose.com/standards/iho">
<bibdata type="standard">
Expand Down Expand Up @@ -252,7 +252,7 @@
</bibliography>
</iho-standard>
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::IHO::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::Iho::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)
.sub(%r{<i18nyaml>.*</i18nyaml>}m, ""))))
Expand Down Expand Up @@ -432,7 +432,7 @@
</bibliography>
</iho-standard>
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::IHO::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::Iho::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)
.sub(%r{<i18nyaml>.*</i18nyaml>}m, ""))))
Expand Down Expand Up @@ -698,12 +698,12 @@
</div>
</body>
OUTPUT
expect(Xml::C14n.format(strip_guid(IsoDoc::IHO::PresentationXMLConvert
expect(Xml::C14n.format(strip_guid(IsoDoc::Iho::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true)
.sub(%r{<localized-strings>.*</localized-strings>}m, ""))))
.to be_equivalent_to Xml::C14n.format(presxml)
expect(Xml::C14n.format(IsoDoc::IHO::HtmlConvert.new({})
expect(Xml::C14n.format(IsoDoc::Iho::HtmlConvert.new({})
.convert("test", presxml, true)
.gsub(%r{^.*<body}m, "<body")
.gsub(%r{</body>.*}m, "</body>")))
Expand Down Expand Up @@ -1123,7 +1123,7 @@
</preface>
OUTPUT
expect(Xml::C14n.format(strip_guid(Nokogiri::XML(
IsoDoc::IHO::PresentationXMLConvert
IsoDoc::Iho::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true),
)
Expand Down
Loading

0 comments on commit 7299711

Please sign in to comment.