rdoba 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +75 -90
- data/Rakefile +61 -55
- data/TODO +6 -0
- data/features/log.feature +100 -29
- data/features/mixin.feature +85 -0
- data/features/step_definitions/log_steps.rb +58 -22
- data/features/step_definitions/mixin_steps.rb +266 -0
- data/features/support/env.rb +48 -24
- data/features/support/fulltest_as_log.rb.in +143 -0
- data/features/support/fulltest_as_self.rb.in +144 -0
- data/features/support/mixin_support.rb +13 -0
- data/html/.keep +0 -0
- data/html/created.rid +28 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +590 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/js/darkfish.js +161 -0
- data/html/js/jquery.js +4 -0
- data/html/js/navigation.js +142 -0
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +228 -0
- data/html/js/searcher.js.gz +0 -0
- data/lib/rdoba/_version_.rb +1 -1
- data/lib/rdoba/common.rb +0 -15
- data/lib/rdoba/debug.rb +5 -1
- data/lib/rdoba/log.rb +360 -189
- data/lib/rdoba/merge.rb +21 -0
- data/lib/rdoba/mixin/time.rb +11 -0
- data/lib/rdoba/mixin/try.rb +6 -0
- data/lib/rdoba/mixin/try_1_9_0.rb +4 -0
- data/lib/rdoba/mixin/wait_if.rb +21 -0
- data/lib/rdoba/mixin.rb +270 -6
- data/lib/rdoba/strings.rb +4 -141
- data/lib/rdoba.rb +13 -19
- data/rdoba.gemspec +30 -24
- data/tddium.yml +11 -0
- metadata +260 -65
- data/features/bcd.feature +0 -29
- data/features/step_definitions/bcd_steps.rb +0 -69
- data/test/helper.rb +0 -18
- data/test/rdoba_test.rb.stub +0 -59
- data/test/test_rdoba.rb +0 -7
data/lib/rdoba/mixin.rb
CHANGED
@@ -1,8 +1,209 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
2
|
#encoding:utf-8
|
3
|
+
|
4
|
+
class String
|
5
|
+
# TODO obsolete
|
6
|
+
ByteByByte = 0
|
7
|
+
FirstChar = 1
|
8
|
+
end
|
3
9
|
|
4
10
|
module Rdoba
|
5
11
|
module Mixin
|
12
|
+
class InvalidOption < StandardError ; end
|
13
|
+
|
14
|
+
module CompareString
|
15
|
+
def compare_to value, opts = {}
|
16
|
+
if ( opts == :ignore_diacritics ||
|
17
|
+
opts.class == Hash && opts.key?( :ignore_diacritics ) )
|
18
|
+
# TODO verify composite range
|
19
|
+
def crop_diacritics(x)
|
20
|
+
(x < 0x300 ||
|
21
|
+
x > 0x36f && x < 0x483 ||
|
22
|
+
x > 0x487 && x < 0xa67c ||
|
23
|
+
x > 0xa67d) && x || nil
|
24
|
+
end
|
25
|
+
|
26
|
+
( self.unpack( 'U*' ).map do |x|
|
27
|
+
crop_diacritics( x ) ; end.compact ) <=>
|
28
|
+
( value.unpack( 'U*' ).map do |x|
|
29
|
+
crop_diacritics( x ) ; end.compact )
|
30
|
+
else
|
31
|
+
self <=> value ; end ; end ; end
|
32
|
+
|
33
|
+
module ReverseString
|
34
|
+
|
35
|
+
Fixups = [ :reverse ]
|
36
|
+
|
37
|
+
Aliases = {
|
38
|
+
:__rdoba_mixin_reverse_orig__ => :reverse
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
def __rdoba_mixin_reverse__ step = 1
|
43
|
+
if ( !step.is_a?( Numeric ) || step < 0 ) && step != :byte_by_byte
|
44
|
+
raise "Invalid step value #{step.inspect}" ; end
|
45
|
+
|
46
|
+
if step == :byte_by_byte || step == String::ByteByByte
|
47
|
+
arr = []
|
48
|
+
self.each_byte do | byte |
|
49
|
+
arr << byte.chr ; end
|
50
|
+
arr.reverse.join.force_encoding( self.encoding )
|
51
|
+
elsif step == 1
|
52
|
+
__rdoba_mixin_reverse_orig__
|
53
|
+
elsif step > 1
|
54
|
+
res = ''
|
55
|
+
offset = (self.size + 1) / step * step - step
|
56
|
+
( 0..offset ).step( step ) do | shift |
|
57
|
+
res += self[ offset - shift..offset - shift + 1 ] ; end
|
58
|
+
res ; end ; end ; end
|
59
|
+
|
60
|
+
module CaseString
|
61
|
+
Fixups = [ :upcase, :downcase ]
|
62
|
+
|
63
|
+
Aliases = {
|
64
|
+
:__rdoba_mixin_upcase_orig__ => :upcase,
|
65
|
+
:__rdoba_mixin_downcase_orig__ => :downcase
|
66
|
+
}
|
67
|
+
|
68
|
+
ConvertTable = {
|
69
|
+
:up => {
|
70
|
+
:ranges => [ {
|
71
|
+
:ords => [ (0xE0..0xFF), (0x3B1..0x3CB),
|
72
|
+
(0x430..0x44F) ],
|
73
|
+
:change => proc { | chr, value | chr -= 0x20 },
|
74
|
+
}, {
|
75
|
+
:ords => [ (0x3AC..0x3AC) ],
|
76
|
+
:change => proc { | ord | ord -= 0x26 },
|
77
|
+
}, {
|
78
|
+
:ords => [ (0x3AD..0x3AF) ],
|
79
|
+
:change => proc { | ord | ord -= 0x25 },
|
80
|
+
}, {
|
81
|
+
:ords => [ (0x3B0..0x3B0) ],
|
82
|
+
:change => proc { | ord | ord -= 0x22 },
|
83
|
+
}, {
|
84
|
+
:ords => [ (0x1F00..0x1F07), (0x1F10..0x1F17),
|
85
|
+
(0x1F20..0x1F27), (0x1F30..0x1F37),
|
86
|
+
(0x1F40..0x1F47), (0x1F50..0x1F57),
|
87
|
+
(0x1F60..0x1F67), (0x1F80..0x1F87),
|
88
|
+
(0x1F90..0x1F97), (0x1Fa0..0x1Fa7),
|
89
|
+
(0x1Fb0..0x1Fb3), ],
|
90
|
+
:change => proc { | ord | ord += 0x8 },
|
91
|
+
}, {
|
92
|
+
:ords => [ (0x450..0x45F) ],
|
93
|
+
:change => proc { | ord | ord -= 0x50 },
|
94
|
+
}, {
|
95
|
+
:ords => [ (0x100..0x1B9), (0x1C4..0x233),
|
96
|
+
(0x460..0x481), (0x48A..0x523),
|
97
|
+
(0x1E00..0x1E95), (0x1EA0..0x1EFF),
|
98
|
+
(0x0A642..0xA667), (0x0A680..0x0A697),
|
99
|
+
(0xA722..0xA7A9) ],
|
100
|
+
:change => proc { | ord | ord.odd? && ( ord - 1 ) || ord },
|
101
|
+
} ],
|
102
|
+
:default => proc do | ord |
|
103
|
+
[ ord ].pack( 'U' ).__rdoba_mixin_upcase_orig__ ; end },
|
104
|
+
:down => {
|
105
|
+
:ranges => [ {
|
106
|
+
:ords => [ (0xC0..0xDF), (0x391..0x3AB),
|
107
|
+
(0x410..0x42F) ],
|
108
|
+
:change => proc { |chr, value| chr += 0x20 },
|
109
|
+
}, {
|
110
|
+
:ords => [ (0x386..0x386) ],
|
111
|
+
:change => proc { | ord | ord += 0x26 },
|
112
|
+
}, {
|
113
|
+
:ords => [ (0x388..0x38A) ],
|
114
|
+
:change => proc { | ord | ord += 0x25 },
|
115
|
+
}, {
|
116
|
+
:ords => [ (0x38E..0x38E) ],
|
117
|
+
:change => proc { | ord | ord += 0x22 },
|
118
|
+
}, {
|
119
|
+
:ords => [ (0x1F08..0x1F0F), (0x1F18..0x1F1F),
|
120
|
+
(0x1F28..0x1F2F), (0x1F38..0x1F3F),
|
121
|
+
(0x1F48..0x1F4F), (0x1F58..0x1F5F),
|
122
|
+
(0x1F68..0x1F6F), (0x1F88..0x1F8F),
|
123
|
+
(0x1F98..0x1F9F), (0x1Fa8..0x1FaF),
|
124
|
+
(0x1Fb8..0x1FbA), ],
|
125
|
+
:change => proc { | ord | ord -= 0x8 },
|
126
|
+
}, {
|
127
|
+
:ords => [ (0x400..0x40F) ],
|
128
|
+
:change => proc { | ord | ord += 0x50 },
|
129
|
+
}, {
|
130
|
+
:ords => [ (0x100..0x1B9), (0x1C4..0x233),
|
131
|
+
(0x450..0x481), (0x48A..0x523),
|
132
|
+
(0x1E00..0x1E95), (0x1EA0..0x1EFF),
|
133
|
+
(0x0A642..0xA667), (0x0A680..0x0A697),
|
134
|
+
(0xA722..0xA7A9) ],
|
135
|
+
:change => proc { | ord | ord.even? && ( ord + 1 ) || ord },
|
136
|
+
} ],
|
137
|
+
:default => proc do | ord |
|
138
|
+
[ ord ].pack( 'U' ).__rdoba_mixin_downcase_orig__ ; end } }
|
139
|
+
|
140
|
+
def self.change_case_char dest, char
|
141
|
+
ord = char.is_a?( String ) ? char.ord : char.to_i
|
142
|
+
table = ConvertTable[ dest ]
|
143
|
+
nord = table[ :ranges ].each do |range|
|
144
|
+
c = range[ :ords ].each do |r|
|
145
|
+
if r.include?( ord )
|
146
|
+
break false ; end ; end
|
147
|
+
if !c
|
148
|
+
break range[ :change ].call ord ; end ; end
|
149
|
+
|
150
|
+
if !nord.is_a? Numeric
|
151
|
+
return table[ :default ].call ord ; end
|
152
|
+
|
153
|
+
[ nord ].pack( 'U' ) ; end
|
154
|
+
|
155
|
+
def self.up_char char
|
156
|
+
CaseString.change_case_char :up, char ; end
|
157
|
+
|
158
|
+
def self.downcase_char char
|
159
|
+
CaseString.change_case_char :down, char ; end
|
160
|
+
|
161
|
+
if RUBY_VERSION < '1.9'
|
162
|
+
alias :setbyte :[]=
|
163
|
+
|
164
|
+
def encoding
|
165
|
+
'UTF-8'
|
166
|
+
end
|
167
|
+
|
168
|
+
def force_encoding(*args)
|
169
|
+
self
|
170
|
+
end
|
171
|
+
|
172
|
+
def ord
|
173
|
+
a = nil
|
174
|
+
self.each_byte do |b|
|
175
|
+
case ( b & 0xC0 )
|
176
|
+
when 0xc0
|
177
|
+
a = (b & 0x3F)
|
178
|
+
when 0x80
|
179
|
+
return (a << 6) + (b & 0x3F)
|
180
|
+
else
|
181
|
+
return b ; end ; end ; end ; end
|
182
|
+
|
183
|
+
def __rdoba_mixin_downcase__ options = {}
|
184
|
+
self.__rdoba_mixin_changecase__ :down, options ; end
|
185
|
+
|
186
|
+
def __rdoba_mixin_upcase__ options = {}
|
187
|
+
self.__rdoba_mixin_changecase__ :up, options ; end
|
188
|
+
|
189
|
+
def __rdoba_mixin_changecase__ reg, options = {}
|
190
|
+
if ![ :up, :down ].include? reg
|
191
|
+
return self ; end
|
192
|
+
|
193
|
+
re = Regexp.new '[\x80-\xFF]', nil, 'n'
|
194
|
+
if options == String::FirstChar || options.include?( :first_char )
|
195
|
+
r = self.dup
|
196
|
+
r[0] = CaseString.change_case_char reg, self.ord
|
197
|
+
r
|
198
|
+
elsif self.dup.force_encoding( 'ASCII-8BIT' ).match re
|
199
|
+
self.unpack('U*').map do | chr |
|
200
|
+
CaseString.change_case_char reg, chr
|
201
|
+
end.join
|
202
|
+
elsif reg == :up
|
203
|
+
self.__rdoba_mixin_upcase_orig__
|
204
|
+
else
|
205
|
+
self.__rdoba_mixin_downcase_orig__ ; end ; end ; end
|
206
|
+
|
6
207
|
module To_hArray
|
7
208
|
def to_h options = {}
|
8
209
|
h = {}
|
@@ -34,24 +235,87 @@ module Rdoba
|
|
34
235
|
|
35
236
|
h ; end ; end
|
36
237
|
|
238
|
+
module Split_byArray
|
239
|
+
#
|
240
|
+
# +split_by+ method splits the +self+ array by a condition,
|
241
|
+
# which is evaliated in a passed block, in two versions that are
|
242
|
+
# the return value. Usage:
|
243
|
+
#
|
244
|
+
# require 'rdoba'
|
245
|
+
#
|
246
|
+
# rdoba mixin: :split_by
|
247
|
+
#
|
248
|
+
# (first, second) = [0,1,2,3].split_by { |value| value % 2 == 0 }
|
249
|
+
# first # => [0,2]
|
250
|
+
# second # => [1,3]
|
251
|
+
#
|
252
|
+
def split_by &block
|
253
|
+
idxs = []
|
254
|
+
rejected = self.reject.with_index do |v, i|
|
255
|
+
yield( v ) && ( idxs << i ) ; end
|
256
|
+
[ self.values_at(*idxs), rejected ] ; end ; end
|
257
|
+
|
37
258
|
module EmptyObject
|
38
259
|
def empty?
|
39
260
|
false ; end ; end
|
40
261
|
|
41
262
|
module EmptyNilClass
|
42
263
|
def empty?
|
43
|
-
true ; end ; end ; end
|
264
|
+
true ; end ; end ; end ; end
|
44
265
|
|
266
|
+
if RUBY_VERSION >= "2.0.0"
|
267
|
+
require_relative 'mixin/try'
|
268
|
+
else
|
269
|
+
require_relative 'mixin/try_1_9_0' ; end
|
270
|
+
|
271
|
+
require_relative 'mixin/wait_if'
|
272
|
+
|
273
|
+
module Rdoba
|
45
274
|
def self.mixin options
|
46
|
-
|
275
|
+
[ options[ :value ] ].flatten.each do |value|
|
47
276
|
case value
|
277
|
+
when :case
|
278
|
+
Mixin::CaseString::Aliases.each do |k,v|
|
279
|
+
::String.send :alias_method, k, v ; end
|
280
|
+
Mixin::CaseString::Fixups.each do |e|
|
281
|
+
::String.class_eval "def #{e}(*args);self.__rdoba_mixin_#{e}__(*args);end"
|
282
|
+
end # trap NameError
|
283
|
+
::String.send :include, Mixin::CaseString
|
284
|
+
when :reverse
|
285
|
+
Mixin::ReverseString::Aliases.each do |k,v|
|
286
|
+
::String.send :alias_method, k, v ; end
|
287
|
+
Mixin::ReverseString::Fixups.each do |e|
|
288
|
+
::String.class_eval "def #{e}(*args);self.__rdoba_mixin_#{e}__(*args);end"
|
289
|
+
end # trap NameError
|
290
|
+
String.send :include, Mixin::ReverseString
|
291
|
+
when :compare
|
292
|
+
String.send :include, Mixin::CompareString
|
48
293
|
when :to_h
|
49
|
-
|
294
|
+
if [].respond_to?( :to_h )
|
295
|
+
m = Mixin::To_hArray.instance_method( :to_h )
|
296
|
+
Array.send( :define_method, :to_h, m )
|
297
|
+
else
|
298
|
+
Array.send( :include, Mixin::To_hArray ) ; end
|
299
|
+
when :time
|
300
|
+
require_relative 'mixin/time'
|
301
|
+
if File.respond_to?( :mtime )
|
302
|
+
[ :mtime, :atime, :ctime ].each do |name|
|
303
|
+
m = Mixin::Time.instance_method( name )
|
304
|
+
::File.send( :define_singleton_method, name, m ) ; end
|
305
|
+
else
|
306
|
+
::File.send( :extend, Mixin::Time ) ; end
|
307
|
+
when :wait_if
|
308
|
+
Object.send :include, Mixin::Wait_ifKernel
|
309
|
+
when :split_by
|
310
|
+
Array.send :include, Mixin::Split_byArray
|
311
|
+
when :try
|
312
|
+
Object.send :include, Mixin::TryObject
|
50
313
|
when :empty
|
51
|
-
Object.send :include,
|
52
|
-
NilClass.send :include,
|
314
|
+
Object.send :include, Mixin::EmptyObject
|
315
|
+
NilClass.send :include, Mixin::EmptyNilClass
|
53
316
|
else
|
54
|
-
|
317
|
+
raise( Mixin::InvalidOption, "Invalid rdoba-mixin options key: " +
|
318
|
+
"#{value.to_s}" )
|
55
319
|
end ; end ; end ; end
|
56
320
|
|
57
321
|
|
data/lib/rdoba/strings.rb
CHANGED
@@ -1,149 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby -KU
|
2
2
|
#coding:utf-8
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
def self.upcase(char)
|
7
|
-
chr = char.class == String ? char.ord : char.to_i
|
8
|
-
if chr >= 0x430 and chr < 0x450
|
9
|
-
chr -= 0x20
|
10
|
-
elsif chr >= 0x410 and chr < 0x430
|
11
|
-
elsif chr >= 0x400 and chr < 0x410 or
|
12
|
-
chr >= 0x450 and chr < 0x482 or
|
13
|
-
chr >= 0x48A and chr < 0x524 or
|
14
|
-
chr >= 0xA642 and chr < 0xA668 or
|
15
|
-
chr >= 0xA680 and chr < 0xA698
|
16
|
-
chr -= 1 if (chr % 1) == 1
|
17
|
-
else
|
18
|
-
return chr.chr.__upcase__
|
19
|
-
end
|
20
|
-
chr.chr
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.downcase(char)
|
24
|
-
chr = (char.class == String) ? char.ord : char.to_i
|
25
|
-
if chr >= 0x410 and chr < 0x430
|
26
|
-
chr += 0x20
|
27
|
-
elsif chr >= 0x430 and chr < 0x450
|
28
|
-
elsif chr >= 0x400 and chr < 0x410 or
|
29
|
-
chr >= 0x450 and chr < 0x482 or
|
30
|
-
chr >= 0x48A and chr < 0x524 or
|
31
|
-
chr >= 0xA642 and chr < 0xA668 or
|
32
|
-
chr >= 0xA680 and chr < 0xA698
|
33
|
-
chr += 1 if (chr % 1) == 0
|
34
|
-
else
|
35
|
-
return chr.chr.__downcase__
|
36
|
-
end
|
37
|
-
chr.chr
|
38
|
-
end
|
39
|
-
|
40
|
-
if RUBY_VERSION < '1.9'
|
41
|
-
|
42
|
-
alias :setbyte :[]=
|
43
|
-
|
44
|
-
def encoding
|
45
|
-
'UTF-8'
|
46
|
-
end
|
47
|
-
|
48
|
-
def force_encoding(*args)
|
49
|
-
self
|
50
|
-
end
|
51
|
-
|
52
|
-
def ord
|
53
|
-
a = nil
|
54
|
-
self.each_byte do |b|
|
55
|
-
c = b & 0xC0
|
56
|
-
case c
|
57
|
-
when 0xc0
|
58
|
-
a = (b & 0x3F)
|
59
|
-
when 0x80
|
60
|
-
return (a << 6) + (b & 0x3F)
|
61
|
-
else
|
62
|
-
return b
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
FirstChar = 0
|
70
|
-
alias :__upcase__ :upcase
|
71
|
-
def upcase(option = nil)
|
72
|
-
if option == FirstChar
|
73
|
-
r = self.dup
|
74
|
-
r[0] = String.upcase(self.ord)
|
75
|
-
r
|
76
|
-
elsif self.match(/[Ѐ-ҁҊ-ԣꙀ-ꙧꚀꚗ]/u)
|
77
|
-
self.unpack('U*').map do |chr| String.upcase(chr) end.join
|
78
|
-
else; __upcase__ end
|
79
|
-
end
|
80
|
-
|
81
|
-
alias :__downcase__ :downcase
|
82
|
-
def downcase(option = nil)
|
83
|
-
if option == FirstChar
|
84
|
-
r = self.dup
|
85
|
-
r[0] = String.downcase(self.ord)
|
86
|
-
r
|
87
|
-
elsif self.match(/[Ѐ-ҁҊ-ԣꙀ-ꙧꚀꚗ]/u)
|
88
|
-
self.unpack('U*').map do |chr| String.downcase(chr) end.join
|
89
|
-
else; __downcase__ end
|
90
|
-
end
|
4
|
+
STDERR.puts "Warning: the module 'string' has kept only for backward " \
|
5
|
+
"compatibility\nPlease use 'rdoba :mixin' form instead"
|
91
6
|
|
7
|
+
class String
|
92
8
|
alias :to_p :to_s
|
93
|
-
|
94
|
-
ByteByByte = 0
|
95
|
-
alias :__reverse__ :reverse
|
96
|
-
def reverse(step = 1)
|
97
|
-
case step
|
98
|
-
when ByteByByte
|
99
|
-
arr = []
|
100
|
-
self.each_byte do |byte| arr << byte.chr end
|
101
|
-
arr.reverse.join
|
102
|
-
when 1
|
103
|
-
__reverse__
|
104
|
-
else
|
105
|
-
res = ''
|
106
|
-
offset = (self.size + 1) / step * step - step
|
107
|
-
(0..offset).step(step) do |shift|
|
108
|
-
res += self[offset - shift..offset - shift + 1]
|
109
|
-
end
|
110
|
-
res
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def compare_to(value, opts = {} )
|
115
|
-
if opts == :ignore_diacritics or
|
116
|
-
(opts.class == Hash and opts.key? :ignore_diacritics)
|
117
|
-
# TODO verify composite range
|
118
|
-
def crop_diacritics(x)
|
119
|
-
(x < 0x300 or
|
120
|
-
x > 0x36f and x < 0x483 or
|
121
|
-
x > 0x487 and x < 0xa67c or
|
122
|
-
x > 0xa67d) && x || nil
|
123
|
-
end
|
124
|
-
|
125
|
-
(self.unpack('U*').map do |x| crop_diacritics(x)
|
126
|
-
end.compact) <=> (value.unpack('U*').map do |x| crop_diacritics(x)
|
127
|
-
end.compact)
|
128
|
-
else
|
129
|
-
self <=> value
|
130
|
-
end
|
131
|
-
end
|
132
9
|
end
|
133
10
|
|
134
|
-
|
135
|
-
alias :__chr__ :chr
|
136
|
-
def chr
|
137
|
-
if self >= 256
|
138
|
-
num = self; s = "\0"; byte = 0x80; a = []
|
139
|
-
while num >= 0x40
|
140
|
-
s.setbyte(0, byte + (num & 0x3F))
|
141
|
-
a << s.dup; num >>= 6; byte = 0x40
|
142
|
-
end
|
143
|
-
s.setbyte(0, 0xC0 + (num & 0x3F))
|
144
|
-
a << s
|
145
|
-
a.reverse.join.force_encoding('UTF-8')
|
146
|
-
else; __chr__ end
|
147
|
-
end
|
148
|
-
end
|
11
|
+
rdoba :mixin => [ :case, :reverse, :compare ]
|
149
12
|
|
data/lib/rdoba.rb
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
#encoding: utf-8
|
2
2
|
|
3
3
|
module Kernel
|
4
|
-
|
4
|
+
Modules = [ :bcd, :mixin, :log, :debug ]
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# TODO and resolve some troubles with eval in main
|
19
|
-
else
|
20
|
-
Kernel.puts STDERR, "Unknown rdoba module named as '#{key.to_s}'"
|
21
|
-
nil; end ||
|
22
|
-
if Modules.include? key
|
23
|
-
require "rdoba/#{key}"; end; end; end; end
|
6
|
+
def rdoba *options
|
7
|
+
options.each do |option|
|
8
|
+
( option.is_a?( Hash ) &&
|
9
|
+
option || { option.to_s.to_sym => {} }
|
10
|
+
).each_pair do |key, value|
|
11
|
+
if Modules.include? key
|
12
|
+
require "rdoba/#{key}"
|
13
|
+
if Rdoba.methods.include? key
|
14
|
+
if !value.is_a? Hash
|
15
|
+
value = { :value => value } ; end
|
16
|
+
value.replace( { :self => self }.merge value )
|
17
|
+
Rdoba.send key, value ; end ; end ; end; end ; end ; end
|
24
18
|
|
25
19
|
require 'rbconfig'
|
26
20
|
|
data/rdoba.gemspec
CHANGED
@@ -3,30 +3,36 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "rdoba/_version_"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
s.name = "rdoba"
|
7
|
+
s.version = Rdoba::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = [ 'Малъ Скрылёвъ (Malo Skrylevo)' ]
|
10
|
+
s.email = [ '3aHyga@gmail.com' ]
|
11
|
+
s.homepage = 'https://github.com/3aHyga/rdoba'
|
12
|
+
s.summary = 'Ruby extension library (Ruby DOBAvka)'
|
13
|
+
s.description = 'Ruby extension library. It extends Kernel, Object, ' \
|
14
|
+
'String, Hash, Array, and some other classes. Also allows ' \
|
15
|
+
'to log application state with debug lines to an io'
|
16
|
+
s.license = 'MIT'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
s.rubyforge_project = "rdoba"
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split( "\n" ).map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = [ "lib" ]
|
23
|
+
s.extra_rdoc_files = [ 'README.md', 'LICENSE', 'CHANGES.md' ] |
|
24
|
+
`find html/`.split( "\n" )
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
s.add_development_dependency 'simplecov', '~> 0'
|
27
|
+
s.add_development_dependency 'tddium', '~> 0'
|
28
|
+
s.add_development_dependency 'rake', '~> 0'
|
29
|
+
s.add_development_dependency 'bundler', '~> 1.5'
|
30
|
+
s.add_development_dependency 'cucumber', '~> 1.3'
|
31
|
+
s.add_development_dependency 'coveralls', '~> 0'
|
32
|
+
s.add_development_dependency 'rdiscount', '~> 2.1'
|
33
|
+
s.add_development_dependency 'rdoc', '~> 4.2'
|
34
|
+
s.add_development_dependency 'rspec-expectations', '~> 3.3'
|
35
|
+
s.add_development_dependency 'ffi-stat', '~> 0.4'
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
s.add_development_dependency 'cucumber', '~> 1.3'
|
31
|
-
s.add_development_dependency 'coveralls'
|
32
|
-
end
|
37
|
+
s.required_rubygems_version = '>= 1.6.0'
|
38
|
+
s.required_ruby_version = '>= 1.9.0' ; end
|