isodoc-i18n 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +10 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +11 -0
- data/LICENSE +25 -0
- data/README.adoc +10 -0
- data/Rakefile +6 -0
- data/bin/rspec +17 -0
- data/isodoc-i18n.gemspec +39 -0
- data/lib/isodoc/i18n.rb +135 -0
- data/lib/isodoc/version.rb +5 -0
- data/lib/isodoc-i18n.rb +5 -0
- data/lib/isodoc-yaml/i18n-en.yaml +4 -0
- data/spec/assets/new.yaml +7 -0
- data/spec/isodoc/base_spec.rb +86 -0
- data/spec/spec_helper.rb +36 -0
- metadata +228 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0cb9429df0523ad853ce2c16221b6ca2da9df7f12be71ec1d9d31dfe8a4507c7
|
4
|
+
data.tar.gz: 0a454f447146ec95be0a421d3b38844d3c502aabf998cef8dfa9158e731e65de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98607331dc8eea71395667abccf85d4e97ce7c91223ccc1e4b7bb860f596de4262cd642fa94d68693a9e77c61d045c402e6919e71b23a4571e519bc0e6fdcc92
|
7
|
+
data.tar.gz: e69e12e61a39badb700850998267e473b5acbe51cf3f11de332ed6a08cc6e50b73de8c6811bcb998999b6b07739b78c390368cdeacd5ad4b6dcf97b55787d5f2
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,10 @@
|
|
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
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ronald.tse@ribose.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
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
|
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,10 @@
|
|
1
|
+
= isodoc-i18n
|
2
|
+
|
3
|
+
image:https://img.shields.io/gem/v/isodoc-i18n.svg["Gem Version", link="https://rubygems.org/gems/isodoc-i18n"]
|
4
|
+
image:https://github.com/metanorma/isodoc-i18n/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/isodoc-i18n/actions?query=workflow%3Arake"]
|
5
|
+
image:https://codeclimate.com/github/metanorma/isodoc-i18n/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/isodoc-i18n"]
|
6
|
+
image:https://img.shields.io/github/issues-pr-raw/metanorma/isodoc-i18n.svg["Pull Requests", link="https://github.com/metanorma/isodoc-i18n/pulls"]
|
7
|
+
image:https://img.shields.io/github/commits-since/metanorma/isodoc-i18n/latest.svg["Commits since latest",link="https://github.com/metanorma/isodoc-i18n/releases"]
|
8
|
+
|
9
|
+
|
10
|
+
Internationalisation for Metanorma rendering
|
data/Rakefile
ADDED
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/isodoc-i18n.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "isodoc/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "isodoc-i18n"
|
7
|
+
spec.version = IsoDoc::I18n::VERSION
|
8
|
+
spec.authors = ["Ribose Inc."]
|
9
|
+
spec.email = ["open.source@ribose.com"]
|
10
|
+
|
11
|
+
spec.summary = "isodoc-i18n "
|
12
|
+
spec.description = <<~DESCRIPTION
|
13
|
+
Internationalisation for Metanorma rendering
|
14
|
+
DESCRIPTION
|
15
|
+
|
16
|
+
spec.homepage = "https://github.com/metanorma/isodoc-i18n"
|
17
|
+
spec.license = "BSD-2-Clause"
|
18
|
+
|
19
|
+
spec.bindir = "bin"
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.files = `git ls-files`.split("\n")
|
22
|
+
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
23
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
24
|
+
|
25
|
+
spec.add_dependency "htmlentities", "~> 4.3.4"
|
26
|
+
spec.add_dependency "metanorma-utils", "~> 1.2.8"
|
27
|
+
|
28
|
+
spec.add_development_dependency "debug"
|
29
|
+
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
30
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
31
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
34
|
+
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
35
|
+
spec.add_development_dependency "simplecov", "~> 0.15"
|
36
|
+
spec.add_development_dependency "timecop", "~> 0.9"
|
37
|
+
spec.add_development_dependency "webmock"
|
38
|
+
#spec.metadata["rubygems_mfa_required"] = "true"
|
39
|
+
end
|
data/lib/isodoc/i18n.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "htmlentities"
|
3
|
+
require "metanorma-utils"
|
4
|
+
|
5
|
+
module IsoDoc
|
6
|
+
class I18n
|
7
|
+
def load_yaml(lang, script, i18nyaml = nil)
|
8
|
+
ret = load_yaml1(lang, script)
|
9
|
+
return normalise_hash(ret.merge(YAML.load_file(i18nyaml))) if i18nyaml
|
10
|
+
|
11
|
+
normalise_hash(ret)
|
12
|
+
end
|
13
|
+
|
14
|
+
def normalise_hash(ret)
|
15
|
+
case ret
|
16
|
+
when Hash
|
17
|
+
ret.each do |k, v|
|
18
|
+
ret[k] = normalise_hash(v)
|
19
|
+
end
|
20
|
+
ret
|
21
|
+
when Array then ret.map { |n| normalise_hash(n) }
|
22
|
+
when String then cleanup_entities(ret.unicode_normalize(:nfc))
|
23
|
+
else ret
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_yaml1(lang, script)
|
28
|
+
case lang
|
29
|
+
when "zh"
|
30
|
+
if script == "Hans" then load_yaml2("zh-Hans")
|
31
|
+
else load_yaml2("en")
|
32
|
+
end
|
33
|
+
else
|
34
|
+
load_yaml2(lang)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# locally defined in calling class
|
39
|
+
def load_yaml2(lang)
|
40
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
41
|
+
"../isodoc-yaml/i18n-#{lang}.yaml"))
|
42
|
+
rescue StandardError
|
43
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
44
|
+
"../isodoc-yaml/i18n-en.yaml"))
|
45
|
+
end
|
46
|
+
|
47
|
+
def get
|
48
|
+
@labels
|
49
|
+
end
|
50
|
+
|
51
|
+
def set(key, val)
|
52
|
+
@labels[key] = val
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(lang, script, i18nyaml = nil)
|
56
|
+
@lang = lang
|
57
|
+
@script = script
|
58
|
+
y = load_yaml(lang, script, i18nyaml)
|
59
|
+
@labels = y
|
60
|
+
@labels["language"] = @lang
|
61
|
+
@labels["script"] = @script
|
62
|
+
@labels.each do |k, _v|
|
63
|
+
self.class.send(:define_method, k.downcase) { get[k] }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.l10n(text, lang = @lang, script = @script)
|
68
|
+
l10n(text, lang, script)
|
69
|
+
end
|
70
|
+
|
71
|
+
# TODO: move to localization file
|
72
|
+
# function localising spaces and punctuation.
|
73
|
+
# Not clear if period needs to be localised for zh
|
74
|
+
def l10n(text, lang = @lang, script = @script)
|
75
|
+
if lang == "zh" && script == "Hans" then l10n_zh(text)
|
76
|
+
else bidiwrap(text, lang, script)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def bidiwrap(text, lang, script)
|
81
|
+
my_script, my_rtl, outer_rtl = bidiwrap_vars(lang, script)
|
82
|
+
if my_rtl && !outer_rtl
|
83
|
+
mark = %w(Arab Aran).include?(my_script) ? "؜" : "‏"
|
84
|
+
"#{mark}#{text}#{mark}"
|
85
|
+
elsif !my_rtl && outer_rtl then "‎#{text}‎"
|
86
|
+
else text
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def bidiwrap_vars(lang, script)
|
91
|
+
my_script = script || Metanorma::Utils.default_script(lang)
|
92
|
+
[my_script,
|
93
|
+
Metanorma::Utils.rtl_script?(my_script),
|
94
|
+
Metanorma::Utils.rtl_script?(@script || Metanorma::Utils
|
95
|
+
.default_script(@lang))]
|
96
|
+
end
|
97
|
+
|
98
|
+
def l10n_zh(text)
|
99
|
+
xml = Nokogiri::HTML::DocumentFragment.parse(text)
|
100
|
+
xml.traverse do |n|
|
101
|
+
next unless n.text?
|
102
|
+
|
103
|
+
n.replace(cleanup_entities(n.text.gsub(/ /, "").gsub(/:/, ":")
|
104
|
+
.gsub(/,/, "、").gsub(/\(/, "(").gsub(/\)/, ")")
|
105
|
+
.gsub(/\[/, "【").gsub(/\]/, "】"), is_xml: false))
|
106
|
+
end
|
107
|
+
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
|
108
|
+
end
|
109
|
+
|
110
|
+
def boolean_conj(list, conn)
|
111
|
+
case list.size
|
112
|
+
when 0 then ""
|
113
|
+
when 1 then list.first
|
114
|
+
when 2 then @labels["binary_#{conn}"].sub(/%1/, list[0])
|
115
|
+
.sub(/%2/, list[1])
|
116
|
+
else
|
117
|
+
@labels["multiple_#{conn}"]
|
118
|
+
.sub(/%1/, l10n(list[0..-2].join(", "), @lang, @script))
|
119
|
+
.sub(/%2/, list[-1])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def cleanup_entities(text, is_xml: true)
|
124
|
+
c = HTMLEntities.new
|
125
|
+
if is_xml
|
126
|
+
text.split(/([<>])/).each_slice(4).map do |a|
|
127
|
+
a[0] = c.encode(c.decode(a[0]), :hexadecimal)
|
128
|
+
a
|
129
|
+
end.join
|
130
|
+
else
|
131
|
+
c.encode(c.decode(text), :hexadecimal)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/lib/isodoc-i18n.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe IsoDoc::I18n do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(IsoDoc::I18n::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "loads language files" do
|
9
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
10
|
+
expect(c.text).to eq "text"
|
11
|
+
expect(c.at).to eq "at"
|
12
|
+
expect(c.language).to eq "en"
|
13
|
+
expect(c.script).to eq "Latn"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "manipulates i18n class" do
|
17
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
18
|
+
expect(c.get["text"]).to eq "text"
|
19
|
+
expect(c.get["fred"]).to be_nil
|
20
|
+
c.set("fred", "frederic")
|
21
|
+
expect(c.get["fred"]).to eq "frederic"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "loads default for missing language files" do
|
25
|
+
c = IsoDoc::I18n.new("tlh", "Klin")
|
26
|
+
expect(c.text).to eq "text"
|
27
|
+
expect(c.at).to eq "at"
|
28
|
+
expect(c.language).to eq "tlh"
|
29
|
+
expect(c.script).to eq "Klin"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "loads language file overrides" do
|
33
|
+
c = IsoDoc::I18n.new("en", "Latn", "spec/assets/new.yaml")
|
34
|
+
expect(c.text).to eq "text2"
|
35
|
+
expect(c.at).to eq "at"
|
36
|
+
expect(c.hash.to_s).to be_equivalent_to '{"key1"=>"val1", "key2"=>"val2"}'
|
37
|
+
expect(c.arr.to_s).to eq '["arr1", "arr2"]'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does English localisation" do
|
41
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
42
|
+
expect(c.l10n("Code (hello, world.)"))
|
43
|
+
.to be_equivalent_to "Code (hello, world.)"
|
44
|
+
expect(c.l10n("<a>Code (he<b>l</b>lo, world.)</a>"))
|
45
|
+
.to be_equivalent_to "<a>Code (he<b>l</b>lo, world.)</a>"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does Chinese localisation" do
|
49
|
+
c = IsoDoc::I18n.new("zh", "Hans")
|
50
|
+
expect(c.l10n("Code (hello, world.)"))
|
51
|
+
.to be_equivalent_to "Code(hello、world.)"
|
52
|
+
expect(c.l10n("<a>Code (he<b>l</b>lo, world.)</a>"))
|
53
|
+
.to be_equivalent_to "<a>Code(hello、world.)</a>"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does Hebrew RTL localisation" do
|
57
|
+
c = IsoDoc::I18n.new("en", "Hebr")
|
58
|
+
expect(c.l10n("Code (hello, world.)"))
|
59
|
+
.to be_equivalent_to "Code (hello, world.)"
|
60
|
+
expect(c.l10n("Code (hello, world.)", "en", "Latn"))
|
61
|
+
.to be_equivalent_to "‎Code (hello, world.)‎"
|
62
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
63
|
+
expect(c.l10n("Code (hello, world.)", "en", "Hebr"))
|
64
|
+
.to be_equivalent_to "‏Code (hello, world.)‏"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "does Arabic RTL localisation" do
|
68
|
+
c = IsoDoc::I18n.new("en", "Arab")
|
69
|
+
expect(c.l10n("Code (hello, world.)"))
|
70
|
+
.to be_equivalent_to "Code (hello, world.)"
|
71
|
+
expect(c.l10n("Code (hello, world.)", "en", "Latn"))
|
72
|
+
.to be_equivalent_to "‎Code (hello, world.)‎"
|
73
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
74
|
+
expect(c.l10n("Code (hello, world.)", "en", "Arab"))
|
75
|
+
.to be_equivalent_to "؜Code (hello, world.)؜"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "does boolean conjunctions" do
|
79
|
+
c = IsoDoc::I18n.new("en", "Latn")
|
80
|
+
expect(c.boolean_conj([], "and")).to eq ""
|
81
|
+
expect(c.boolean_conj(%w(a), "and")).to eq "a"
|
82
|
+
expect(c.boolean_conj(%w(a b), "and")).to eq "a and b"
|
83
|
+
expect(c.boolean_conj(%w(a b c), "and")).to eq "a, b, and c"
|
84
|
+
expect(c.boolean_conj(%w(a b c d), "and")).to eq "a, b, c, and d"
|
85
|
+
end
|
86
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter "/spec/"
|
4
|
+
end
|
5
|
+
|
6
|
+
require "bundler/setup"
|
7
|
+
require "isodoc-i18n"
|
8
|
+
require "rspec/matchers"
|
9
|
+
require "equivalent-xml"
|
10
|
+
require "rexml/document"
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
# Enable flags like --only-failures and --next-failure
|
14
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
15
|
+
|
16
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
17
|
+
config.disable_monkey_patching!
|
18
|
+
|
19
|
+
config.expect_with :rspec do |c|
|
20
|
+
c.syntax = :expect
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def xmlpp(xml)
|
25
|
+
s = ""
|
26
|
+
f = REXML::Formatters::Pretty.new(2)
|
27
|
+
f.compact = true
|
28
|
+
f.write(REXML::Document.new(xml), s)
|
29
|
+
s
|
30
|
+
end
|
31
|
+
|
32
|
+
def metadata(hash)
|
33
|
+
Hash[hash.sort].delete_if do |_k, v|
|
34
|
+
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isodoc-i18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: htmlentities
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.3.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.3.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: metanorma-utils
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.8
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.8
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: equivalent-xml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.14'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.14'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '13.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '13.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.6'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.6'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.5.2
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.5.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.15'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.15'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: timecop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.9'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.9'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: 'Internationalisation for Metanorma rendering
|
182
|
+
|
183
|
+
'
|
184
|
+
email:
|
185
|
+
- open.source@ribose.com
|
186
|
+
executables: []
|
187
|
+
extensions: []
|
188
|
+
extra_rdoc_files: []
|
189
|
+
files:
|
190
|
+
- ".rubocop.yml"
|
191
|
+
- CODE_OF_CONDUCT.md
|
192
|
+
- Gemfile
|
193
|
+
- LICENSE
|
194
|
+
- README.adoc
|
195
|
+
- Rakefile
|
196
|
+
- bin/rspec
|
197
|
+
- isodoc-i18n.gemspec
|
198
|
+
- lib/isodoc-i18n.rb
|
199
|
+
- lib/isodoc-yaml/i18n-en.yaml
|
200
|
+
- lib/isodoc/i18n.rb
|
201
|
+
- lib/isodoc/version.rb
|
202
|
+
- spec/assets/new.yaml
|
203
|
+
- spec/isodoc/base_spec.rb
|
204
|
+
- spec/spec_helper.rb
|
205
|
+
homepage: https://github.com/metanorma/isodoc-i18n
|
206
|
+
licenses:
|
207
|
+
- BSD-2-Clause
|
208
|
+
metadata: {}
|
209
|
+
post_install_message:
|
210
|
+
rdoc_options: []
|
211
|
+
require_paths:
|
212
|
+
- lib
|
213
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: 2.5.0
|
218
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
requirements: []
|
224
|
+
rubygems_version: 3.3.9
|
225
|
+
signing_key:
|
226
|
+
specification_version: 4
|
227
|
+
summary: isodoc-i18n
|
228
|
+
test_files: []
|