isodoc-i18n 1.1.3 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 573397fe43411b36723793fd50893ce1fd5eda84ca84f8e00ba608f6e50f3cd5
4
- data.tar.gz: 3117720a218de8fe171ee8c4d3237c97408a87beac521d4bb13d0d1021d329a9
3
+ metadata.gz: cf80de5e127891bdd42fef149b032db2649100b48e3903255b8045021d11f8d7
4
+ data.tar.gz: cbb3b8f8791089bd9ec2e161a0d268ae02b3768338963181f452812110aa32bf
5
5
  SHA512:
6
- metadata.gz: 865a347ccd8f837f4a88f950179d375a79db880ca61de6880d545163ad5e8ca19488410f7dc0a03cf8205a3d948256b58dae49909a442427ffb409635ed7d9c5
7
- data.tar.gz: a0a3ba98de7b47388e81f9bbdc8dac86e95f9c91aaca0290b1952d9bf7b9f98d23b5725bc70c75f8018c65d61bbaaa629fe65ee2edb868f6cb1dab1223afa8a3
6
+ metadata.gz: b6f9db2ae6a42c46dc8b8b6722daaf90b0bcfddd67d3eb244186c9d4e561d76019c837609cce2dcad35d7bf039393c8aaffeeb46e4249688a1c6b1330da2aee1
7
+ data.tar.gz: b79476f0ca524c142d0135de71206b6a137055286f214a94bbfc0d125d12a8d18a7357cb2162b6e75e3a8308c6b9d85005bd88bcdffc545c8764c22c55911e22
data/isodoc-i18n.gemspec CHANGED
@@ -1,6 +1,4 @@
1
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "isodoc/version"
1
+ require_relative "lib/isodoc/i18n/version"
4
2
 
5
3
  Gem::Specification.new do |spec|
6
4
  spec.name = "isodoc-i18n"
@@ -18,9 +16,11 @@ Gem::Specification.new do |spec|
18
16
 
19
17
  spec.bindir = "bin"
20
18
  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")
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features|bin|.github)/}) \
21
+ || f.match(%r{Rakefile|bin/rspec})
22
+ end
23
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
24
24
 
25
25
  spec.add_dependency "htmlentities", "~> 4.3.4"
26
26
  spec.add_dependency "metanorma-utils", "~> 1.4.0"
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "simplecov", "~> 0.15"
37
37
  spec.add_development_dependency "timecop", "~> 0.9"
38
38
  spec.add_development_dependency "webmock"
39
- #spec.metadata["rubygems_mfa_required"] = "true"
39
+ # spec.metadata["rubygems_mfa_required"] = "true"
40
40
  end
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.1.3".freeze
3
+ VERSION = "1.1.6".freeze
4
4
  end
5
5
  end
data/lib/isodoc/i18n.rb CHANGED
@@ -2,6 +2,7 @@ require "yaml"
2
2
  require "htmlentities"
3
3
  require "metanorma-utils"
4
4
  require "twitter_cldr"
5
+ require_relative "i18n/version"
5
6
 
6
7
  module IsoDoc
7
8
  class I18n
@@ -77,7 +78,7 @@ module IsoDoc
77
78
  # function localising spaces and punctuation.
78
79
  # Not clear if period needs to be localised for zh
79
80
  def l10n(text, lang = @lang, script = @script, locale = @locale)
80
- lang == "zh" && script == "Hans" and text = l10n_zh(text)
81
+ lang == "zh" and text = l10n_zh(text, script)
81
82
  lang == "fr" && text = l10n_fr(text, locale || "FR")
82
83
  bidiwrap(text, lang, script)
83
84
  end
@@ -100,12 +101,12 @@ module IsoDoc
100
101
  .default_script(@lang))]
101
102
  end
102
103
 
103
- def l10n_zh(text)
104
+ def l10n_zh(text, script = "Hans")
104
105
  xml = Nokogiri::XML::DocumentFragment.parse(text)
