-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-test.r3
More file actions
56 lines (49 loc) · 1.32 KB
/
ci-test.r3
File metadata and controls
56 lines (49 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Rebol [title: "MOBI codec CI test"]
system/options/quiet: false
system/options/log/rebol: 4
import %mobi.reb
system/options/log/mobi: 4
foreach [file url] [
%RUR.v1.mobi https://www.gutenberg.org/ebooks/13083.kindle.images
%RUR.v2.mobi https://www.gutenberg.org/ebooks/13083.kf8.images
][
print-horizontal-line
if not exists? file [
print [as-green "Downloading book from:" as-yellow url]
try/with [
;; Download a book for a test...
write file read url
][
print as-purple "*** Failed to download a book!"
quit/return -1
]
]
print-horizontal-line
print as-yellow "Decode the book using `decode` function:"
try/with [
;; Decode raw binary data already in memory...
data: decode 'mobi file
][
print as-purple "*** Failed to decode a book!"
print system/state/last-error
quit/return -2
]
print as-green "MOBI data succesfully decoded!"
? data ;print to-string data/text
print-horizontal-line
print as-yellow "Decode the book using a scheme:"
try/with [
book: open [scheme: 'mobi path: file]
;; all metadata should be decoded when the port is opened...
? book
probe query book
;; when text is needed, use READ on the port...
text: read/string book
? text ;print text
close book
][
print as-purple "*** Failed to decode a book!"
print system/state/last-error
quit/return -3
]
]