rdoba 0.9.1 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.gitignore +4 -0
- data/.travis.yml +28 -0
- data/CHANGES.md +6 -0
- data/Gemfile +5 -0
- data/README.md +87 -108
- data/Rakefile +62 -54
- data/TODO +6 -0
- data/features/mixin.feature +85 -0
- data/features/step_definitions/mixin_steps.rb +305 -0
- data/features/support/env.rb +35 -145
- data/features/support/mixin_support.rb +17 -0
- data/html/.keep +0 -0
- data/lib/rdoba/_version_.rb +3 -1
- data/lib/rdoba/a.rb +44 -42
- data/lib/rdoba/bcd.rb +43 -26
- data/lib/rdoba/blank.rb +14 -0
- data/lib/rdoba/combinations.rb +17 -15
- data/lib/rdoba/common.rb +53 -68
- data/lib/rdoba/debug.rb +9 -3
- data/lib/rdoba/deploy.rb +55 -50
- data/lib/rdoba/dup.rb +31 -31
- data/lib/rdoba/fe.rb +6 -5
- data/lib/rdoba/gem.rb +33 -29
- data/lib/rdoba/hashorder.rb +24 -24
- data/lib/rdoba/io.rb +81 -74
- data/lib/rdoba/merge.rb +21 -0
- data/lib/rdoba/mixin/time.rb +17 -0
- data/lib/rdoba/mixin/try.rb +11 -0
- data/lib/rdoba/mixin/try_1_9_0.rb +9 -0
- data/lib/rdoba/mixin/wait_if.rb +27 -0
- data/lib/rdoba/mixin.rb +373 -52
- data/lib/rdoba/numeric.rb +19 -17
- data/lib/rdoba/os.rb +127 -0
- data/lib/rdoba/re.rb +4 -4
- data/lib/rdoba/require.rb +24 -19
- data/lib/rdoba/roman.rb +32 -22
- data/lib/rdoba/strings.rb +6 -144
- data/lib/rdoba/yaml.rb +20 -18
- data/lib/rdoba.rb +50 -47
- data/rdoba.gemspec +33 -26
- data/tddium.yml +11 -0
- metadata +184 -77
- data/features/bcd.feature +0 -29
- data/features/log.feature +0 -206
- data/features/step_definitions/bcd_steps.rb +0 -69
- data/features/step_definitions/log_steps.rb +0 -164
- data/lib/rdoba/log.rb +0 -248
- data/test/helper.rb +0 -18
- data/test/rdoba_test.rb.stub +0 -59
- data/test/test_rdoba.rb +0 -7
data/lib/rdoba/bcd.rb
CHANGED
@@ -1,61 +1,78 @@
|
|
1
|
-
#
|
2
|
-
#
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module BCD
|
5
|
-
class ParseError <
|
6
|
-
def initialize
|
4
|
+
class ParseError < RuntimeError
|
5
|
+
def initialize(msg = 'Invalid positive integer value'); end
|
6
|
+
end
|
7
7
|
|
8
|
-
class ConvertError <
|
9
|
-
def initialize
|
8
|
+
class ConvertError < RuntimeError
|
9
|
+
def initialize(msg = 'Invalid number has given'); end
|
10
|
+
end
|
10
11
|
|
11
12
|
def to_i
|
12
13
|
res = 0
|
13
14
|
mul = 1
|
14
|
-
|
15
|
-
def pow
|
15
|
+
each_byte do |c|
|
16
|
+
def pow(value, mul)
|
16
17
|
if value >= 10
|
17
|
-
raise ConvertError
|
18
|
+
raise ConvertError
|
19
|
+
end
|
20
|
+
|
18
21
|
value * mul
|
19
22
|
end
|
20
|
-
res += pow(
|
23
|
+
res += pow(c.ord & 0xF, mul)
|
21
24
|
mul *= 10
|
22
|
-
res += pow(
|
25
|
+
res += pow(c.ord >> 4, mul)
|
23
26
|
mul *= 10
|
24
27
|
end
|
25
|
-
res
|
28
|
+
res
|
29
|
+
end
|
26
30
|
|
27
|
-
def self.parse
|
31
|
+
def self.parse(value)
|
28
32
|
if value < 0
|
29
|
-
raise ParseError
|
33
|
+
raise ParseError
|
34
|
+
end
|
35
|
+
|
30
36
|
res = BCDString.new
|
31
37
|
if res.respond_to? :force_encoding
|
32
|
-
res.force_encoding(
|
38
|
+
res.force_encoding('ASCII-8BIT')
|
39
|
+
end
|
33
40
|
if value > 0
|
34
41
|
part = nil
|
35
42
|
while value > 0
|
36
|
-
|
43
|
+
value, mod = value.divmod 10
|
37
44
|
if part
|
38
|
-
res << (
|
45
|
+
res << ((mod << 4) | part).chr
|
39
46
|
part = nil
|
40
47
|
else
|
41
|
-
part = mod
|
48
|
+
part = mod
|
49
|
+
end
|
50
|
+
end
|
42
51
|
if part
|
43
|
-
res << part.chr
|
52
|
+
res << part.chr
|
53
|
+
end
|
44
54
|
else
|
45
|
-
res << 0.chr
|
46
|
-
|
55
|
+
res << 0.chr
|
56
|
+
end
|
57
|
+
res
|
58
|
+
end
|
59
|
+
end
|
47
60
|
|
48
61
|
class BCDString < String
|
49
62
|
include BCD
|
50
63
|
|
51
|
-
def initialize
|
64
|
+
def initialize(value = nil)
|
52
65
|
if value.is_a? Numeric
|
53
|
-
|
66
|
+
replace BCD.parse(value)
|
54
67
|
else
|
55
|
-
super value.to_s
|
68
|
+
super value.to_s
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
56
72
|
|
57
73
|
class Numeric
|
58
74
|
def to_bcd
|
59
75
|
# NOTE: return as plain LSB string
|
60
|
-
BCD.parse value
|
61
|
-
|
76
|
+
BCD.parse value
|
77
|
+
end
|
78
|
+
end
|
data/lib/rdoba/blank.rb
ADDED
data/lib/rdoba/combinations.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
class Array
|
4
|
-
|
5
|
-
private
|
5
|
+
private
|
6
6
|
|
7
7
|
def __comby(i, size)
|
8
|
-
s = "0#{
|
9
|
-
v = { :
|
8
|
+
s = "0#{format('%.*b', size, i)}0"
|
9
|
+
v = { res: [], c0: 0, c1: 0, j: 0 }
|
10
10
|
|
11
11
|
def up1(v)
|
12
12
|
sub_j = v[:j] + v[:c1] + 1
|
@@ -17,7 +17,9 @@ private
|
|
17
17
|
|
18
18
|
def up0(v)
|
19
19
|
sub_j = v[:j] + v[:c0] - 1
|
20
|
-
self[v[:j]...sub_j].each do |x|
|
20
|
+
self[v[:j]...sub_j].each do |x|
|
21
|
+
v[:res] << [x]
|
22
|
+
end
|
21
23
|
v[:j] = sub_j
|
22
24
|
end
|
23
25
|
|
@@ -35,25 +37,25 @@ private
|
|
35
37
|
v[:res]
|
36
38
|
end
|
37
39
|
|
38
|
-
public
|
40
|
+
public
|
39
41
|
|
40
42
|
def each_comby(*args)
|
41
|
-
return self if
|
43
|
+
return self if empty? or !block_given?
|
44
|
+
|
42
45
|
if args.include?(:backward)
|
43
|
-
yield [
|
44
|
-
((1 << (
|
45
|
-
c = __comby(i,
|
46
|
+
yield [dup]
|
47
|
+
((1 << (size - 1)) - 2).downto(0) do |i|
|
48
|
+
c = __comby(i, size - 1)
|
46
49
|
yield c
|
47
50
|
end
|
48
51
|
else
|
49
|
-
0.upto((1 << (
|
50
|
-
c = __comby(i,
|
52
|
+
0.upto((1 << (size - 1)) - 2) do |i|
|
53
|
+
c = __comby(i, size - 1)
|
51
54
|
yield c
|
52
55
|
end
|
53
|
-
yield [
|
56
|
+
yield [dup]
|
54
57
|
end
|
55
58
|
|
56
|
-
|
59
|
+
self
|
57
60
|
end
|
58
61
|
end
|
59
|
-
|
data/lib/rdoba/common.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
class Object
|
5
5
|
def xor(val1)
|
6
|
-
val0 =
|
7
|
-
(
|
6
|
+
val0 = !!self
|
7
|
+
(val0 and !val1) or (!val0 and val1)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
# calls any method
|
11
|
+
def co(method, *_args)
|
11
12
|
eval "#{method}(*args)"
|
12
13
|
end
|
13
14
|
|
@@ -20,49 +21,36 @@ class Object
|
|
20
21
|
opts.each do |opt|
|
21
22
|
case opt.class.to_s.to_sym
|
22
23
|
when :Hash
|
23
|
-
|
24
|
+
opt.each do |x, y|
|
25
|
+
v[x] = y
|
26
|
+
end
|
24
27
|
when :Array
|
25
|
-
|
28
|
+
opt.each do |x|
|
29
|
+
v[x] = true
|
30
|
+
end
|
26
31
|
when :Symbol
|
27
|
-
|
32
|
+
v[opt] = true
|
28
33
|
end
|
29
34
|
end
|
30
35
|
v
|
31
36
|
end
|
32
37
|
|
33
38
|
def apply_opts(opts)
|
34
|
-
parse_opts(opts).each do |x,y|
|
35
|
-
self.instance_variable_set("@#{x}".to_sym, y)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
module Kernel
|
41
|
-
def wait_if(timeout = 30)
|
42
|
-
require 'timeout'
|
43
|
-
|
44
|
-
begin
|
45
|
-
Timeout::timeout(timeout) do
|
46
|
-
while yield(); end
|
47
|
-
end
|
48
|
-
true
|
49
|
-
rescue Timeout::Error
|
50
|
-
false
|
51
|
-
end
|
39
|
+
parse_opts(opts).each do |x, y| instance_variable_set("@#{x}".to_sym, y)end
|
52
40
|
end
|
53
41
|
end
|
54
42
|
|
55
43
|
class NilClass
|
56
44
|
def =~(value)
|
57
|
-
value
|
45
|
+
value.nil?
|
58
46
|
end
|
59
47
|
|
60
|
-
def +(
|
61
|
-
|
48
|
+
def +(other)
|
49
|
+
other
|
62
50
|
end
|
63
51
|
|
64
52
|
def <<(value)
|
65
|
-
[
|
53
|
+
[value]
|
66
54
|
end
|
67
55
|
|
68
56
|
def empty?
|
@@ -72,59 +60,58 @@ class NilClass
|
|
72
60
|
def to_i
|
73
61
|
0
|
74
62
|
end
|
75
|
-
alias
|
63
|
+
alias ord to_i
|
76
64
|
|
77
65
|
def size
|
78
66
|
0
|
79
67
|
end
|
80
68
|
|
81
|
-
def <=>(
|
69
|
+
def <=>(_other)
|
82
70
|
-1
|
83
71
|
end
|
84
72
|
end
|
85
73
|
|
86
|
-
|
87
74
|
class Array
|
88
75
|
def purge
|
89
|
-
|
76
|
+
compact.delete_if { |x| x.empty? }
|
90
77
|
end
|
91
78
|
|
92
79
|
def >>(value = nil)
|
93
80
|
value ? delete(value) : shift
|
94
81
|
end
|
95
82
|
|
96
|
-
alias
|
83
|
+
alias __get__ []
|
97
84
|
def [](index, *args)
|
98
|
-
return __get__(index.to_i, *args) if index.
|
85
|
+
return __get__(index.to_i, *args) if index.instance_of?(String) and index =~ /^\d+$/
|
86
|
+
|
99
87
|
__get__(index, *args)
|
100
88
|
end
|
101
89
|
|
102
|
-
alias
|
90
|
+
alias __set__ []=
|
103
91
|
def []=(index, value, *args)
|
104
|
-
return __set__(index.to_i, value, *args) if index.
|
92
|
+
return __set__(index.to_i, value, *args) if index.instance_of?(String) and index =~ /^\d+$/
|
93
|
+
|
105
94
|
__set__(index, value, *args)
|
106
95
|
end
|
107
96
|
end
|
108
97
|
|
109
98
|
class String
|
110
|
-
def -(
|
111
|
-
#TODO make smart search for match in the 'str', when only last subpart matched to 'self'
|
112
|
-
len =
|
99
|
+
def -(other)
|
100
|
+
# TODO: make smart search for match in the 'str', when only last subpart matched to 'self'
|
101
|
+
len = size
|
113
102
|
bc = ec = nil
|
114
103
|
(0...len).each do |idx|
|
115
|
-
break bc = idx if self[idx] ==
|
104
|
+
break bc = idx if self[idx] == other[0]
|
116
105
|
end
|
117
|
-
((bc + 1)...len).each do |idx|
|
118
|
-
|
119
|
-
end if bc
|
120
|
-
(not bc) ? self.clone : (not ec) ? self[0, bc] : self[0, bc] + self[ec, len - ec]
|
106
|
+
((bc + 1)...len).each do |idx| break ec = idx if self[idx] != other[idx - bc]end if bc
|
107
|
+
bc ? ec ? self[0, bc] + self[ec, len - ec] : self[0, bc] : clone
|
121
108
|
end
|
122
109
|
|
123
|
-
alias
|
110
|
+
alias __match__ =~
|
124
111
|
def =~(value)
|
125
|
-
if value.
|
112
|
+
if value.instance_of?(String)
|
126
113
|
self == value
|
127
|
-
elsif value.
|
114
|
+
elsif value.instance_of?(Regexp)
|
128
115
|
value =~ self
|
129
116
|
else
|
130
117
|
__match__(value)
|
@@ -132,14 +119,14 @@ class String
|
|
132
119
|
end
|
133
120
|
|
134
121
|
def rmatch(value)
|
135
|
-
self == value || self =~
|
122
|
+
self == value || self =~ %r{^/([^/]+)} && value =~ /#{Regexp.last_match(1)}/
|
136
123
|
end
|
137
124
|
|
138
125
|
def hexdump
|
139
|
-
res= ''
|
126
|
+
res = ''
|
140
127
|
i = 0
|
141
|
-
|
142
|
-
res <<
|
128
|
+
each_byte do |byte|
|
129
|
+
res << format('%.2X ', byte)
|
143
130
|
i += 1
|
144
131
|
res << "\n" if i % 16 == 0
|
145
132
|
end
|
@@ -148,13 +135,13 @@ class String
|
|
148
135
|
end
|
149
136
|
|
150
137
|
class Hash
|
151
|
-
def |(
|
152
|
-
res =
|
153
|
-
|
154
|
-
if val.
|
155
|
-
if val.
|
156
|
-
res[key] |=
|
157
|
-
elsif val.
|
138
|
+
def |(other)
|
139
|
+
res = dup
|
140
|
+
other.each_pair do |key, val|
|
141
|
+
if val.instance_of?(res[key].class)
|
142
|
+
if val.instance_of?(Hash)
|
143
|
+
res[key] |= other[key]
|
144
|
+
elsif val.instance_of?(Array)
|
158
145
|
res[key].concat val
|
159
146
|
else
|
160
147
|
res[key] = val
|
@@ -172,19 +159,17 @@ class Hash
|
|
172
159
|
|
173
160
|
def reverse
|
174
161
|
h = {}
|
175
|
-
|
162
|
+
each_pair do |key, value|
|
176
163
|
if h.key? value
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
164
|
+
if h[value].instance_of?(Array)
|
165
|
+
h[value] << key
|
166
|
+
else
|
167
|
+
h[value] = [h[value], key]
|
168
|
+
end
|
182
169
|
else
|
183
|
-
|
170
|
+
h[value] = key
|
184
171
|
end
|
185
172
|
end
|
186
173
|
h
|
187
174
|
end
|
188
175
|
end
|
189
|
-
|
190
|
-
|
data/lib/rdoba/debug.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
warn "Warning: the module has kept only for backward compatibility\n" \
|
4
|
+
"Please use 'rdoba :log' form instead"
|
2
5
|
|
3
|
-
STDERR.puts "Warning: the module has kept only for backward compatibility\n" +
|
4
|
-
"Please use 'rdoba :log' form instead"
|
5
6
|
require 'rdoba/log'
|
6
7
|
|
8
|
+
module Rdoba
|
9
|
+
def self.debug(options = {})
|
10
|
+
Rdoba.log options
|
11
|
+
end
|
12
|
+
end
|
data/lib/rdoba/deploy.rb
CHANGED
@@ -1,74 +1,80 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rdoba/common'
|
5
5
|
|
6
6
|
class Hash
|
7
|
-
|
8
7
|
def deploy!(vars = {})
|
9
|
-
|
10
|
-
# TODO add variable copy
|
8
|
+
replace deploy(vars)
|
9
|
+
# TODO: add variable copy
|
11
10
|
end
|
12
11
|
|
13
12
|
def deploy(vars = {})
|
14
13
|
res = {}
|
15
14
|
|
16
|
-
|
17
|
-
if x
|
18
|
-
|
15
|
+
keys.sort do |x, y|
|
16
|
+
if /=$/.match?(x)
|
17
|
+
/=$/.match?(y) ? x <=> y : -1
|
19
18
|
else
|
20
|
-
|
19
|
+
/=$/.match?(y) ? 1 : x <=> y
|
21
20
|
end
|
22
21
|
end.each do |key|
|
23
|
-
|
24
22
|
if key =~ /(.*)=$/
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
vars[Regexp.last_match(1)] = self[key]
|
24
|
+
next
|
28
25
|
elsif key =~ /(.*)@$/
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
sym = Regexp.last_match(1)
|
27
|
+
eval "res.class.co( :attr_accessor, :#{sym})"
|
28
|
+
eval "res.#{sym} = self[key]"
|
29
|
+
next
|
34
30
|
elsif key =~ /^%([^%].*)/
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
if var.class == Hash
|
39
|
-
res |= var.deploy(vars)
|
40
|
-
elsif var.class == String
|
41
|
-
res[var] = nil
|
42
|
-
else
|
43
|
-
raise "Undeployable hash #{$1} value class #{var.class}"
|
44
|
-
end
|
45
|
-
next
|
31
|
+
unless vars.key?(Regexp.last_match(1))
|
32
|
+
next warn 'Warning: undefined variable ' + "#{Regexp.last_match(1).inspect} found. Ignoring..."
|
33
|
+
end
|
46
34
|
|
35
|
+
var = vars[Regexp.last_match(1)].dup
|
36
|
+
if var.instance_of?(Hash)
|
37
|
+
res |= var.deploy(vars)
|
38
|
+
elsif var.instance_of?(String)
|
39
|
+
res[var] = nil
|
40
|
+
else
|
41
|
+
raise "Undeployable hash #{Regexp.last_match(1)} value class #{var.class}"
|
42
|
+
end
|
43
|
+
next
|
47
44
|
elsif key =~ /^%%(.*)/
|
48
|
-
|
45
|
+
key.replace Regexp.last_match(1).to_s
|
49
46
|
end
|
50
47
|
|
51
48
|
def deploy_value(value, vars)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
49
|
+
case value.class.to_sym
|
50
|
+
when :String
|
51
|
+
if value =~ /^%([^%].*)/
|
52
|
+
begin
|
53
|
+
vars[Regexp.last_match(1)].deploy(vars)
|
54
|
+
rescue StandardError
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
elsif value =~ /(.*)%([A-Za-z0-9_А-я]+)(.*)/
|
58
|
+
a = [Regexp.last_match(1).to_s, Regexp.last_match(2).to_s, Regexp.last_match(3).to_s]
|
59
|
+
a[1] =
|
60
|
+
begin
|
61
|
+
vars[a[1]].deploy(vars).to_s
|
62
|
+
rescue StandardError
|
63
|
+
vars[a[1]]
|
64
|
+
end
|
65
|
+
a.join
|
66
|
+
else
|
67
|
+
value
|
68
|
+
end
|
69
|
+
when :Hash
|
70
|
+
value.deploy(vars)
|
71
|
+
when :Array
|
72
|
+
value.map do |sub|
|
73
|
+
deploy_value(sub, vars)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
value
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
value = self[key]
|
@@ -77,4 +83,3 @@ class Hash
|
|
77
83
|
res
|
78
84
|
end
|
79
85
|
end
|
80
|
-
|
data/lib/rdoba/dup.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
class Array
|
5
|
-
alias
|
5
|
+
alias __dup__ dup
|
6
6
|
def dup(opts = {})
|
7
|
-
if
|
7
|
+
if opts.instance_of?(Hash) ? opts.key?(:recursive) : opts.to_s.to_sym == :recursive
|
8
8
|
res = []
|
9
9
|
|
10
10
|
def sub_dup(value)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
if /(Hash|Array)/.match?(value.class.to_s)
|
12
|
+
value.dup(:recursive)
|
13
|
+
else
|
14
|
+
begin
|
15
|
+
value.dup
|
16
|
+
rescue StandardError
|
17
|
+
new = value
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
each do |value|
|
23
|
+
res << sub_dup(value)
|
24
|
+
end
|
23
25
|
|
24
26
|
res
|
25
27
|
elsif opts.empty?
|
26
28
|
__dup__
|
27
29
|
else
|
28
|
-
raise "Unsupported option(s): #{opts.
|
30
|
+
raise "Unsupported option(s): #{opts.instance_of?(Hash) ? opts.keys.join(', ') : opts}"
|
29
31
|
end
|
30
32
|
end
|
31
|
-
|
32
33
|
end
|
33
34
|
|
34
35
|
class Hash
|
35
|
-
alias
|
36
|
+
alias __dup__ dup
|
36
37
|
def dup(opts = {})
|
37
|
-
if
|
38
|
+
if opts.instance_of?(Hash) ? opts.key?(:recursive) : opts.to_s.to_sym == :recursive
|
38
39
|
res = {}
|
39
40
|
|
40
41
|
def sub_dup(value)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
if /(Hash|Array)/.match?(value.class.to_s)
|
43
|
+
value.dup(:recursive)
|
44
|
+
else
|
45
|
+
begin
|
46
|
+
value.dup
|
47
|
+
rescue StandardError
|
48
|
+
new = value
|
49
|
+
end
|
50
|
+
end
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
+
each do |key, value|
|
54
|
+
res[sub_dup(key)] = sub_dup(value)
|
55
|
+
end
|
53
56
|
|
54
57
|
res
|
55
58
|
elsif opts.empty?
|
56
59
|
__dup__
|
57
60
|
else
|
58
|
-
raise "Unsupported option(s): #{opts.
|
61
|
+
raise "Unsupported option(s): #{opts.instance_of?(Hash) ? opts.keys.join(', ') : opts}"
|
59
62
|
end
|
60
63
|
end
|
61
|
-
|
62
64
|
end
|
63
|
-
|
64
|
-
|
data/lib/rdoba/fe.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
class String
|
4
5
|
def fe
|
@@ -6,13 +7,13 @@ class String
|
|
6
7
|
self
|
7
8
|
else
|
8
9
|
return self unless Encoding.default_internal
|
9
|
-
|
10
|
-
|
10
|
+
|
11
|
+
if frozen?
|
12
|
+
dup.force_encoding(Encoding.default_internal || 'UTF-8').freeze
|
11
13
|
else
|
12
|
-
|
14
|
+
force_encoding(Encoding.default_internal || 'UTF-8')
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
alias
|
18
|
+
alias fenc fe
|
17
19
|
end
|
18
|
-
|