105
106
  xml.traverse do |n|
106
107
  next unless n.text?
107
108
 
108
- n.replace(cleanup_entities(l10_zh1(n.text), is_xml: false))
109
+ n.replace(l10_zh1(cleanup_entities(n.text, is_xml: false), script))
109
110
  end
110
111
  xml.to_xml(encoding: "UTF-8").gsub(/<b>/, "").gsub("</b>", "")
111
112
  .gsub(/<\?[^>]+>/, "")
@@ -116,7 +117,7 @@ module IsoDoc
116
117
  xml.traverse do |n|
117
118
  next unless n.text?
118
119
 
119
- n.replace(cleanup_entities(l10n_fr1(n.text, locale), is_xml: false))
120
+ n.replace(l10n_fr1(cleanup_entities(n.text, is_xml: false), locale))
120
121
  end
121
122
  xml.to_xml(encoding: "UTF-8")
122
123
  end
@@ -125,17 +126,16 @@ module IsoDoc
125
126
  "\\p{In Halfwidth And Fullwidth Forms}".freeze
126
127
 
127
128
  # note: we can't differentiate comma from enumeration comma 、
128
- def l10_zh1(text)
129
+ def l10_zh1(text, _script)
129
130
  l10n_zh_remove_space(l10n_zh_punct(text))
130
131
  end
131
132
 
132
133
  def l10n_zh_punct(text)
