mn-requirements 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e8561bbfa3412485e724742474078348fffb06c9687bcf2cb18d815027ab5df2
4
+ data.tar.gz: e9d8755e0ba593ca3e308e579bb0abea161ccd0bac385d4e8ef58f946b083c6a
5
+ SHA512:
6
+ metadata.gz: f8a0464554be764a948a3aa9a2531dbb0959e867d28c51d5ba9e25febd1e27260d810eae70a15001bedf95bddb386c6d59c0693a2eb8e73c16018ce4bb5c93ca
7
+ data.tar.gz: 16afa9642145d263f50ee5e7cd62d9f27ac6ff852250785195ad32d06e6498ca865164b37637fe75ac7069656f5c6d50cf529bcf36ac14af918e06f8ed965c2e
@@ -0,0 +1,15 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/graphviz-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -0,0 +1,24 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: metanorma/metanorma-build-scripts/.github/workflows/rubygems-release.yml@main
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ event_name: ${{ github.event_name }}
22
+ secrets:
23
+ rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
24
+
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
11
+
12
+ Metrics/MethodLength:
13
+ CountAsOne: ['array', 'heredoc']
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ source "https://rubygems.org"
5
+ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
+
7
+ gemspec
8
+
9
+ if File.exist? "Gemfile.devel"
10
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
+ end
12
+
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2022, Metanorma
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,26 @@
1
+ = mn-requirements: Requirements processing and rendering according to different models
2
+
3
+ image:https://img.shields.io/gem/v/mn-requirements.svg["Gem Version", link="https://rubygems.org/gems/mn-requirements"]
4
+ image:https://github.com/metanorma/mn-requirements/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/mn-requirements/actions?workflow=rake"]
5
+ image:https://codeclimate.com/github/metanorma/mn-requirements/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/mn-requirements"]
6
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/mn-requirements.svg["Pull Requests", link="https://github.com/metanorma/mn-requirements/pulls"]
7
+ image:https://img.shields.io/github/commits-since/metanorma/mn-requirements/latest.svg["Commits since latest",link="https://github.com/metanorma/mn-requirements/releases"]
8
+
9
+ == Functionality
10
+
11
+ This gem supports the processing of Requirements models and their rendering in the https://metanorma.org[Metanorma]
12
+ toolset, allowing various models to be processed. The gem currently supports:
13
+
14
+ `metanorma`:: Default Metanorma Requiremnts model
15
+ `ogc`:: OGC Modspec
16
+
17
+ == Usage
18
+
19
+ Within Metanorma, a requirement is specified as being of a particular type; e.g.
20
+
21
+ [source,asciidoc]
22
+ ----
23
+ [requirement,type=ogc]
24
+ ...
25
+ ...
26
+ ----
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "isodoc/gem_tasks"
4
+
5
+ IsoDoc::GemTasks.install
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "metanorma/ogc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
+ "../../Gemfile", Pathname.new(__FILE__).realpath
12
+ )
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,146 @@
1
+ module Metanorma
2
+ class Requirements
3
+ class Default
4
+ def requirement_type_cleanup(reqt); end
5
+
6
+ def requirement_identifier_cleanup(reqt)
7
+ reqt.xpath("./identifier[link] | ./inherit[link]").each do |i|
8
+ i.children = i.at("./link/@target").text
9
+ end
10
+ end
11
+
12
+ def requirement_inherit_cleanup(reqt)
13
+ ins = requirement_inherit_insert(reqt)
14
+ reqt.xpath("./*//inherit").each { |i| ins.previous = i }
15
+ end
16
+
17
+ def requirement_inherit_insert(reqt)
18
+ ins = reqt.at("./classification") || reqt.at(
19
+ "./description | ./measurementtarget | ./specification | "\
20
+ "./verification | ./import | ./description | ./component | "\
21
+ "./requirement | ./recommendation | ./permission",
22
+ ) and return ins
23
+ requirement_inherit_insert1(reqt)
24
+ end
25
+
26
+ def requirement_inherit_insert1(reqt)
27
+ if t = reqt.at("./title")
28
+ t.next = " "
29
+ t.next
30
+ else
31
+ if reqt.children.empty? then reqt.add_child(" ")
32
+ else reqt.children.first.previous = " "
33
+ end
34
+ reqt.children.first
35
+ end
36
+ end
37
+
38
+ def requirement_descriptions_cleanup(reqt)
39
+ reqt.xpath(".//p[not(./*)][normalize-space(.)='']").each(&:remove)
40
+ reqt.children.each do |e|
41
+ requirement_description_wrap(reqt, e)
42
+ end
43
+ requirement_description_cleanup1(reqt)
44
+ end
45
+
46
+ REQS = %w(recommendation requirement permission).freeze
47
+
48
+ def requirement_description_wrap(reqt, text)
49
+ return if (text.element? && (reqt_subpart?(text.name) ||
50
+ REQS.include?(text.name))) ||
51
+ (text.text.strip.empty? && !text.at(".//xref | .//eref | .//link"))
52
+
53
+ t = Nokogiri::XML::Element.new("description", reqt.document)
54
+ text.before(t)
55
+ t.children = text.remove
56
+ end
57
+
58
+ def requirement_description_cleanup1(reqt)
59
+ while d = reqt.at("./description[following-sibling::*[1]"\
60
+ "[self::description]]")
61
+ n = d.next.remove
62
+ d << n.children
63
+ end
64
+ reqt.xpath("./description[normalize-space(.)='']").each do |r|
65
+ r.replace("\n")
66
+ end
67
+ end
68
+
69
+ def requirement_metadata_cleanup(reqt)
70
+ dl = reqt.at("./dl[@metadata = 'true']")&.remove or return
71
+ requirement_metadata1(reqt, dl, reqt.at("./title"))
72
+ end
73
+
74
+ def requirement_metadata1_attrs
75
+ %w(obligation model type)
76
+ end
77
+
78
+ def requirement_metadata1_tags
79
+ %w(identifier subject inherit)
80
+ end
81
+
82
+ def requirement_metadata_component_tags
83
+ []
84
+ end
85
+
86
+ def dl_to_attrs(elem, dlist, name)
87
+ Metanorma::Utils::dl_to_attrs(elem, dlist, name)
88
+ end
89
+
90
+ def dl_to_elems(ins, elem, dlist, name)
91
+ Metanorma::Utils::dl_to_elems(ins, elem, dlist, name)
92
+ end
93
+
94
+ def requirement_metadata1(reqt, dlist, ins)
95
+ ins = requirement_metadata1_set_insert(reqt, ins)
96
+ requirement_metadata1_attrs.each do |a|
97
+ dl_to_attrs(reqt, dlist, a)
98
+ end
99
+ requirement_metadata1_tags.each do |a|
100
+ ins = dl_to_elems(ins, reqt, dlist, a)
101
+ end
102
+ ins = reqt_dl_to_classif(ins, reqt, dlist)
103
+ reqt_dl_to_classif1(ins, reqt, dlist)
104
+ end
105
+
106
+ def requirement_metadata1_set_insert(reqt, ins)
107
+ return ins if ins
108
+
109
+ reqt.children.first.previous = " "
110
+ reqt.children.first
111
+ end
112
+
113
+ def reqt_dl_to_classif(ins, reqt, dlist)
114
+ if a = reqt.at("./classification[last()]") then ins = a end
115
+ dlist.xpath("./dt[text()='classification']").each do |e|
116
+ val = e.at("./following::dd/p") || e.at("./following::dd")
117
+ req_classif_parse(val.children.to_xml).each do |r|
118
+ ins.next = "<classification><tag>#{r[0]}</tag>"\
119
+ "<value>#{r[1]}</value></classification>"
120
+ ins = ins.next
121
+ end
122
+ end
123
+ ins
124
+ end
125
+
126
+ def reqt_dl_to_classif1(ins, reqt, dlist)
127
+ if a = reqt.at("./classification[last()]") then ins = a end
128
+ dlist.xpath("./dt").each do |e|
129
+ next if (requirement_metadata1_attrs + requirement_metadata1_tags +
130
+ requirement_metadata_component_tags + %w(classification))
131
+ .include?(e.text)
132
+
133
+ ins = reqt_dl_to_classif2(e, ins)
134
+ end
135
+ ins
136
+ end
137
+
138
+ def reqt_dl_to_classif2(term, ins)
139
+ val = term.at("./following::dd/p") || e.at("./following::dd")
140
+ ins.next = "<classification><tag>#{term.text}</tag>"\
141
+ "<value>#{val.children.to_xml}</value></classification>"
142
+ ins.next
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,99 @@
1
+ require "htmlentities"
2
+ require_relative "cleanup"
3
+ require_relative "utils"
4
+ require_relative "isodoc"
5
+ require_relative "xrefs"
6
+
7
+ module Metanorma
8
+ class Requirements
9
+ class Default
10
+ def initialize(options)
11
+ @c = HTMLEntities.new
12
+ @parent = options[:parent]
13
+ @i18n = @parent.i18n
14
+ @labels = @parent.labels
15
+ end
16
+
17
+ def reqt_subpart?(name)
18
+ %w[specification measurement-target verification import identifier title
19
+ description component subject inherit classification].include? name
20
+ end
21
+
22
+ def reqt_subpart_attrs(node, name, attrs)
23
+ klass = node.attr("class") || "component"
24
+ attr_code(attrs
25
+ .merge(exclude: node.option?("exclude"),
26
+ type: node.attr("type"),
27
+ class: name == "component" ? klass : nil))
28
+ end
29
+
30
+ def requirement_subpart(node, attrs)
31
+ name = node.role || node.attr("style")
32
+ noko do |xml|
33
+ xml.send name, **reqt_subpart_attrs(node, name, attrs) do |o|
34
+ o << node.content
35
+ end
36
+ end
37
+ end
38
+
39
+ def req_classif_parse(classif)
40
+ ret = []
41
+ @c.decode(classif).split(/;\s*/).each do |c|
42
+ c1 = c.split(/:\s*/)
43
+ next unless c1.size == 2
44
+
45
+ c1[1].split(/,\s*/).each { |v| ret << [c1[0], v] }
46
+ end
47
+ ret
48
+ end
49
+
50
+ def requirement_classification(classif, out)
51
+ req_classif_parse(classif).each do |r|
52
+ out.classification do |c|
53
+ c.tag { |t| t << r[0] }
54
+ c.value { |v| v << r[1] }
55
+ end
56
+ end
57
+ end
58
+
59
+ def reqt_attrs(node, attrs)
60
+ attr_code(attrs.merge(
61
+ id: Metanorma::Utils.anchor_or_uuid(node),
62
+ unnumbered: node.option?("unnumbered") ? "true" : nil,
63
+ number: node.attr("number"),
64
+ subsequence: node.attr("subsequence"),
65
+ obligation: node.attr("obligation"),
66
+ filename: node.attr("filename"),
67
+ type: node.attr("type"),
68
+ ))
69
+ end
70
+
71
+ def requirement_elems(node, out)
72
+ node.title and out.title { |t| t << node.title }
73
+ a = node.attr("identifier") and out.identifier do |l|
74
+ l << out.text(a)
75
+ end
76
+ a = node.attr("subject") and csv_split(a)&.each do |subj|
77
+ out.subject { |s| s << out.text(subj) }
78
+ end
79
+ a = @c.decode(node.attr("inherit")) and
80
+ csv_split(a)&.each do |i|
81
+ out.inherit do |inh|
82
+ inh << @c.encode(i, :hexadecimal)
83
+ end
84
+ end
85
+ classif = node.attr("classification") and
86
+ requirement_classification(classif, out)
87
+ end
88
+
89
+ def requirement(node, obligation, attrs)
90
+ noko do |xml|
91
+ xml.send obligation, **reqt_attrs(node, attrs) do |ex|
92
+ requirement_elems(node, ex)
93
+ wrap_in_para(node, ex)
94
+ end
95
+ end.join("\n")
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,106 @@
1
+ module Metanorma
2
+ class Requirements
3
+ class Default
4
+ def l10n(text)
5
+ @i18n.l10n(text)
6
+ end
7
+
8
+ def recommendation_label(elem, type, xrefs)
9
+ number = xrefs.anchor(elem["id"], :label, false)
10
+ (number.nil? ? type : "#{type} #{number}")
11
+ end
12
+
13
+ def reqt_metadata_node?(node)
14
+ %w(identifier title subject classification tag value
15
+ inherit name).include? node.name
16
+ end
17
+
18
+ def requirement_render1(node)
19
+ out = recommendation_base(node, node.name)
20
+ ins = recommendation_header(node, out)
21
+ ins = recommendation_attributes(node, ins)
22
+ node.elements.reject do |n|
23
+ reqt_metadata_node?(n)
24
+ end.each { |n| ins = requirement_component_parse(n, ins) }
25
+ out
26
+ end
27
+
28
+ def recommendation_base(node, klass)
29
+ out = node.document.create_element(klass)
30
+ node.attributes.each do |k, v|
31
+ out[k] = v
32
+ end
33
+ out
34
+ end
35
+
36
+ def recommendation_labels(node)
37
+ [node.at(ns("./identifier")), node.at(ns("./title")),
38
+ node.at(ns("./name"))]
39
+ .map do |n|
40
+ n&.children&.to_xml
41
+ end
42
+ end
43
+
44
+ def recommendation_header(node, out)
45
+ label, title, name = recommendation_labels(node)
46
+ ret = name ? [name + l10n(":")] : []
47
+ if label || title
48
+ ret += ["<br/>", label]
49
+ ret << l10n(". ") if label && title
50
+ ret << title
51
+ end
52
+ out << "<name>#{ret.compact.join}</name>"
53
+ out
54
+ end
55
+
56
+ def recommendation_attributes1(node, out)
57
+ oblig = node["obligation"] and
58
+ out << l10n("#{@labels['obligation']}: #{oblig}")
59
+ node.xpath(ns("./subject")).each do |subj|
60
+ out << l10n("#{@labels['subject']}: #{subj.text}")
61
+ end
62
+ node.xpath(ns("./inherit")).each do |i|
63
+ out << recommendation_attr_parse(i, @labels["inherits"])
64
+ end
65
+ node.xpath(ns("./classification")).each do |c|
66
+ out << recommendation_attr_keyvalue(c, "tag", "value")
67
+ end
68
+ out
69
+ end
70
+
71
+ def recommendation_attr_parse(node, label)
72
+ "#{label}: #{node.children.to_xml}"
73
+ end
74
+
75
+ def recommendation_attr_keyvalue(node, key, value)
76
+ tag = node.at(ns("./#{key}")) or return nil
77
+ value = node.at(ns("./#{value}")) or return nil
78
+ "#{tag.text.capitalize}: #{value.children.to_xml}"
79
+ end
80
+
81
+ def recommendation_attributes(node, out)
82
+ ret = recommendation_attributes1(node, [])
83
+ .map { |a| "<em>#{a}</em>" }
84
+ ret.empty? or
85
+ out << "<p>#{ret.join("<br/>\n")}</p>"
86
+ out
87
+ end
88
+
89
+ def reqt_component_type(node)
90
+ klass = node.name
91
+ klass == "component" and klass = node["class"]
92
+ "requirement-#{klass}"
93
+ end
94
+
95
+ def requirement_component_parse(node, out)
96
+ return out if node["exclude"] == "true"
97
+
98
+ ret = node.dup
99
+ ret["type"] = reqt_component_type(node)
100
+ ret.name = "div"
101
+ out << ret
102
+ out
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,27 @@
1
+ require "metanorma-utils"
2
+
3
+ module Metanorma
4
+ class Requirements
5
+ class Default
6
+ def noko(&block)
7
+ Metanorma::Utils.noko(&block)
8
+ end
9
+
10
+ def attr_code(attributes)
11
+ Metanorma::Utils.attr_code(attributes)
12
+ end
13
+
14
+ def csv_split(text, delim = ";")
15
+ Metanorma::Utils.csv_split(text, delim)
16
+ end
17
+
18
+ def wrap_in_para(node, out)
19
+ Metanorma::Utils.wrap_in_para(node, out)
20
+ end
21
+
22
+ def ns(xpath)
23
+ Metanorma::Utils.ns(xpath)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ module Metanorma
2
+ class Requirements
3
+ class Default
4
+ def permission_parts(_block, _block_id, _label, _klass)
5
+ []
6
+ end
7
+
8
+ def req_class_paths
9
+ [
10
+ { klass: "permission", label: "permission",
11
+ xpath: "permission" },
12
+ { klass: "requirement", label: "requirement",
13
+ xpath: "requirement" },
14
+ { klass: "recommendation", label: "recommendation",
15
+ xpath: "recommendation" },
16
+ ]
17
+ end
18
+
19
+ def req_nested_class_paths
20
+ [
21
+ { klass: "permission", label: "permission",
22
+ xpath: "permission" },
23
+ { klass: "requirement", label: "requirement",
24
+ xpath: "requirement" },
25
+ { klass: "recommendation", label: "recommendation",
26
+ xpath: "recommendation" },
27
+ ]
28
+ end
29
+
30
+ def postprocess_anchor_struct(_block, anchor)
31
+ anchor
32
+ end
33
+ end
34
+ end
35
+ end