zaphire 0.0.8 → 0.0.18
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 +4 -4
- data/lib/zaphire.rb +216 -179
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04eabf77d33c1a421a393a1983bd07f6706a881a
|
4
|
+
data.tar.gz: 09d1adab1102d694c8c58104a8a199f9983aea5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec493e72d388a2f326e827171a7704d33c80638a857a6e264fe6bd6625037f0af7c361ad58b466f5ed96546dad5ec42dbdcae19f6c39b228bd4dbbedac403ea
|
7
|
+
data.tar.gz: a89d8d7d72f8927e5df1a4352769eb6727a0823255cf61698288a2b0f454bbd2826ffc9295c36367df0cf0f96348968876476058bd501b346bd9a95b1337a148
|
data/lib/zaphire.rb
CHANGED
@@ -5,33 +5,11 @@ require 'google_drive'
|
|
5
5
|
require 'csv'
|
6
6
|
require 'open-uri'
|
7
7
|
|
8
|
-
module Zsave
|
9
|
-
|
10
|
-
def self.csv(arr,file,mode="w",opts={})
|
11
|
-
|
12
|
-
arr = arr.to_a
|
13
|
-
|
14
|
-
File.open(file,mode){ |f| f << arr.map(&:to_csv).join("\n") }
|
15
|
-
|
16
|
-
#open(path,mode,opts){ |csv| array.each{ |row| csv << row } }
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.cvs(array,path,mode="w",opts={})
|
20
|
-
|
21
|
-
arr = arr.to_a
|
22
|
-
|
23
|
-
File.open(file,mode){ |f| f << arr.map(&:to_csv).join("\n") }
|
24
|
-
|
25
|
-
#open(path,mode,opts){ |csv| array.each{ |row| csv << row } }
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
8
|
# short version for short commands that rely on global variable well set to get things
|
31
9
|
|
32
10
|
module Z
|
33
11
|
|
34
|
-
def self.get
|
12
|
+
def self.get(pack=@iivar)
|
35
13
|
|
36
14
|
|
37
15
|
key = m(pack,'key')
|
@@ -43,8 +21,37 @@ module Z
|
|
43
21
|
|
44
22
|
|
45
23
|
end
|
24
|
+
|
25
|
+
def self.v
|
26
|
+
return '18'
|
27
|
+
end
|
28
|
+
|
46
29
|
end
|
47
30
|
|
31
|
+
module Zsave
|
32
|
+
|
33
|
+
def self.csv(arr,file,mode="w",opts={})
|
34
|
+
|
35
|
+
arr = arr.to_a
|
36
|
+
|
37
|
+
File.open(file,mode){ |f| f << arr.map(&:to_csv).join("\n") }
|
38
|
+
|
39
|
+
#open(path,mode,opts){ |csv| array.each{ |row| csv << row } }
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.cvs(array,path,mode="w",opts={})
|
43
|
+
|
44
|
+
arr = arr.to_a
|
45
|
+
|
46
|
+
File.open(file,mode){ |f| f << arr.map(&:to_csv).join("\n") }
|
47
|
+
|
48
|
+
#open(path,mode,opts){ |csv| array.each{ |row| csv << row } }
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
48
55
|
module Zgdocs
|
49
56
|
|
50
57
|
def self.addvalue key,sheet,value,user,password
|
@@ -86,13 +93,13 @@ module Zgdocs
|
|
86
93
|
|
87
94
|
session = GoogleDrive.login(user, password)
|
88
95
|
ws = session.spreadsheet_by_key(key).worksheet_by_title(sheet)
|
89
|
-
|
96
|
+
|
90
97
|
rows = t.last_row
|
91
98
|
|
92
99
|
ws.max_rows = (rows + 1) if ws.max_rows == rows
|
93
100
|
|
94
101
|
rows = 0 if rows == nil
|
95
|
-
|
102
|
+
|
96
103
|
|
97
104
|
aa = rows + 1
|
98
105
|
aa
|
@@ -121,7 +128,7 @@ module Zgdocs
|
|
121
128
|
curCol = colstart
|
122
129
|
|
123
130
|
m "ZgdocsSaving Row",therow,xx
|
124
|
-
|
131
|
+
|
125
132
|
data.row(therow).each do |value|
|
126
133
|
|
127
134
|
#0.upto(row.column_count) do |col|
|
@@ -146,7 +153,7 @@ module Zgdocs
|
|
146
153
|
session = GoogleDrive.login(user, password)
|
147
154
|
|
148
155
|
ws = session.spreadsheet_by_key(key).worksheet_by_title(sheet)
|
149
|
-
|
156
|
+
|
150
157
|
ws.max_rows = (rows + 2) if ws.max_rows < rows
|
151
158
|
|
152
159
|
end
|
@@ -183,46 +190,48 @@ def put a
|
|
183
190
|
puts a.to_s
|
184
191
|
end
|
185
192
|
|
186
|
-
def d
|
187
|
-
|
188
|
-
|
193
|
+
def d itext,i,xx,iadditional
|
194
|
+
if i == nil
|
195
|
+
puts a
|
196
|
+
return ''
|
197
|
+
else
|
198
|
+
iadditional = '' if iadditional == nil
|
199
|
+
tt = xx.to_f + 1.00
|
200
|
+
aa = trunc( (( (i.to_f+1) / tt) * 100) )
|
201
|
+
it = itext << ": (" << aa.to_s << "%)"
|
189
202
|
|
190
|
-
|
191
|
-
|
192
|
-
aa = trunc( (( (i.to_f+1) / tt) * 100) )
|
193
|
-
it = itext << ": (" << aa.to_s << "%)"
|
203
|
+
return "" if @mvar == it
|
204
|
+
@mvar = it
|
194
205
|
|
195
|
-
|
196
|
-
@mvar = it
|
206
|
+
texttodisp = @mvar << " " << iadditional
|
197
207
|
|
198
|
-
|
208
|
+
i += 1
|
209
|
+
xx += 1
|
199
210
|
|
200
|
-
|
201
|
-
|
211
|
+
@mstart = theticks() if i == 1
|
212
|
+
return "" if i == 1 or xx == 1
|
213
|
+
|
214
|
+
it = trunc( (i.to_f / tt*10) )
|
215
|
+
|
216
|
+
ee = ( (theticks.to_f - @mstart.to_f) / 60) * ( (tt - i) / i.to_f )
|
217
|
+
aa = trunc( ee )
|
218
|
+
bb = trunc( aa.to_f / 60 )
|
219
|
+
cc1 = aa.to_f / 60
|
220
|
+
cc2 = trunc( (aa.to_f / 60) )
|
221
|
+
cc = trunc( (cc1 - cc2 ) * 60 )
|
202
222
|
|
203
|
-
|
204
|
-
return "" if i == 1 or xx == 1
|
205
|
-
|
206
|
-
it = trunc( (i.to_f / tt*10) )
|
207
|
-
|
208
|
-
ee = ( (theticks.to_f - @mstart.to_f) / 60) * ( (tt - i)/i.to_f )
|
209
|
-
aa = trunc( ee )
|
210
|
-
bb = trunc( aa.to_f / 60 )
|
211
|
-
cc1 = aa.to_f / 60
|
212
|
-
cc2 = trunc( (aa.to_f / 60) )
|
213
|
-
cc = trunc( (cc1 - cc2 ) * 60 )
|
223
|
+
cc = "0" << cc.to_s if cc.to_s.size == 1
|
214
224
|
|
215
|
-
|
225
|
+
it = "[" << " XXXXXXXXXX"[1..it.to_i] << " __________"[1..(10-it.to_i)] << "] " << texttodisp << " (" << bb.to_s << ":" << cc.to_s << " Min. left) " << i.to_i.to_s << " of " << tt.to_i.to_s
|
216
226
|
|
217
|
-
|
218
|
-
|
219
|
-
d it
|
227
|
+
d it
|
220
228
|
|
221
|
-
|
229
|
+
iSetMsgForTerm(@itermattended, it) unless @itermattended
|
230
|
+
end
|
222
231
|
end
|
223
232
|
|
224
233
|
def iSetMsgForTerm iterm,imessage
|
225
|
-
|
234
|
+
return ""
|
226
235
|
end
|
227
236
|
|
228
237
|
# on m itext,i,xx
|
@@ -250,11 +259,11 @@ end
|
|
250
259
|
|
251
260
|
class String
|
252
261
|
|
253
|
-
def delete_lines(
|
254
|
-
|
262
|
+
def delete_lines(num_of_lines=1)
|
263
|
+
split(/\r\n|\r|\n/, num_of_lines+1).last
|
255
264
|
end
|
256
265
|
|
257
|
-
def delete_char(number=1,number2='')
|
266
|
+
def delete_char(number=1, number2='')
|
258
267
|
if number2==''
|
259
268
|
self[number-1]=''
|
260
269
|
self
|
@@ -264,7 +273,7 @@ class String
|
|
264
273
|
end
|
265
274
|
end
|
266
275
|
|
267
|
-
def char(number=1,number2='')
|
276
|
+
def char(number=1, number2='')
|
268
277
|
if number2==''
|
269
278
|
self[number-1]
|
270
279
|
else
|
@@ -272,7 +281,7 @@ class String
|
|
272
281
|
end
|
273
282
|
end
|
274
283
|
|
275
|
-
def line(number=1,number2='')
|
284
|
+
def line(number=1, number2='')
|
276
285
|
if number2==''
|
277
286
|
self.split('\n')[number-1]
|
278
287
|
else
|
@@ -285,50 +294,75 @@ class String
|
|
285
294
|
end
|
286
295
|
|
287
296
|
def lastchar(a=1)
|
297
|
+
return '' if self == nil
|
288
298
|
self[-a..-1]
|
289
299
|
end
|
290
300
|
|
291
|
-
def number_of_lines
|
292
|
-
|
301
|
+
def number_of_lines
|
302
|
+
return 0 if self == nil or self == ''
|
303
|
+
self.lines.count
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
class Nil
|
309
|
+
def lastchar
|
310
|
+
return ''
|
311
|
+
end
|
312
|
+
|
313
|
+
def number_of_lines
|
314
|
+
return 0
|
315
|
+
end
|
316
|
+
|
317
|
+
def contains
|
318
|
+
return false
|
319
|
+
end
|
320
|
+
|
321
|
+
def line
|
322
|
+
return ''
|
293
323
|
end
|
324
|
+
|
325
|
+
def char
|
326
|
+
return ''
|
327
|
+
end
|
328
|
+
|
294
329
|
end
|
295
330
|
|
296
331
|
class Matrix
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
332
|
+
def dump(firstLine = "")
|
333
|
+
str = ""
|
334
|
+
if firstLine != ""
|
335
|
+
str << firstLine << "\n"
|
336
|
+
end
|
337
|
+
for i in 0...self.row_size
|
338
|
+
space = ""
|
339
|
+
for j in 0...self.column_size
|
340
|
+
str << space << self[i,j].to_s
|
341
|
+
space = " "
|
342
|
+
end
|
343
|
+
str << "\n"
|
344
|
+
end
|
345
|
+
return str
|
346
|
+
end
|
312
347
|
# La classe Matrix est immutable, or je veux pouvoir écrire :
|
313
348
|
# m[i,j] = v
|
314
349
|
#
|
315
350
|
def []=(i, j, v)
|
316
|
-
|
351
|
+
@rows[i][j] = v
|
317
352
|
end
|
318
353
|
# Il n'y a même pas de constructeur pour une matrice rectangulaire : bouhhh
|
319
354
|
# Le prefixe "self." permet de déclarer une méthode de classe
|
320
355
|
def self.create(nbRows, nbCols, value)
|
321
|
-
|
356
|
+
return Matrix.rows(Array.new(nbRows, Array.new(nbCols,value)))
|
322
357
|
end
|
323
358
|
end
|
324
359
|
|
325
|
-
|
326
360
|
def left a,b
|
327
361
|
c = b-1
|
328
362
|
a.to_s[0..c]
|
329
363
|
end
|
330
364
|
|
331
|
-
def chars
|
365
|
+
def chars(a, b, c)
|
332
366
|
c.to_s[a-1..b-1]
|
333
367
|
end
|
334
368
|
|
@@ -338,14 +372,14 @@ end
|
|
338
372
|
# end
|
339
373
|
# end
|
340
374
|
|
341
|
-
def offset tofind, pack
|
375
|
+
def offset (tofind, pack)
|
342
376
|
a = pack.index(tofind)
|
343
377
|
if a == nill
|
344
|
-
a
|
378
|
+
a = 0
|
345
379
|
else
|
346
380
|
a += 1
|
347
381
|
end
|
348
|
-
|
382
|
+
a
|
349
383
|
end
|
350
384
|
|
351
385
|
def length a
|
@@ -353,118 +387,121 @@ def length a
|
|
353
387
|
end
|
354
388
|
|
355
389
|
def icrash imessage
|
356
|
-
|
357
|
-
|
390
|
+
d "CRASH****: " << imessage
|
391
|
+
# break
|
358
392
|
end
|
359
393
|
|
360
|
-
def m
|
361
|
-
|
362
|
-
|
363
|
-
|
394
|
+
def m(ifld, ipack, icrashnow)
|
395
|
+
r = "\n"
|
396
|
+
|
397
|
+
get offset("ı" << ifld << ",",ipack)
|
364
398
|
if @it == 0 # multiline pck
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
399
|
+
get offset("ı" << ifld << r,ipack)
|
400
|
+
ifldend = "ıend" << ifld
|
401
|
+
iendc = offset(ifldend, ipack) - 2
|
402
|
+
if iendc == 0 or iendc <= @it
|
403
|
+
if icrashnow == true
|
404
|
+
icrash "mExtFrmPck:fldNotFound:'" << ifld << "'"
|
405
|
+
return "***CRASH"
|
406
|
+
end
|
407
|
+
if ipack == ''
|
408
|
+
get m(ifld, fiivar(), true)
|
409
|
+
else
|
410
|
+
get m(ifld, mreformat(ipack), true)
|
411
|
+
end
|
412
|
+
else
|
413
|
+
istart = @it + (ifld.length) + 2
|
414
|
+
get ipack.char(istart, iendc)
|
415
|
+
end
|
382
416
|
else
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
417
|
+
ifldend = r
|
418
|
+
istart = @it + length(ifld) + 2
|
419
|
+
ilen = length(ipack)
|
420
|
+
rrr = ipack.char(istart, ilen) << r
|
421
|
+
iendc = offset(ifldend, rrr) - 2 + istart
|
422
|
+
get ipack.char(istart, iendc)
|
423
|
+
end
|
389
424
|
return @it
|
390
425
|
end
|
391
426
|
|
392
427
|
|
393
428
|
def mreformat ipack
|
394
429
|
r = "\n"
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
else
|
419
|
-
aa = aa << "ı" << it << r
|
420
|
-
end
|
421
|
-
end
|
422
|
-
|
423
|
-
aa = aa << "≤"
|
424
|
-
return aa
|
430
|
+
until 1 == 2 do
|
431
|
+
break if ipack.lines.count == 0
|
432
|
+
get ipack.lines.first
|
433
|
+
ipack = ipack.delete_lines(1)
|
434
|
+
|
435
|
+
if @it.char(1) == "ı"
|
436
|
+
aa = aa << it << r
|
437
|
+
|
438
|
+
next if @it.contains(",")
|
439
|
+
|
440
|
+
@it = @it.delete_char(1)
|
441
|
+
iend = offset("ıend" << @it, ipack)
|
442
|
+
icrash "reformat:StartedButNoEnd" if iend == 0
|
443
|
+
aa = aa << ipack.char(1, iend)
|
444
|
+
ipack = ipack.delete_char(1, iend)
|
445
|
+
aa = aa << ipack.line(1) << r
|
446
|
+
ipack = ipack.delete_lines(1)
|
447
|
+
|
448
|
+
next
|
449
|
+
else
|
450
|
+
aa = aa << "ı" << it << r
|
451
|
+
end
|
452
|
+
end
|
425
453
|
|
454
|
+
aa = aa << "≤"
|
455
|
+
return aa
|
426
456
|
end
|
427
457
|
|
428
|
-
def ireplaceachar
|
458
|
+
def ireplaceachar(aa)
|
429
459
|
a = aa[0]
|
430
460
|
b = aa[1]
|
431
|
-
aa = aa.delete_char(1,2)
|
432
|
-
aa.gsub(a, b)
|
461
|
+
aa = aa.delete_char(1, 2)
|
462
|
+
aa = aa.gsub(a, b)
|
463
|
+
aa
|
433
464
|
end
|
434
465
|
|
435
466
|
# need to check strange symbols on a Mac, since Window mixes up chars
|
436
|
-
def ms
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
467
|
+
def ms(ipart, inewvalue, ipack)
|
468
|
+
r = "\n"
|
469
|
+
|
470
|
+
icrash "ms():part not defined" if ipart == nil
|
471
|
+
ipack = mreformat(ipack) if ipack.lastchar() != "≤"
|
472
|
+
ipart = ireplaceachar("≤Ì" << ipart) if ipart.contains("≤")
|
473
|
+
inewvalue = ireplaceachar("≤Ì" << inewvalue) if inewvalue.contains("≤")
|
474
|
+
|
475
|
+
if inewvalue.number_of_lines < 2
|
476
|
+
inewpart = "" << ipart << "," << inewvalue
|
477
|
+
else
|
478
|
+
inewpart = "" << ipart << r << inewvalue << r << "end" << ipart
|
479
|
+
end
|
480
|
+
|
481
|
+
get offset(r << "" << ipart << ",", r << ipack)
|
482
|
+
get offset(r << "" << ipart << r, r << ipack) if @it == 0
|
483
|
+
|
484
|
+
if @it == 0
|
485
|
+
if ipack == ''
|
486
|
+
return inewpart << r << "≤"
|
487
|
+
else
|
488
|
+
ipack[-1] = inewpart << r << "≤"
|
489
|
+
return ipack
|
490
|
+
end
|
491
|
+
end
|
492
|
+
istartchar = it
|
493
|
+
iendoffset = offset("end" << ipart << r, ipack << r)
|
494
|
+
ilastChar = iendoffset + length(ipart) + 3
|
495
|
+
if iendoffset == 0
|
496
|
+
yyy = ipack << r
|
497
|
+
ilastChar = offset(r, yyy.char(istartchar, (length(ipack)+1))) - 2 + istartchar
|
498
|
+
end
|
499
|
+
ipack[istartchar-1..ilastchar-1] = inewpart
|
500
|
+
return ipack
|
466
501
|
end
|
467
502
|
|
468
|
-
def fiivar
|
469
|
-
@iivar
|
503
|
+
def fiivar(aa=nil)
|
504
|
+
@iivar = '' if @iivar == nil
|
505
|
+
@iivar = aa unless aa == nil
|
506
|
+
return @iivar
|
470
507
|
end
|