133
- ["::", ",,", ".。", "))", "]", "::", ";;", "??", "!!"].each do |m|
134
- text = text.gsub(/(?<=#{ZH_CHAR})#{Regexp.quote m[0]}/, m[1])
135
- text = text.gsub(/^#{Regexp.quote m[0]}/, m[1])
134
+ ["::", ",,", "..", "))", "]", "::", ";;", "??", "!!", "–~"].each do |m|
135
+ text = text.gsub(/#{Regexp.quote m[0]}/, m[1])
136
136
  end
137
- ["((", "["].each do |m|
138
- text = text.gsub(/#{Regexp.quote m[0]}(?=#{ZH_CHAR})/, m[1])
137
+ ["((", "["].each do |m|
138
+ text = text.gsub(/#{Regexp.quote m[0]}/, m[1])
139
139
  end
140
140
  text
141
141
  end
@@ -166,11 +166,16 @@ module IsoDoc
166
166
  .sub(/%2/, list[1])
167
167
  else
168
168
  @labels["multiple_#{conn}"]
169
- .sub(/%1/, l10n(list[0..-2].join(", "), @lang, @script))
169
+ .sub(/%1/, l10n(list[0..-2].join(enum_comma), @lang, @script))
170
170
  .sub(/%2/, list[-1])
171
171
  end
172
172
  end
173
173
 
174
+ def enum_comma
175
+ %w(Hans Hant).include?(@script) and return "、"
176
+ ", "
177
+ end
178
+
174
179
  def cleanup_entities(text, is_xml: true)
175
180
  c = HTMLEntities.new
176
181
  if is_xml
@@ -185,12 +190,13 @@ module IsoDoc
185
190
 
186
191
  # ord class is either SpelloutRules or OrdinalRules
187
192
  def inflect_ordinal(num, term, ord_class)
188
- if @labels["ordinal_keys"].nil? || @labels["ordinal_keys"].empty?
189
- tw_cldr_localize(num).to_rbnf_s(ord_class, @labels[ord_class])
190
- else
191
- tw_cldr_localize(num)
192
- .to_rbnf_s(ord_class, @labels[ord_class][ordinal_key(term)])
193
- end
193
+ lbl = if @labels["ordinal_keys"].nil? || @labels["ordinal_keys"].empty?
194
+ @labels[ord_class]
195
+ else @labels[ord_class][ordinal_key(term)]
196
+ end
197
+ tw_cldr_localize(num).to_rbnf_s(ord_class, lbl)
198
+ rescue StandardError
199
+ num.localize(@lang.to_sym).to_rbnf_s(ord_class, lbl)
194
200
  end
195
201
 
196
202
  def tw_cldr_localize(num)
data/lib/isodoc-i18n.rb CHANGED
@@ -1,5 +1 @@
1
- require_relative "isodoc/version"
2
1
  require_relative "isodoc/i18n"
3
-
4
- module IsoDoc
5
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-13 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -201,26 +201,17 @@ executables: []
201
201
  extensions: []
202
202
  extra_rdoc_files: []
203
203
  files:
204
- - ".github/workflows/rake.yml"
205
- - ".github/workflows/release.yml"
206
204
  - ".hound.yml"
207
205
  - ".rubocop.yml"
208
206
  - CODE_OF_CONDUCT.md
209
207
  - Gemfile
210
208
  - LICENSE
211
209
  - README.adoc
212
- - Rakefile
213
- - bin/rspec
214
210
  - isodoc-i18n.gemspec
215
211
  - lib/isodoc-i18n.rb
216
212
  - lib/isodoc-yaml/i18n-en.yaml
217
213
  - lib/isodoc/i18n.rb
218
- - lib/isodoc/version.rb
219
- - spec/assets/de.yaml
220
- - spec/assets/new.yaml
221
- - spec/assets/zh-Hans.yaml
222
- - spec/isodoc/base_spec.rb
223
- - spec/spec_helper.rb
214
+ - lib/isodoc/i18n/version.rb
224
215
  homepage: https://github.com/metanorma/isodoc-i18n
225
216
  licenses:
226
217
  - BSD-2-Clause
@@ -233,14 +224,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
224
  requirements:
234
225
  - - ">="
235
226
  - !ruby/object:Gem::Version
236
- version: 2.5.0
227
+ version: 2.7.0
237
228
  required_rubygems_version: !ruby/object:Gem::Requirement
238
229
  requirements:
239
230
  - - ">="
240
231
  - !ruby/object:Gem::Version
241
232
  version: '0'
242
233
  requirements: []
243
- rubygems_version: 3.1.6
234
+ rubygems_version: 3.3.26
244
235
  signing_key:
245
236
  specification_version: 4
246
237
  summary: isodoc-i18n
@@ -1,15 +0,0 @@
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/ci/.github/workflows/generic-rake.yml@main
14
- secrets:
15
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -1,24 +0,0 @@
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/ci/.github/workflows/rubygems-release.yml@main
19
- with:
20
- next_version: ${{ github.event.inputs.next_version }}
21
- secrets:
22
- rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
23
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
24
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/bin/rspec DELETED
@@ -1,17 +0,0 @@
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/spec/assets/de.yaml DELETED
@@ -1,12 +0,0 @@
1
- ordinal_keys: [gender,number]
2
- SpelloutRules:
3
- m.sg: spellout-ordinal-r
4
- f.sg: spellout-ordinal
5
- n.sg: spellout-ordinal-s
6
- m.pl: spellout-ordinal
7
- f.pl: spellout-ordinal
8
- n.pl: spellout-ordinal
9
- edition: Auflage
10
- inflection:
11
- Auflage:
12
- gender: f
data/spec/assets/new.yaml DELETED
@@ -1,53 +0,0 @@
1
- hash:
2
- key1: val1
3
- key2: val2
4
- arr:
5
- - arr1
6
- - arr2
7
- text: "&#x74;ext2"
8
- inflection:
9
- Fred:
10
- sg: Fred
11
- pl: Freds
12
- Man:
13
- dat: viri
14
- acc: virem
15
- Woman:
16
- sg:
17
- nom: mulier
18
- gen: mulieris
19
- pl:
20
- nom: mulieres
21
- gen: mulierum
22
- Good:
23
- sg:
24
- nom:
25
- masc: bonus
26
- fem: bona
27
- neut: bonum
28
- gen:
29
- masc: boni
30
- fem: bonae
31
- neut: boni
32
- pl:
33
- nom:
34
- masc: boni
35
- fem: bonae
36
- neut: bona
37
- gen:
38
- masc: bonorum
39
- fem: bonarum
40
- neut: bonorum
41
- Walk:
42
- act:
43
- ind:
44
- pres:
45
- sg:
46
- 1st: ambulo
47
- 2nd: ambulas
48
- subj:
49
- pres:
50
- pl:
51
- 1st: ambulemus
52
- 2nd: ambuletis
53
-
@@ -1,7 +0,0 @@
1
- ordinal_keys: []
2
- SpelloutRules: spellout-ordinal
3
- edition: Auflage
4
- inflection:
5
- Auflage:
6
- gender: f
7
-
@@ -1,158 +0,0 @@
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", i18nyaml: "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 "loads language hash overrides" do
41
- c = IsoDoc::I18n.new("en", "Latn",
42
- i18nhash: YAML.load_file("spec/assets/new.yaml"))
43
- expect(c.text).to eq "text2"
44
- expect(c.at).to eq "at"
45
- expect(c.hash.to_s).to be_equivalent_to '{"key1"=>"val1", "key2"=>"val2"}'
46
- expect(c.arr.to_s).to eq '["arr1", "arr2"]'
47
- end
48
-
49
- it "does English localisation" do
50
- c = IsoDoc::I18n.new("en", "Latn")
51
- expect(c.l10n("Code (hello, world.)"))
52
- .to be_equivalent_to "Code (hello, world.)"
53
- expect(c.l10n("<a>Code (he<b>l</b>lo, world.)</a>"))
54
- .to be_equivalent_to "<a>Code (he<b>l</b>lo, world.)</a>"
55
- end
56
-
57
- it "does Chinese localisation" do
58
- c = IsoDoc::I18n.new("zh", "Hans")
59
- expect(c.l10n("Code (hello, world.)"))
60
- .to be_equivalent_to "Code (hello, world.)"
61
- expect(c.l10n("计算机代码 (你好, 世界.)"))
62
- .to be_equivalent_to " 计算机代码(你好,世界。)"
63
- expect(c.l10n("<a>计算机代码</a> (<b>你好,</b> 世界.)"))
64
- .to be_equivalent_to "<a>计算机代码</a> (你好, 世界。)"
65
- end
66
-
67
- it "does Hebrew RTL localisation" do
68
- c = IsoDoc::I18n.new("en", "Hebr")
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 "&#x200e;Code (hello, world.)&#x200e;"
73
- c = IsoDoc::I18n.new("en", "Latn")
74
- expect(c.l10n("Code (hello, world.)", "en", "Hebr"))
75
- .to be_equivalent_to "&#x200f;Code (hello, world.)&#x200f;"
76
- end
77
-
78
- it "does Arabic RTL localisation" do
79
- c = IsoDoc::I18n.new("en", "Arab")
80
- expect(c.l10n("Code (hello, world.)"))
81
- .to be_equivalent_to "Code (hello, world.)"
82
- expect(c.l10n("Code (hello, world.)", "en", "Latn"))
83
- .to be_equivalent_to "&#x200e;Code (hello, world.)&#x200e;"
84
- c = IsoDoc::I18n.new("en", "Latn")
85
- expect(c.l10n("Code (hello, world.)", "en", "Arab"))
86
- .to be_equivalent_to "&#x61c;Code (hello, world.)&#x61c;"
87
- end
88
-
89
- it "does French localisation" do
90
- e = HTMLEntities.new
91
- c = IsoDoc::I18n.new("fr", "Latn")
92
- expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
93
- .to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; " \
94
- "and&#xa0;: code&#x202f;!"
95
- expect(e.encode(c.l10n("Code; &#xab;code&#xbb; and: code!"), :hexadecimal))
96
- .to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; " \
97
- "and&#xa0;: code&#x202f;!"
98
- c = IsoDoc::I18n.new("fr", "Latn", locale: "FR")
99
- expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
100
- .to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; " \
101
- "and&#xa0;: code&#x202f;!"
102
- c = IsoDoc::I18n.new("fr", "Latn", locale: "CH")
103
- expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
104
- .to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; " \
105
- "and&#x202f;: code&#x202f;!"
106
- expect(e.encode(c.l10n("http://xyz a;b"), :hexadecimal))
107
- .to be_equivalent_to "http://xyz a;b"
108
- end
109
-
110
- it "does boolean conjunctions" do
111
- c = IsoDoc::I18n.new("en", "Latn")
112
- expect(c.boolean_conj([], "and")).to eq ""
113
- expect(c.boolean_conj(%w(a), "and")).to eq "a"
114
- expect(c.boolean_conj(%w(a b), "and")).to eq "a and b"
115
- expect(c.boolean_conj(%w(a b c), "and")).to eq "a, b, and c"
116
- expect(c.boolean_conj(%w(a b c d), "and")).to eq "a, b, c, and d"
117
- end
118
-
119
- it "does German ordinals" do
120
- c = IsoDoc::I18n.new("de", "Latn", i18nyaml: "spec/assets/de.yaml")
121
- term = c.inflection[c.edition]
122
- expect(c.inflect_ordinal(5, term, "SpelloutRules"))
123
- .to eq "fünfte"
124
- end
125
-
126
- it "does Chinese ordinals" do
127
- c = IsoDoc::I18n.new("zh", "Hans", i18nyaml: "spec/assets/zh-Hans.yaml")
128
- term = c.inflection[c.edition]
129
- expect(c.inflect_ordinal(5, term, "SpelloutRules"))
130
- .to eq "第五"
131
- end
132
-
133
- it "does Klingon ordinals" do
134
- c = IsoDoc::I18n.new("tlh", "Hans", i18nyaml: "spec/assets/zh-Hans.yaml")
135
- term = c.inflection[c.edition]
136
- expect(c.inflect_ordinal(5, term, "SpelloutRules"))
137
- .to eq "fifth"
138
- end
139
-
140
- it "does inflections" do
141
- c = IsoDoc::I18n.new("en", "Latn", i18nyaml: "spec/assets/new.yaml")
142
- expect(c.inflect("John", number: "sg")).to eq "John"
143
- expect(c.inflect("Fred", number: "sg")).to eq "Fred"
144
- expect(c.inflect("Fred", number: "pl")).to eq "Freds"
145
- expect(c.inflect("Fred", number: "du")).to eq "Fred"
146
- expect(c.inflect("Fred", tense: "pres")).to eq "Fred"
147
- expect(c.inflect("Man", case: "dat")).to eq "viri"
148
- expect(c.inflect("Man", number: "sg", case: "dat")).to eq "viri"
149
- expect(c.inflect("Man", number: "pl", case: "acc")).to eq "virem"
150
- expect(c.inflect("Woman", number: "pl", case: "gen")).to eq "mulierum"
151
- expect(c.inflect("Good", number: "pl", case: "gen")).to eq "bonorum"
152
- expect(c.inflect("Good", number: "pl", case: "gen", gender: "fem"))
153
- .to eq "bonarum"
154
- expect(c.inflect("Walk", person: "2nd")).to eq "ambulas"
155
- expect(c.inflect("Walk", person: "2nd", number: "pl", mood: "subj"))
156
- .to eq "ambuletis"
157
- end
158
- end
data/spec/spec_helper.rb DELETED
@@ -1,36 +0,0 @@
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.sort.to_h.delete_if do |_k, v|
34
- v.nil? || (v.respond_to?(:empty?) && v.empty?)
35
- end
36
- end