-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsqlyoga_levure_callbacks.livecodescript
88 lines (71 loc) · 2.49 KB
/
sqlyoga_levure_callbacks.livecodescript
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
script "SQLYoga Levure Callbacks"
command loadRegisteredKeyFile @xFileA
local tDBObjectA, tDataA, tError
_concatYAMLFiles xFileA["filename"]
put the result into tError
put it into tDataA
if tError is empty then
dbobject_initialize tDataA, levureAppFolder(), xFileA["database key"]
put the result into tError
end if
if tError is empty then
return empty for value
else
return tError for error
end if
end loadRegisteredKeyFile
private command _concatYAMLFiles pFilename
local tError, tFile, tData, tDataA
if there is a folder pFilename then
repeat for each line tFile in files(pFilename)
if not (tFile ends with ".yml" or tFile ends with ".yaml") then next repeat
put url("binfile:" & pFilename & "/" & tFile) & cr after tData
if the result is not empty then
put "unable to read schema yaml file" && pFilename & "/" & tFile && ":" && the result into tError
exit repeat
end if
end repeat
else
put url("binfile:" & pFilename) into tData
end if
if tError is empty then
YAMLToArray textDecode(tData, "utf8")
put the result into tError
put it into tDataA
end if
if tError is empty then
return tDataA for value
else
return tError for error
end if
end _concatYAMLFiles
/**
Summary: Concat all of the files and store in a custom property in sqlyoga_loader.livecodescript
Description:
This helper doesn't distribute the files in the sql yoga > configuration key. In
development the designated folder holds multiple files. Concat the files and make available
through a custom property.
*/
command processPackagedFileAsset pBuildProfile, pPlatform, @xFileAssetA, pOutputFolder
local tError, tDataA, tFilename
local msgsAreLocked
if xFileAssetA["database key"] is empty then put "default" into xFileAssetA["database key"]
_concatYAMLFiles xFileAssetA["filename"]
put the result into tError
put it into tDataA
if tError is empty then
# Store the database object in the sqlyoga library stack
put pOutputFolder & "/helpers/sql-yoga/sqlyoga_loader.livecodescript" into tFilename
put the lockMessages into msgsAreLocked
lock messages
set the uDbObjects[ xFileAssetA["database key"] ] of stack tFilename to tDataA
set the scriptonly of stack tFilename to false
save stack tFilename
delete stack tFilename
unlock messages
end if
if tError is not empty then
answer error "SQL Yoga Helper:" && param(0) & ":" && tError
end if
return empty
end processPackagedFileAsset