iev 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +0 -4
- data/.github/workflows/release.yml +1 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +81 -0
- data/Gemfile +11 -3
- data/README.adoc +276 -21
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/exe/iev +7 -0
- data/iev.gemspec +15 -19
- data/lib/iev/cli/command.rb +38 -38
- data/lib/iev/cli/command_helper.rb +13 -11
- data/lib/iev/cli/ui.rb +5 -5
- data/lib/iev/cli.rb +5 -5
- data/lib/iev/converter/mathml_to_asciimath.rb +75 -77
- data/lib/iev/converter.rb +2 -2
- data/lib/iev/data_conversions.rb +5 -5
- data/lib/iev/db.rb +5 -3
- data/lib/iev/db_cache.rb +7 -5
- data/lib/iev/db_writer.rb +3 -2
- data/lib/iev/iso_639_code.rb +8 -12
- data/lib/iev/profiler.rb +7 -7
- data/lib/iev/relaton_db.rb +8 -12
- data/lib/iev/source_parser.rb +60 -62
- data/lib/iev/supersession_parser.rb +7 -8
- data/lib/iev/term_attrs_parser.rb +22 -23
- data/lib/iev/term_builder.rb +16 -19
- data/lib/iev/utilities.rb +40 -40
- data/lib/iev/version.rb +4 -2
- data/lib/iev.rb +5 -8
- metadata +25 -94
- data/exe/iev-glossarist +0 -21
@@ -3,10 +3,10 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
7
|
-
module
|
6
|
+
module Iev
|
7
|
+
module Cli
|
8
8
|
module CommandHelper
|
9
|
-
include
|
9
|
+
include Cli::Ui
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
@@ -19,7 +19,7 @@ module IEV
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
22
|
+
# NOTE: Implementation examples here:
|
23
23
|
# https://www.rubydoc.info/github/luislavena/sqlite3-ruby/SQLite3/Backup
|
24
24
|
def save_db_to_file(src_db, dbfile)
|
25
25
|
info "Saving database to a file..."
|
@@ -46,21 +46,23 @@ module IEV
|
|
46
46
|
$IEV_PROFILE = options[:profile]
|
47
47
|
$IEV_PROGRESS = options.fetch(:progress, !ENV["CI"])
|
48
48
|
|
49
|
-
$IEV_DEBUG = options.to_h
|
50
|
-
select { |k, _| k.to_s.start_with? "debug_" }
|
51
|
-
transform_keys
|
49
|
+
$IEV_DEBUG = options.to_h
|
50
|
+
.select { |k, _| k.to_s.start_with? "debug_" }
|
51
|
+
.transform_keys do |k|
|
52
|
+
k.to_s.sub("debug_",
|
53
|
+
"").to_sym
|
54
|
+
end
|
52
55
|
end
|
53
56
|
|
54
57
|
def filter_dataset(db, options)
|
55
58
|
query = db[:concepts]
|
56
59
|
|
57
60
|
if options[:only_concepts]
|
58
|
-
query = query.where(Sequel.ilike(:ievref,
|
61
|
+
query = query.where(Sequel.ilike(:ievref,
|
62
|
+
options[:only_concepts]))
|
59
63
|
end
|
60
64
|
|
61
|
-
if options[:only_languages]
|
62
|
-
query = query.where(language: options[:only_languages].split(","))
|
63
|
-
end
|
65
|
+
query = query.where(language: options[:only_languages].split(",")) if options[:only_languages]
|
64
66
|
|
65
67
|
query
|
66
68
|
end
|
data/lib/iev/cli/ui.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
7
|
-
module
|
6
|
+
module Iev
|
7
|
+
module Cli
|
8
8
|
# @todo
|
9
9
|
# Make it thread-safe. Currently, calling UI methods from different
|
10
10
|
# threads may result with mangled output. At first glance it seems like
|
11
11
|
# something is wrong with carriage returns, but more research is needed.
|
12
|
-
module
|
12
|
+
module Ui
|
13
13
|
module_function
|
14
14
|
|
15
15
|
def debug(*args)
|
@@ -42,11 +42,11 @@ module IEV
|
|
42
42
|
module_function
|
43
43
|
|
44
44
|
def clear_progress
|
45
|
-
$IEV_PROGRESS ? "\r#{
|
45
|
+
$IEV_PROGRESS ? "\r#{' ' * 40}\r" : ""
|
46
46
|
end
|
47
47
|
|
48
48
|
def cli_out(level, *args)
|
49
|
-
topic =
|
49
|
+
topic = args[0].is_a?(Symbol) ? args.shift : nil
|
50
50
|
message = args.map(&:to_s).join(" ").chomp
|
51
51
|
ui_tag = Thread.current[:iev_ui_tag]
|
52
52
|
|
data/lib/iev/cli.rb
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
7
|
-
module
|
6
|
+
module Iev
|
7
|
+
module Cli
|
8
8
|
def self.start(arguments)
|
9
9
|
Signal.trap("INT") do
|
10
|
-
|
10
|
+
Ui.info "Signal SIGINT received, quitting!"
|
11
11
|
Kernel.exit(1)
|
12
12
|
end
|
13
13
|
|
14
14
|
Signal.trap("TERM") do
|
15
|
-
|
15
|
+
Ui.info "Signal SIGTERM received, quitting!"
|
16
16
|
Kernel.exit(1)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
Iev::Cli::Command.start(arguments)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module Iev
|
4
4
|
module Converter
|
5
5
|
class MathmlToAsciimath
|
6
6
|
using DataConversions
|
@@ -21,9 +21,7 @@ module IEV
|
|
21
21
|
# any MathML or HTML formula.
|
22
22
|
return input unless input&.match?(/<|&/)
|
23
23
|
|
24
|
-
unless input.include?("<math>")
|
25
|
-
return html_to_asciimath(input)
|
26
|
-
end
|
24
|
+
return html_to_asciimath(input) unless input.include?("<math>")
|
27
25
|
|
28
26
|
# puts "GOING TO MATHML MATH"
|
29
27
|
# puts input
|
@@ -107,7 +105,7 @@ module IEV
|
|
107
105
|
to_asciimath
|
108
106
|
.children.to_s
|
109
107
|
.gsub(/\]stem:\[/, "")
|
110
|
-
.gsub(
|
108
|
+
.gsub(%r{</?[uo]l>}, ""),
|
111
109
|
)
|
112
110
|
end
|
113
111
|
|
@@ -116,81 +114,81 @@ module IEV
|
|
116
114
|
end
|
117
115
|
|
118
116
|
def html_entities_to_asciimath(input)
|
119
|
-
input.gsub("α", "alpha")
|
120
|
-
gsub("β", "beta")
|
121
|
-
gsub("γ", "gamma")
|
122
|
-
gsub("Γ", "Gamma")
|
123
|
-
gsub("δ", "delta")
|
124
|
-
gsub("Δ", "Delta")
|
125
|
-
gsub("ε", "epsilon")
|
126
|
-
gsub("ϵ", "varepsilon")
|
127
|
-
gsub("ζ", "zeta")
|
128
|
-
gsub("η", "eta")
|
129
|
-
gsub("θ", "theta")
|
130
|
-
gsub("Θ", "Theta")
|
131
|
-
gsub("ϑ", "vartheta")
|
132
|
-
gsub("ι", "iota")
|
133
|
-
gsub("κ", "kappa")
|
134
|
-
gsub("λ", "lambda")
|
135
|
-
gsub("Λ", "Lambda")
|
136
|
-
gsub("μ", "mu")
|
137
|
-
gsub("ν", "nu")
|
138
|
-
gsub("ξ", "xi")
|
139
|
-
gsub("Ξ", "Xi")
|
140
|
-
gsub("π", "pi")
|
141
|
-
gsub("Π", "Pi")
|
142
|
-
gsub("ρ", "rho")
|
143
|
-
gsub("β", "beta")
|
144
|
-
gsub("σ", "sigma")
|
145
|
-
gsub("Σ", "Sigma")
|
146
|
-
gsub("τ", "tau")
|
147
|
-
gsub("υ", "upsilon")
|
148
|
-
gsub("φ", "phi")
|
149
|
-
gsub("Φ", "Phi")
|
150
|
-
gsub("ϕ", "varphi")
|
151
|
-
gsub("χ", "chi")
|
152
|
-
gsub("ψ", "psi")
|
153
|
-
gsub("Ψ", "Psi")
|
154
|
-
gsub("ω", "omega")
|
117
|
+
input.gsub("α", "alpha")
|
118
|
+
.gsub("β", "beta")
|
119
|
+
.gsub("γ", "gamma")
|
120
|
+
.gsub("Γ", "Gamma")
|
121
|
+
.gsub("δ", "delta")
|
122
|
+
.gsub("Δ", "Delta")
|
123
|
+
.gsub("ε", "epsilon")
|
124
|
+
.gsub("ϵ", "varepsilon")
|
125
|
+
.gsub("ζ", "zeta")
|
126
|
+
.gsub("η", "eta")
|
127
|
+
.gsub("θ", "theta")
|
128
|
+
.gsub("Θ", "Theta")
|
129
|
+
.gsub("ϑ", "vartheta")
|
130
|
+
.gsub("ι", "iota")
|
131
|
+
.gsub("κ", "kappa")
|
132
|
+
.gsub("λ", "lambda")
|
133
|
+
.gsub("Λ", "Lambda")
|
134
|
+
.gsub("μ", "mu")
|
135
|
+
.gsub("ν", "nu")
|
136
|
+
.gsub("ξ", "xi")
|
137
|
+
.gsub("Ξ", "Xi")
|
138
|
+
.gsub("π", "pi")
|
139
|
+
.gsub("Π", "Pi")
|
140
|
+
.gsub("ρ", "rho")
|
141
|
+
.gsub("β", "beta")
|
142
|
+
.gsub("σ", "sigma")
|
143
|
+
.gsub("Σ", "Sigma")
|
144
|
+
.gsub("τ", "tau")
|
145
|
+
.gsub("υ", "upsilon")
|
146
|
+
.gsub("φ", "phi")
|
147
|
+
.gsub("Φ", "Phi")
|
148
|
+
.gsub("ϕ", "varphi")
|
149
|
+
.gsub("χ", "chi")
|
150
|
+
.gsub("ψ", "psi")
|
151
|
+
.gsub("Ψ", "Psi")
|
152
|
+
.gsub("ω", "omega")
|
155
153
|
end
|
156
154
|
|
157
155
|
def html_entities_to_stem(input)
|
158
|
-
input.gsub("α", "stem:[alpha]")
|
159
|
-
gsub("β", "stem:[beta]")
|
160
|
-
gsub("γ", "stem:[gamma]")
|
161
|
-
gsub("Γ", "stem:[Gamma]")
|
162
|
-
gsub("δ", "stem:[delta]")
|
163
|
-
gsub("Δ", "stem:[Delta]")
|
164
|
-
gsub("ε", "stem:[epsilon]")
|
165
|
-
gsub("ϵ", "stem:[varepsilon]")
|
166
|
-
gsub("ζ", "stem:[zeta]")
|
167
|
-
gsub("η", "stem:[eta]")
|
168
|
-
gsub("θ", "stem:[theta]")
|
169
|
-
gsub("Θ", "stem:[Theta]")
|
170
|
-
gsub("ϑ", "stem:[vartheta]")
|
171
|
-
gsub("ι", "stem:[iota]")
|
172
|
-
gsub("κ", "stem:[kappa]")
|
173
|
-
gsub("λ", "stem:[lambda]")
|
174
|
-
gsub("Λ", "stem:[Lambda]")
|
175
|
-
gsub("μ", "stem:[mu]")
|
176
|
-
gsub("ν", "stem:[nu]")
|
177
|
-
gsub("ξ", "stem:[xi]")
|
178
|
-
gsub("Ξ", "stem:[Xi]")
|
179
|
-
gsub("π", "stem:[pi]")
|
180
|
-
gsub("Π", "stem:[Pi]")
|
181
|
-
gsub("ρ", "stem:[rho]")
|
182
|
-
gsub("β", "stem:[beta]")
|
183
|
-
gsub("σ", "stem:[sigma]")
|
184
|
-
gsub("Σ", "stem:[Sigma]")
|
185
|
-
gsub("τ", "stem:[tau]")
|
186
|
-
gsub("υ", "stem:[upsilon]")
|
187
|
-
gsub("φ", "stem:[phi]")
|
188
|
-
gsub("Φ", "stem:[Phi]")
|
189
|
-
gsub("ϕ", "stem:[varphi]")
|
190
|
-
gsub("χ", "stem:[chi]")
|
191
|
-
gsub("ψ", "stem:[psi]")
|
192
|
-
gsub("Ψ", "stem:[Psi]")
|
193
|
-
gsub("ω", "stem:[omega]")
|
156
|
+
input.gsub("α", "stem:[alpha]")
|
157
|
+
.gsub("β", "stem:[beta]")
|
158
|
+
.gsub("γ", "stem:[gamma]")
|
159
|
+
.gsub("Γ", "stem:[Gamma]")
|
160
|
+
.gsub("δ", "stem:[delta]")
|
161
|
+
.gsub("Δ", "stem:[Delta]")
|
162
|
+
.gsub("ε", "stem:[epsilon]")
|
163
|
+
.gsub("ϵ", "stem:[varepsilon]")
|
164
|
+
.gsub("ζ", "stem:[zeta]")
|
165
|
+
.gsub("η", "stem:[eta]")
|
166
|
+
.gsub("θ", "stem:[theta]")
|
167
|
+
.gsub("Θ", "stem:[Theta]")
|
168
|
+
.gsub("ϑ", "stem:[vartheta]")
|
169
|
+
.gsub("ι", "stem:[iota]")
|
170
|
+
.gsub("κ", "stem:[kappa]")
|
171
|
+
.gsub("λ", "stem:[lambda]")
|
172
|
+
.gsub("Λ", "stem:[Lambda]")
|
173
|
+
.gsub("μ", "stem:[mu]")
|
174
|
+
.gsub("ν", "stem:[nu]")
|
175
|
+
.gsub("ξ", "stem:[xi]")
|
176
|
+
.gsub("Ξ", "stem:[Xi]")
|
177
|
+
.gsub("π", "stem:[pi]")
|
178
|
+
.gsub("Π", "stem:[Pi]")
|
179
|
+
.gsub("ρ", "stem:[rho]")
|
180
|
+
.gsub("β", "stem:[beta]")
|
181
|
+
.gsub("σ", "stem:[sigma]")
|
182
|
+
.gsub("Σ", "stem:[Sigma]")
|
183
|
+
.gsub("τ", "stem:[tau]")
|
184
|
+
.gsub("υ", "stem:[upsilon]")
|
185
|
+
.gsub("φ", "stem:[phi]")
|
186
|
+
.gsub("Φ", "stem:[Phi]")
|
187
|
+
.gsub("ϕ", "stem:[varphi]")
|
188
|
+
.gsub("χ", "stem:[chi]")
|
189
|
+
.gsub("ψ", "stem:[psi]")
|
190
|
+
.gsub("Ψ", "stem:[Psi]")
|
191
|
+
.gsub("ω", "stem:[omega]")
|
194
192
|
end
|
195
193
|
end
|
196
194
|
end
|
data/lib/iev/converter.rb
CHANGED
data/lib/iev/data_conversions.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
6
|
+
module Iev
|
7
7
|
module DataConversions
|
8
8
|
refine String do
|
9
9
|
def decode_html!
|
@@ -18,9 +18,9 @@ module IEV
|
|
18
18
|
# Normalize various encoding anomalies like `\uFEFF` in strings
|
19
19
|
def sanitize!
|
20
20
|
unicode_normalize!
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
delete!("\uFEFF")
|
22
|
+
tr!("\u2011", "-")
|
23
|
+
tr!("\u00a0", " ")
|
24
24
|
gsub!(/[\u2000-\u2006]/, " ")
|
25
25
|
strip!
|
26
26
|
nil
|
@@ -32,7 +32,7 @@ module IEV
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def to_three_char_code
|
35
|
-
|
35
|
+
Iev::Iso639Code.three_char_code(self).first
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/iev/db.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# require 'pstore'
|
2
4
|
require_relative "db_cache"
|
3
5
|
|
4
|
-
module
|
6
|
+
module Iev
|
5
7
|
# Cache class.
|
6
8
|
class Db
|
7
9
|
# @param global_cache [String] filename of global DB
|
@@ -43,12 +45,12 @@ module IEV
|
|
43
45
|
|
44
46
|
# @return [Hash]
|
45
47
|
def new_bib_entry(code, lang)
|
46
|
-
|
48
|
+
Iev.get(code, lang)
|
47
49
|
end
|
48
50
|
|
49
51
|
# @param dir [String] DB dir
|
50
52
|
# @param global [TrueClass, FalseClass]
|
51
|
-
# @return [
|
53
|
+
# @return [Iev::DbCache, nil]
|
52
54
|
def open_cache_biblio(dir, global: true)
|
53
55
|
return nil if dir.nil?
|
54
56
|
|
data/lib/iev/db_cache.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fileutils"
|
2
4
|
|
3
|
-
module
|
5
|
+
module Iev
|
4
6
|
class DbCache
|
5
7
|
# @return [String]
|
6
8
|
attr_reader :dir
|
@@ -8,7 +10,7 @@ module IEV
|
|
8
10
|
# @param dir [String] DB directory
|
9
11
|
def initialize(dir)
|
10
12
|
@dir = dir
|
11
|
-
FileUtils
|
13
|
+
FileUtils.mkdir_p @dir
|
12
14
|
file_version = "#{@dir}/version"
|
13
15
|
File.exist? file_version or
|
14
16
|
File.write file_version, VERSION, encoding: "utf-8"
|
@@ -21,7 +23,7 @@ module IEV
|
|
21
23
|
return if value.nil?
|
22
24
|
|
23
25
|
prefix_dir = "#{@dir}/#{prefix(key)}"
|
24
|
-
FileUtils
|
26
|
+
FileUtils.mkdir_p prefix_dir
|
25
27
|
File.write filename(key), value, encoding: "utf-8"
|
26
28
|
end
|
27
29
|
|
@@ -73,7 +75,7 @@ module IEV
|
|
73
75
|
end
|
74
76
|
|
75
77
|
# Set version of the DB to the gem version.
|
76
|
-
# @return [
|
78
|
+
# @return [Iev::DbCache]
|
77
79
|
def set_version
|
78
80
|
File.write "#{@dir}/version", VERSION, encoding: "utf-8"
|
79
81
|
self
|
@@ -100,7 +102,7 @@ module IEV
|
|
100
102
|
# if prefcode
|
101
103
|
# "#{@dir}/#{prefcode[:prefix]}/#{prefcode[:code].gsub(/[-:\s\/]/, '_')}.xml"
|
102
104
|
# else
|
103
|
-
"#{@dir}/#{key.gsub(
|
105
|
+
"#{@dir}/#{key.gsub(%r{[-:\s/]}, '_')}.xml"
|
104
106
|
# end
|
105
107
|
end
|
106
108
|
|
data/lib/iev/db_writer.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
6
|
+
module Iev
|
7
7
|
class DbWriter
|
8
|
-
include
|
8
|
+
include Cli::Ui
|
9
9
|
using DataConversions
|
10
10
|
|
11
11
|
attr_reader :db
|
@@ -27,6 +27,7 @@ module IEV
|
|
27
27
|
loop do
|
28
28
|
row = row_enumerator.next
|
29
29
|
next if row.empty?
|
30
|
+
|
30
31
|
data = prepare_data(row, symbolized_title_row)
|
31
32
|
display_progress(data)
|
32
33
|
insert_data(data)
|
data/lib/iev/iso_639_code.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
6
|
+
module Iev
|
7
7
|
# @todo This needs to be rewritten.
|
8
8
|
class Iso639Code
|
9
9
|
COUNTRY_CODES = YAML.load(IO.read(File.join(__dir__, "iso_639_2.yaml")))
|
@@ -11,12 +11,12 @@ module IEV
|
|
11
11
|
|
12
12
|
def initialize(two_char_code)
|
13
13
|
@code = case two_char_code.length
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
when 2
|
15
|
+
two_char_code
|
16
|
+
else
|
17
|
+
# This is to handle code "nl BE" in the Iev sheet
|
18
|
+
two_char_code.split(" ").first
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def find(code_type)
|
@@ -24,9 +24,7 @@ module IEV
|
|
24
24
|
key if value["iso_639_1"] == @code.to_s && value[code_type]
|
25
25
|
end
|
26
26
|
|
27
|
-
if code.nil?
|
28
|
-
raise StandardError.new("Iso639Code not found for '#{@code}'!")
|
29
|
-
end
|
27
|
+
raise StandardError, "Iso639Code not found for '#{@code}'!" if code.nil?
|
30
28
|
|
31
29
|
code
|
32
30
|
end
|
@@ -41,7 +39,5 @@ module IEV
|
|
41
39
|
def country_codes
|
42
40
|
COUNTRY_CODES
|
43
41
|
end
|
44
|
-
|
45
42
|
end
|
46
43
|
end
|
47
|
-
|
data/lib/iev/profiler.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
# (c) Copyright 2020 Ribose Inc.
|
4
4
|
#
|
5
5
|
|
6
|
-
module
|
6
|
+
module Iev
|
7
7
|
class Profiler
|
8
8
|
attr_reader :bench, :dir, :prefix, :profile
|
9
9
|
|
10
|
-
def self.measure(prefix = nil, &
|
11
|
-
new(prefix).run(&
|
10
|
+
def self.measure(prefix = nil, &)
|
11
|
+
new(prefix).run(&)
|
12
12
|
end
|
13
13
|
|
14
14
|
def initialize(prefix, dir: "profile")
|
@@ -16,15 +16,15 @@ module IEV
|
|
16
16
|
@dir = dir
|
17
17
|
end
|
18
18
|
|
19
|
-
def run(&
|
20
|
-
profiler_enabled? ? run!(&
|
19
|
+
def run(&)
|
20
|
+
profiler_enabled? ? run!(&) : yield
|
21
21
|
end
|
22
22
|
|
23
|
-
def run!
|
23
|
+
def run!
|
24
24
|
retval = nil
|
25
25
|
@profile = RubyProf.profile allow_exceptions: true do
|
26
26
|
@bench = Benchmark.measure do
|
27
|
-
retval =
|
27
|
+
retval = yield
|
28
28
|
end
|
29
29
|
end
|
30
30
|
retval
|
data/lib/iev/relaton_db.rb
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
require "singleton"
|
7
7
|
|
8
|
-
module
|
8
|
+
module Iev
|
9
9
|
# Relaton cach singleton.
|
10
10
|
class RelatonDb
|
11
11
|
include Singleton
|
12
|
-
include
|
12
|
+
include Cli::Ui
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
info "Initializing Relaton..."
|
@@ -33,15 +33,12 @@ module IEV
|
|
33
33
|
|
34
34
|
begin
|
35
35
|
yield
|
36
|
+
rescue StandardError
|
37
|
+
raise unless curr_attempt <= attempts
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
curr_attempt += 1
|
41
|
-
retry
|
42
|
-
else
|
43
|
-
raise
|
44
|
-
end
|
39
|
+
sleep(2**curr_attempt * 0.1)
|
40
|
+
curr_attempt += 1
|
41
|
+
retry
|
45
42
|
end
|
46
43
|
end
|
47
44
|
|
@@ -52,11 +49,10 @@ module IEV
|
|
52
49
|
|
53
50
|
begin
|
54
51
|
yield
|
55
|
-
|
56
52
|
ensure
|
57
53
|
$stdout = original_stdout
|
58
54
|
$stderr = original_stderr
|
59
|
-
debug(:relaton, fake_out.string) if fake_out.pos
|
55
|
+
debug(:relaton, fake_out.string) if fake_out.pos.positive?
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|