qfunction 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -2
- data/Rakefile +6 -2
- data/lib/function/HTMLElement.rb +1 -3
- data/lib/function/assertions.rb +198 -83
- data/lib/function/sfunction.rb +148 -148
- metadata +20 -6
data/README
CHANGED
data/Rakefile
CHANGED
@@ -12,16 +12,20 @@ require 'rake/testtask'
|
|
12
12
|
|
13
13
|
spec = Gem::Specification.new do |s|
|
14
14
|
s.name = 'qfunction'
|
15
|
-
s.version = '0.1.
|
15
|
+
s.version = '0.1.2'
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.extra_rdoc_files = ['README', 'LICENSE']
|
18
18
|
s.summary = 'Nice Function'
|
19
19
|
s.description = s.summary
|
20
20
|
s.author = 'QuangMV, Cyworld VietNam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Ha Noi, VietNam'
|
21
|
-
s.email = '
|
21
|
+
s.email = 'mr.quangmv@gmail.com'
|
22
22
|
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
23
23
|
s.require_path = "lib"
|
24
24
|
s.bindir = "bin"
|
25
|
+
# s.add_dependency('watir','>=1.6.5')
|
26
|
+
s.add_dependency('ocra','>=1.2.0')
|
27
|
+
# s.add_dependency('tslmail','>=0.0.1')
|
28
|
+
# s.add_dependency('gmail_sender','>=1.1.1')
|
25
29
|
end
|
26
30
|
|
27
31
|
Rake::GemPackageTask.new(spec) do |p|
|
data/lib/function/HTMLElement.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#B: HTML
|
2
|
-
module Qh
|
2
|
+
module Qh
|
3
3
|
include Test::Unit::Assertions
|
4
4
|
#Goto url
|
5
5
|
def goto(url)
|
@@ -88,7 +88,6 @@ include Test::Unit::Assertions
|
|
88
88
|
#type = 2:value,<br>
|
89
89
|
#type = 3:append<br>
|
90
90
|
def setTextfieldname(text1,text2,type=1)
|
91
|
-
|
92
91
|
waitExists($ff.text_field(:name,text1))
|
93
92
|
if type == 1 then
|
94
93
|
$ff.text_field(:name,text1).set(text2)
|
@@ -105,7 +104,6 @@ include Test::Unit::Assertions
|
|
105
104
|
#type = 2:value,<br>
|
106
105
|
#type = 3:append<br>
|
107
106
|
def setTextfieldclass(text1,text2,type=1)
|
108
|
-
|
109
107
|
waitExists($ff.text_field(:class,text1))
|
110
108
|
if type == 1 then
|
111
109
|
$ff.text_field(:class,text1).set(text2)
|
data/lib/function/assertions.rb
CHANGED
@@ -8,7 +8,6 @@ module Qa
|
|
8
8
|
sleep(1)
|
9
9
|
if i>=waittime then
|
10
10
|
assert($ff.contains_text(text))
|
11
|
-
# break;
|
12
11
|
end
|
13
12
|
i=i+1
|
14
13
|
end
|
@@ -21,7 +20,6 @@ module Qa
|
|
21
20
|
sleep(1)
|
22
21
|
if i>=$timeout then
|
23
22
|
assert_false($ff.contains_text(text))
|
24
|
-
break;
|
25
23
|
end
|
26
24
|
i=i+1
|
27
25
|
end
|
@@ -35,7 +33,8 @@ module Qa
|
|
35
33
|
#type = 5:maxlength<br>
|
36
34
|
def assertEqual(value1,value2,type=1) #0.0.8
|
37
35
|
i = 0
|
38
|
-
|
36
|
+
case type
|
37
|
+
when 1 then
|
39
38
|
begin
|
40
39
|
assert_equal(value1, value2.text)
|
41
40
|
rescue Exception => e
|
@@ -45,7 +44,7 @@ module Qa
|
|
45
44
|
end
|
46
45
|
assert_equal(value1, value2.text)
|
47
46
|
end
|
48
|
-
|
47
|
+
when 2 then
|
49
48
|
begin
|
50
49
|
assert_equal(value1, value2.title)
|
51
50
|
rescue
|
@@ -55,7 +54,7 @@ module Qa
|
|
55
54
|
end
|
56
55
|
assert_equal(value1, value2.title)
|
57
56
|
end
|
58
|
-
|
57
|
+
when 3 then
|
59
58
|
begin
|
60
59
|
assert_equal(value1, value2.url)
|
61
60
|
rescue
|
@@ -65,7 +64,7 @@ module Qa
|
|
65
64
|
end
|
66
65
|
assert_equal(value1, value2.url)
|
67
66
|
end
|
68
|
-
|
67
|
+
when 4 then
|
69
68
|
begin
|
70
69
|
assert_equal(value1, value2.value)
|
71
70
|
rescue
|
@@ -75,7 +74,7 @@ module Qa
|
|
75
74
|
end
|
76
75
|
assert_equal(value1, value2.value)
|
77
76
|
end
|
78
|
-
|
77
|
+
when 5 then
|
79
78
|
begin
|
80
79
|
assert_equal(value1, value2.maxlength)
|
81
80
|
rescue
|
@@ -87,9 +86,10 @@ module Qa
|
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
90
|
-
def assertSpan_Equal(spantype,valuetype
|
89
|
+
def assertSpan_Equal(value1,spantype,value2,valuetype="text")
|
91
90
|
i = 0
|
92
|
-
|
91
|
+
case valuetype
|
92
|
+
when "text" then
|
93
93
|
begin
|
94
94
|
assert_equal(value1, $ff.span(:"#{spantype}",value2).text)
|
95
95
|
rescue
|
@@ -99,22 +99,74 @@ module Qa
|
|
99
99
|
end
|
100
100
|
assert_equal(value1, $ff.span(:"#{spantype}",value2).text)
|
101
101
|
end
|
102
|
+
when "id" then
|
103
|
+
begin
|
104
|
+
assert_equal(value1, $ff.span(:"#{spantype}",value2).id)
|
105
|
+
rescue
|
106
|
+
sleep(1)
|
107
|
+
i += 1
|
108
|
+
if i <= $timeout+1 then retry
|
109
|
+
end
|
110
|
+
assert_equal(value1, $ff.span(:"#{spantype}",value2).id)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
def assertDiv_Equal(value1,divtype,value2,valuetype="text")
|
115
|
+
i = 0
|
116
|
+
case valuetype
|
117
|
+
when "text" then
|
118
|
+
begin
|
119
|
+
assert_equal(value1, $ff.div(:"#{divtype}",value2).text)
|
120
|
+
rescue
|
121
|
+
sleep(1)
|
122
|
+
i += 1
|
123
|
+
if i <= $timeout+1 then retry
|
124
|
+
end
|
125
|
+
assert_equal(value1, $ff.div(:"#{divtype}",value2).text)
|
126
|
+
end
|
127
|
+
when "id" then
|
128
|
+
begin
|
129
|
+
assert_equal(value1, $ff.div(:"#{divtype}",value2).id)
|
130
|
+
rescue
|
131
|
+
sleep(1)
|
132
|
+
i += 1
|
133
|
+
if i <= $timeout+1 then retry
|
134
|
+
end
|
135
|
+
assert_equal(value1, $ff.div(:"#{divtype}",value2).id)
|
136
|
+
end
|
102
137
|
end
|
103
138
|
end
|
104
139
|
|
105
|
-
def
|
140
|
+
def assertLink_Equal(value1,linktype,value2,valuetype="text")
|
106
141
|
i = 0
|
107
|
-
|
142
|
+
case valuetype
|
143
|
+
when "text" then
|
144
|
+
begin
|
145
|
+
assert_equal(value1, $ff.link(:"#{linktype}",value2).text)
|
146
|
+
rescue
|
147
|
+
sleep(1)
|
148
|
+
i += 1
|
149
|
+
if i <= $timeout+1 then retry
|
150
|
+
end
|
151
|
+
assert_equal(value1, $ff.link(:"#{linktype}",value2).text)
|
152
|
+
end
|
153
|
+
when "id" then
|
108
154
|
begin
|
109
|
-
assert_equal(value1, $ff.
|
155
|
+
assert_equal(value1, $ff.link(:"#{linktype}",value2).id)
|
110
156
|
rescue
|
111
157
|
sleep(1)
|
112
158
|
i += 1
|
113
159
|
if i <= $timeout+1 then retry
|
114
160
|
end
|
115
|
-
assert_equal(value1, $ff.
|
161
|
+
assert_equal(value1, $ff.link(:"#{linktype}",value2).id)
|
116
162
|
end
|
117
|
-
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def assertImage_Equal(value1,imagetype,value2,valuetype="src")
|
167
|
+
i = 0
|
168
|
+
case valuetype
|
169
|
+
when "src" then
|
118
170
|
begin
|
119
171
|
assert_equal(value1, $ff.image(:"#{imagetype}",value2).src)
|
120
172
|
rescue
|
@@ -124,7 +176,7 @@ module Qa
|
|
124
176
|
end
|
125
177
|
assert_equal(value1, $ff.image(:"#{imagetype}",value2).src)
|
126
178
|
end
|
127
|
-
|
179
|
+
when "href" then
|
128
180
|
begin
|
129
181
|
assert_equal(value1, $ff.image(:"#{imagetype}",value2).href)
|
130
182
|
rescue
|
@@ -134,10 +186,68 @@ module Qa
|
|
134
186
|
end
|
135
187
|
assert_equal(value1, $ff.image(:"#{imagetype}",value2).href)
|
136
188
|
end
|
189
|
+
when "id" then
|
190
|
+
begin
|
191
|
+
assert_equal(value1, $ff.image(:"#{imagetype}",value2).id)
|
192
|
+
rescue
|
193
|
+
sleep(1)
|
194
|
+
i += 1
|
195
|
+
if i <= $timeout+1 then retry
|
196
|
+
end
|
197
|
+
assert_equal(value1, $ff.image(:"#{imagetype}",value2).id)
|
198
|
+
end
|
137
199
|
end
|
138
200
|
end
|
139
|
-
|
140
|
-
|
201
|
+
|
202
|
+
def assertTextfield_Equal(value1,textfieldtype,value2,valuetype="value")
|
203
|
+
i = 0
|
204
|
+
case valuetype
|
205
|
+
when "value" then
|
206
|
+
begin
|
207
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).value)
|
208
|
+
rescue
|
209
|
+
sleep(1)
|
210
|
+
i += 1
|
211
|
+
if i <= $timeout+1 then retry
|
212
|
+
end
|
213
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).value)
|
214
|
+
end
|
215
|
+
when "id" then
|
216
|
+
begin
|
217
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).id)
|
218
|
+
rescue
|
219
|
+
sleep(1)
|
220
|
+
i += 1
|
221
|
+
if i <= $timeout+1 then retry
|
222
|
+
end
|
223
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).id)
|
224
|
+
end
|
225
|
+
when "name" then
|
226
|
+
begin
|
227
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).name)
|
228
|
+
rescue
|
229
|
+
sleep(1)
|
230
|
+
i += 1
|
231
|
+
if i <= $timeout+1 then retry
|
232
|
+
end
|
233
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).name)
|
234
|
+
end
|
235
|
+
when "maxlength" then
|
236
|
+
begin
|
237
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).maxlength)
|
238
|
+
rescue
|
239
|
+
sleep(1)
|
240
|
+
i += 1
|
241
|
+
if i <= $timeout+1 then retry
|
242
|
+
end
|
243
|
+
assert_equal(value1, $ff.text_field(:"#{textfieldtype}",value2).maxlength)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
def assertBrowser_Equal(value,valuetype="title")
|
248
|
+
i = 0
|
249
|
+
case valuetype
|
250
|
+
when "title" then
|
141
251
|
begin
|
142
252
|
assert_equal(value, $ff.title)
|
143
253
|
rescue
|
@@ -147,6 +257,26 @@ module Qa
|
|
147
257
|
end
|
148
258
|
assert_equal(value, $ff.title)
|
149
259
|
end
|
260
|
+
when "url" then
|
261
|
+
begin
|
262
|
+
assert_equal(value, $ff.url)
|
263
|
+
rescue
|
264
|
+
sleep(1)
|
265
|
+
i += 1
|
266
|
+
if i <= $timeout+1 then retry
|
267
|
+
end
|
268
|
+
assert_equal(value, $ff.url)
|
269
|
+
end
|
270
|
+
when "status" then
|
271
|
+
begin
|
272
|
+
assert_equal(value, $ff.status)
|
273
|
+
rescue
|
274
|
+
sleep(1)
|
275
|
+
i += 1
|
276
|
+
if i <= $timeout+1 then retry
|
277
|
+
end
|
278
|
+
assert_equal(value, $ff.status)
|
279
|
+
end
|
150
280
|
end
|
151
281
|
end
|
152
282
|
|
@@ -159,7 +289,8 @@ module Qa
|
|
159
289
|
#type = 4:value<br>
|
160
290
|
def assertfalseEqual(value1,value2,type=1)
|
161
291
|
i = 0
|
162
|
-
|
292
|
+
case type
|
293
|
+
when 1 then
|
163
294
|
while value2.text == value1 do
|
164
295
|
sleep(1)
|
165
296
|
if i >= $timeout then
|
@@ -168,7 +299,7 @@ module Qa
|
|
168
299
|
end
|
169
300
|
i += 1
|
170
301
|
end
|
171
|
-
|
302
|
+
when 2 then
|
172
303
|
while value2.title == value1 do
|
173
304
|
sleep(1)
|
174
305
|
if i >= $timeout then
|
@@ -177,7 +308,7 @@ module Qa
|
|
177
308
|
end
|
178
309
|
i += 1
|
179
310
|
end
|
180
|
-
|
311
|
+
when 3 then
|
181
312
|
while value2.url == value1 do
|
182
313
|
sleep(1)
|
183
314
|
if i >= $timeout then
|
@@ -186,7 +317,7 @@ module Qa
|
|
186
317
|
end
|
187
318
|
i += 1
|
188
319
|
end
|
189
|
-
|
320
|
+
when 4 then
|
190
321
|
while value2.value == value1 do
|
191
322
|
sleep(1)
|
192
323
|
if i >= $timeout then
|
@@ -196,7 +327,6 @@ module Qa
|
|
196
327
|
i += 1
|
197
328
|
end
|
198
329
|
end
|
199
|
-
|
200
330
|
end
|
201
331
|
|
202
332
|
#Wait Element show
|
@@ -224,121 +354,103 @@ module Qa
|
|
224
354
|
end
|
225
355
|
end
|
226
356
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
assert( $ff.link(:"#{arg}",item).exists? )
|
236
|
-
break;
|
237
|
-
end
|
357
|
+
#Wait Element none
|
358
|
+
def waitfalseExists(text)
|
359
|
+
i = 0
|
360
|
+
while text.exists? do
|
361
|
+
sleep(1)
|
362
|
+
if i>=$timeout then
|
363
|
+
assert(text.exists?)
|
364
|
+
break;
|
238
365
|
end
|
366
|
+
i +=1
|
239
367
|
end
|
240
368
|
end
|
241
|
-
|
369
|
+
|
370
|
+
def noLinks(arg,text)
|
242
371
|
text.each do |item|
|
243
372
|
i = 0
|
244
|
-
while
|
373
|
+
while $ff.link(:"#{arg}",item).exists? do
|
245
374
|
sleep(1)
|
246
375
|
i +=1
|
247
376
|
if i>=$timeout then
|
248
|
-
assert(
|
249
|
-
break;
|
377
|
+
assert( !$ff.link(:"#{arg}",item).exists? )
|
250
378
|
end
|
251
379
|
end
|
252
380
|
end
|
253
381
|
end
|
254
|
-
|
382
|
+
|
383
|
+
def noButtons(arg,text)
|
255
384
|
text.each do |item|
|
256
385
|
i = 0
|
257
|
-
while
|
386
|
+
while $ff.button(:"#{arg}",item).exists? do
|
258
387
|
sleep(1)
|
259
388
|
i +=1
|
260
389
|
if i>=$timeout then
|
261
|
-
assert(
|
262
|
-
break;
|
390
|
+
assert( !$ff.button(:"#{arg}",item).exists? )
|
263
391
|
end
|
264
392
|
end
|
265
393
|
end
|
266
394
|
end
|
267
395
|
|
268
|
-
def
|
396
|
+
def noSpans(arg,text)
|
269
397
|
text.each do |item|
|
270
398
|
i = 0
|
271
|
-
while
|
399
|
+
while $ff.span(:"#{arg}",item).exists? do
|
272
400
|
sleep(1)
|
273
401
|
i +=1
|
274
402
|
if i>=$timeout then
|
275
|
-
assert(
|
276
|
-
break;
|
403
|
+
assert( !$ff.span(:"#{arg}",item).exists? )
|
277
404
|
end
|
278
405
|
end
|
279
406
|
end
|
280
407
|
end
|
281
|
-
|
282
|
-
#Wait Element none
|
283
|
-
def waitfalseExists(text)
|
284
|
-
i = 0
|
285
|
-
while text.exists? do
|
286
|
-
sleep(1)
|
287
|
-
if i>=$timeout then
|
288
|
-
assert(text.exists?)
|
289
|
-
break;
|
290
|
-
end
|
291
|
-
i +=1
|
292
|
-
end
|
293
|
-
end
|
294
408
|
|
295
|
-
def
|
409
|
+
def noImages(arg,text)
|
296
410
|
text.each do |item|
|
297
411
|
i = 0
|
298
|
-
while $ff.
|
412
|
+
while $ff.image(:"#{arg}",item).exists? do
|
299
413
|
sleep(1)
|
300
414
|
i +=1
|
301
415
|
if i>=$timeout then
|
302
|
-
assert( !$ff.
|
416
|
+
assert( !$ff.image(:"#{arg}",item).exists? )
|
303
417
|
end
|
304
418
|
end
|
305
419
|
end
|
306
420
|
end
|
307
421
|
|
308
|
-
def
|
422
|
+
def noTables(arg,text)
|
309
423
|
text.each do |item|
|
310
424
|
i = 0
|
311
|
-
while $ff.
|
425
|
+
while $ff.table(:"#{arg}",item).exists? do
|
312
426
|
sleep(1)
|
313
427
|
i +=1
|
314
428
|
if i>=$timeout then
|
315
|
-
assert( !$ff.
|
429
|
+
assert( !$ff.table(:"#{arg}",item).exists? )
|
316
430
|
end
|
317
431
|
end
|
318
432
|
end
|
319
433
|
end
|
320
|
-
|
321
|
-
def noSpans(arg,text)
|
434
|
+
def noDivs(arg,text)
|
322
435
|
text.each do |item|
|
323
436
|
i = 0
|
324
|
-
while $ff.
|
437
|
+
while $ff.div(:"#{arg}",item).exists? do
|
325
438
|
sleep(1)
|
326
439
|
i +=1
|
327
440
|
if i>=$timeout then
|
328
|
-
assert( !$ff.
|
441
|
+
assert( !$ff.div(:"#{arg}",item).exists? )
|
329
442
|
end
|
330
443
|
end
|
331
444
|
end
|
332
445
|
end
|
333
|
-
|
334
|
-
def noImages(arg,text)
|
446
|
+
def noTextfields(arg,text)
|
335
447
|
text.each do |item|
|
336
448
|
i = 0
|
337
|
-
while $ff.
|
449
|
+
while $ff.text_field(:"#{arg}",item).exists? do
|
338
450
|
sleep(1)
|
339
451
|
i +=1
|
340
452
|
if i>=$timeout then
|
341
|
-
assert( !$ff.
|
453
|
+
assert( !$ff.text_field(:"#{arg}",item).exists? )
|
342
454
|
end
|
343
455
|
end
|
344
456
|
end
|
@@ -350,8 +462,9 @@ module Qa
|
|
350
462
|
#tags = 4: Textfield<br>
|
351
463
|
#tags = 5: Div<br>
|
352
464
|
def falseExistsid(text,tags=1)
|
353
|
-
|
354
|
-
|
465
|
+
i = 0
|
466
|
+
case tags
|
467
|
+
when 1 then
|
355
468
|
while $ff.link(:id,text).exists? do
|
356
469
|
sleep(1)
|
357
470
|
i +=1
|
@@ -359,9 +472,7 @@ module Qa
|
|
359
472
|
assert(!$ff.link(:id,text).exists?)
|
360
473
|
end
|
361
474
|
end
|
362
|
-
|
363
|
-
elsif tags == 2 then
|
364
|
-
i = 0
|
475
|
+
when 2 then
|
365
476
|
while $ff.button(:id,text).exists? do
|
366
477
|
sleep(1)
|
367
478
|
i +=1
|
@@ -369,8 +480,7 @@ module Qa
|
|
369
480
|
assert(!$ff.button(:id,text).exists?)
|
370
481
|
end
|
371
482
|
end
|
372
|
-
|
373
|
-
i = 0
|
483
|
+
when 3 then
|
374
484
|
while $ff.table(:id,text).exists? do
|
375
485
|
sleep(1)
|
376
486
|
i +=1
|
@@ -378,8 +488,7 @@ module Qa
|
|
378
488
|
assert(!$ff.table(:id,text).exists?)
|
379
489
|
end
|
380
490
|
end
|
381
|
-
|
382
|
-
i = 0
|
491
|
+
when 4 then
|
383
492
|
while $ff.text_field(:id,text).exists? do
|
384
493
|
sleep(1)
|
385
494
|
i +=1
|
@@ -387,10 +496,16 @@ module Qa
|
|
387
496
|
assert(!$ff.text_field(:id,text).exists?)
|
388
497
|
end
|
389
498
|
end
|
499
|
+
when 5 then
|
500
|
+
while $ff.div(:id,text).exists? do
|
501
|
+
sleep(1)
|
502
|
+
i +=1
|
503
|
+
if i>=10 then
|
504
|
+
assert(!$ff.div(:id,text).exists?)
|
505
|
+
end
|
506
|
+
end
|
390
507
|
end
|
391
|
-
|
392
508
|
end
|
393
|
-
|
394
509
|
#tags = 1: Link(d)
|
395
510
|
def falseExiststext(text,tags=1)
|
396
511
|
if tags == 1 then
|
data/lib/function/sfunction.rb
CHANGED
@@ -1,150 +1,150 @@
|
|
1
1
|
module Qs
|
2
|
-
include Test::Unit::Assertions
|
3
|
-
def decoder(n)
|
4
|
-
str = [" ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";",
|
5
|
-
"<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
6
|
-
"[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
7
|
-
"y","z","{","|","}","~" ]
|
8
|
-
for i in 32..126
|
9
|
-
if n == i then return "#{str[i-32]}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
#i=1: 0-9,a-z,A-Z<br>
|
15
|
-
#i=2: -_ <br>
|
16
|
-
#i=3: a-z,A-Z<br>
|
17
|
-
#i=4: 0-9<br>
|
18
|
-
#i=41: 0-9 <br>
|
19
|
-
#i=5: @domain<br>
|
20
|
-
#i=10: Ho va Ten<br>
|
21
|
-
def getRandomString(n,i)
|
22
|
-
str = ""
|
23
|
-
|
24
|
-
str1 = ["0","1","2","3","4","5","6","7","8","9",
|
25
|
-
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
26
|
-
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
27
|
-
"y","z"]
|
28
|
-
|
29
|
-
str2 = ["-","","_",""]
|
30
|
-
|
31
|
-
str3 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
|
32
|
-
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
33
|
-
|
34
|
-
str4 = ["0","1","2","3","4","5","6","7","8","9"]
|
35
|
-
str41 = ["0","1","2","3","4","5","6","7","8","9","","","","","","","","","",""]
|
36
|
-
|
37
|
-
str5 = ["@yahoo.com.vn","@gmail.com","@yahoo.com","@msn.com","@hotmail.com","@zing.vn","@google.com.vn","@dantri.com",
|
38
|
-
"@vnexpress.net","@mail.com","@abc.com","@live.com"]
|
39
|
-
|
40
|
-
strHo = ["Nguyen","Dinh","Dang","Huynh","Mai","Tran","Le","Hoang","Pham","Phan","Vu","Bui","Do","Ho","Ngo",
|
41
|
-
"Duong","Ly","Vuong","Trinh","Truong","Dinh","Doan","Lam","Phung"]
|
42
|
-
|
43
|
-
strTenDem = ["Thi","Hong","Van","","Duc","Thuy","Ngoc","Ly","Bac","Hien"]
|
44
|
-
|
45
|
-
strTen = ["Trai","Xi","Truc","Tu","Bat","Thanh","Luong","Khuong","Quyen","Quang",
|
46
|
-
"Hoang","Ky","Thai","Chinh","Trinh","Kien","Hao","Hung","Quynh","Phuong","Hoa","Hop","Dung","Thang","Van","Tu","Ninh","Vinh","Loc","Khanh","Thuy","Ha",
|
47
|
-
"Hang","Lam","Hai","Vu","Na","Duyen","Minh","Tuan","Hien","Anh","An","Be","Binh","Canh"]
|
48
|
-
|
49
|
-
|
50
|
-
for i in 1..n
|
51
|
-
str = "#{str}#{str1[rand(str1.length)]}"
|
52
|
-
end
|
53
|
-
return str
|
54
|
-
|
55
|
-
for i in 1..n
|
56
|
-
str = "#{str}#{str2[rand(str2.length)]}"
|
57
|
-
end
|
58
|
-
return str
|
59
|
-
|
60
|
-
for i in 1..n
|
61
|
-
str = "#{str}#{str3[rand(str3.length)]}"
|
62
|
-
end
|
63
|
-
return str
|
64
|
-
|
65
|
-
for i in 1..n
|
66
|
-
str = "#{str}#{str4[rand(10)]}"
|
67
|
-
end
|
68
|
-
return str
|
69
|
-
|
70
|
-
for i in 1..n
|
71
|
-
str = "#{str}#{str41[rand(str41.length)]}"
|
72
|
-
end
|
73
|
-
return str
|
74
|
-
|
75
|
-
for i in 1..n
|
76
|
-
str = "#{str}#{str5[rand(str5.length)]}"
|
77
|
-
end
|
78
|
-
return str
|
79
|
-
|
80
|
-
str = "#{strHo[rand(strHo.length)]} #{strTenDem[rand(strTenDem.length)]} #{strTen[rand(strTen.length)]}"
|
81
|
-
return str
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def randfromto(a,b)
|
86
|
-
x = rand(b)
|
87
|
-
while x < a do
|
88
|
-
x = rand(b)
|
89
|
-
end
|
90
|
-
return x
|
91
|
-
end
|
92
|
-
|
93
|
-
def cutEndline(text) #0.0.8
|
94
|
-
if RUBY_VERSION <= '1.8.6' then
|
95
|
-
if text[text.length - 1] < 32 then
|
96
|
-
return text[0,text.length - 1]
|
97
|
-
else return text[0,text.length]
|
98
|
-
end
|
99
|
-
else
|
100
|
-
if text[text.length - 1] < ' ' then
|
101
|
-
return text[0,text.length - 1]
|
102
|
-
else return text[0,text.length]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def readExcel(dir,sheet=1)
|
108
|
-
$excel = WIN32OLE.new("excel.application")
|
109
|
-
$excel.visible = true
|
110
|
-
$workbook = $excel.workbooks.open(dir)
|
111
|
-
$ws=$workbook.worksheets(sheet)
|
112
|
-
$workbook = $excel.ActiveWorkbook
|
113
|
-
end
|
114
|
-
|
115
|
-
def saveExcel
|
116
|
-
$workbook.Save
|
117
|
-
$workbook.Close
|
118
|
-
$excel.Quit
|
119
|
-
end
|
120
|
-
|
121
|
-
def getFile(name)
|
122
|
-
if File.exist?(name) then return true
|
123
|
-
else return false
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def getPathExe(default_dir)
|
128
|
-
if ENV['OCRA_EXECUTABLE'].nil?
|
129
|
-
root_dir = File.dirname(default_dir).gsub('/', '\\') #0.0.7
|
130
|
-
else
|
131
|
-
root_dir = File.expand_path(File.dirname(ENV['OCRA_EXECUTABLE'])).gsub('/', '\\')
|
132
|
-
end
|
133
|
-
return root_dir + "\\"
|
134
|
-
end
|
135
|
-
|
136
|
-
def getDir(file,type = 1)
|
137
|
-
if type == 1 then
|
138
|
-
return File.dirname(file).gsub('/', '\\') + "\\"
|
139
|
-
else return File.dirname(file).gsub('/', '\\')
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def send_Mail_on_Gmail(nickname,pass,to,subject,content)
|
144
|
-
g = GmailSender.new(nickname, pass)
|
145
|
-
g.send(:to => to,
|
146
|
-
:subject => subject,
|
147
|
-
:content => content,
|
148
|
-
:content_type => 'text/html')
|
149
|
-
end
|
2
|
+
include Test::Unit::Assertions
|
3
|
+
def decoder(n)
|
4
|
+
str = [" ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";",
|
5
|
+
"<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
6
|
+
"[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
7
|
+
"y","z","{","|","}","~" ]
|
8
|
+
for i in 32..126
|
9
|
+
if n == i then return "#{str[i-32]}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
#i=1: 0-9,a-z,A-Z<br>
|
15
|
+
#i=2: -_ <br>
|
16
|
+
#i=3: a-z,A-Z<br>
|
17
|
+
#i=4: 0-9<br>
|
18
|
+
#i=41: 0-9 <br>
|
19
|
+
#i=5: @domain<br>
|
20
|
+
#i=10: Ho va Ten<br>
|
21
|
+
def getRandomString(n,i)
|
22
|
+
str = ""
|
23
|
+
|
24
|
+
str1 = ["0","1","2","3","4","5","6","7","8","9",
|
25
|
+
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
26
|
+
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
27
|
+
"y","z"]
|
28
|
+
|
29
|
+
str2 = ["-","","_",""]
|
30
|
+
|
31
|
+
str3 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
|
32
|
+
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
33
|
+
|
34
|
+
str4 = ["0","1","2","3","4","5","6","7","8","9"]
|
35
|
+
str41 = ["0","1","2","3","4","5","6","7","8","9","","","","","","","","","",""]
|
36
|
+
|
37
|
+
str5 = ["@yahoo.com.vn","@gmail.com","@yahoo.com","@msn.com","@hotmail.com","@zing.vn","@google.com.vn","@dantri.com",
|
38
|
+
"@vnexpress.net","@mail.com","@abc.com","@live.com","@mailinator.com"]
|
39
|
+
|
40
|
+
strHo = ["Nguyen","Dinh","Dang","Huynh","Mai","Tran","Le","Hoang","Pham","Phan","Vu","Bui","Do","Ho","Ngo",
|
41
|
+
"Duong","Ly","Vuong","Trinh","Truong","Dinh","Doan","Lam","Phung"]
|
42
|
+
|
43
|
+
strTenDem = ["Thi","Hong","Van","","Duc","Thuy","Ngoc","Ly","Bac","Hien"]
|
44
|
+
|
45
|
+
strTen = ["Trai","Xi","Truc","Tu","Bat","Thanh","Luong","Khuong","Quyen","Quang",
|
46
|
+
"Hoang","Ky","Thai","Chinh","Trinh","Kien","Hao","Hung","Quynh","Phuong","Hoa","Hop","Dung","Thang","Van","Tu","Ninh","Vinh","Loc","Khanh","Thuy","Ha",
|
47
|
+
"Hang","Lam","Hai","Vu","Na","Duyen","Minh","Tuan","Hien","Anh","An","Be","Binh","Canh"]
|
48
|
+
case i
|
49
|
+
when i == 1 then
|
50
|
+
for i in 1..n
|
51
|
+
str = "#{str}#{str1[rand(str1.length)]}"
|
52
|
+
end
|
53
|
+
return str
|
54
|
+
when i == 2 then
|
55
|
+
for i in 1..n
|
56
|
+
str = "#{str}#{str2[rand(str2.length)]}"
|
57
|
+
end
|
58
|
+
return str
|
59
|
+
when i == 3 then
|
60
|
+
for i in 1..n
|
61
|
+
str = "#{str}#{str3[rand(str3.length)]}"
|
62
|
+
end
|
63
|
+
return str
|
64
|
+
when i == 4 then
|
65
|
+
for i in 1..n
|
66
|
+
str = "#{str}#{str4[rand(10)]}"
|
67
|
+
end
|
68
|
+
return str
|
69
|
+
when i == 41 then
|
70
|
+
for i in 1..n
|
71
|
+
str = "#{str}#{str41[rand(str41.length)]}"
|
72
|
+
end
|
73
|
+
return str
|
74
|
+
when i == 5 then
|
75
|
+
for i in 1..n
|
76
|
+
str = "#{str}#{str5[rand(str5.length)]}"
|
77
|
+
end
|
78
|
+
return str
|
79
|
+
when i == 10 then
|
80
|
+
str = "#{strHo[rand(strHo.length)]} #{strTenDem[rand(strTenDem.length)]} #{strTen[rand(strTen.length)]}"
|
81
|
+
return str
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def randfromto(a,b)
|
86
|
+
x = rand(b)
|
87
|
+
while x < a do
|
88
|
+
x = rand(b)
|
89
|
+
end
|
90
|
+
return x
|
91
|
+
end
|
92
|
+
|
93
|
+
def cutEndline(text) #0.0.8
|
94
|
+
if RUBY_VERSION <= '1.8.6' then
|
95
|
+
if text[text.length - 1] < 32 then
|
96
|
+
return text[0,text.length - 1]
|
97
|
+
else return text[0,text.length]
|
98
|
+
end
|
99
|
+
else
|
100
|
+
if text[text.length - 1] < ' ' then
|
101
|
+
return text[0,text.length - 1]
|
102
|
+
else return text[0,text.length]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def readExcel(dir,sheet=1)
|
108
|
+
$excel = WIN32OLE.new("excel.application")
|
109
|
+
$excel.visible = true
|
110
|
+
$workbook = $excel.workbooks.open(dir)
|
111
|
+
$ws=$workbook.worksheets(sheet)
|
112
|
+
$workbook = $excel.ActiveWorkbook
|
113
|
+
end
|
114
|
+
|
115
|
+
def saveExcel
|
116
|
+
$workbook.Save
|
117
|
+
$workbook.Close
|
118
|
+
$excel.Quit
|
119
|
+
end
|
120
|
+
|
121
|
+
def getFile(name)
|
122
|
+
if File.exist?(name) then return true
|
123
|
+
else return false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def getPathExe(default_dir)
|
128
|
+
if ENV['OCRA_EXECUTABLE'].nil?
|
129
|
+
root_dir = File.dirname(default_dir).gsub('/', '\\') #0.0.7
|
130
|
+
else
|
131
|
+
root_dir = File.expand_path(File.dirname(ENV['OCRA_EXECUTABLE'])).gsub('/', '\\')
|
132
|
+
end
|
133
|
+
return root_dir + "\\"
|
134
|
+
end
|
135
|
+
|
136
|
+
def getDir(file,type = 1)
|
137
|
+
if type == 1 then
|
138
|
+
return File.dirname(file).gsub('/', '\\') + "\\"
|
139
|
+
else return File.dirname(file).gsub('/', '\\')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def send_Mail_on_Gmail(nickname,pass,to,subject,content)
|
144
|
+
g = GmailSender.new(nickname, pass)
|
145
|
+
g.send(:to => to,
|
146
|
+
:subject => subject,
|
147
|
+
:content => content,
|
148
|
+
:content_type => 'text/html')
|
149
|
+
end
|
150
150
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- QuangMV, Cyworld VietNam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Ha Noi, VietNam
|
@@ -14,12 +14,26 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-22 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: ocra
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
- 0
|
32
|
+
version: 1.2.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
21
35
|
description: Nice Function
|
22
|
-
email:
|
36
|
+
email: mr.quangmv@gmail.com
|
23
37
|
executables: []
|
24
38
|
|
25
39
|
extensions: []
|