urbit/pkg/garden/lib/settings.hoon

148 lines
2.3 KiB
Plaintext
Raw Normal View History

2021-01-12 23:36:30 +03:00
/- *settings
|%
++ enjs
=, enjs:format
|%
++ data
|= dat=^data
^- json
%+ frond -.dat
?- -.dat
%all (settings +.dat)
%bucket (bucket +.dat)
%entry (value +.dat)
2021-09-09 04:35:57 +03:00
%desk (desk-settings +.dat)
==
::
++ settings
|= s=^settings
^- json
2021-09-09 03:41:39 +03:00
[%o (~(run by s) desk-settings)]
::
++ desk-settings
|= s=(map key ^bucket)
[%o (~(run by s) bucket)]
::
2021-01-12 23:36:30 +03:00
++ event
|= evt=^event
^- json
%+ frond -.evt
?- -.evt
%put-bucket (put-bucket +.evt)
%del-bucket (del-bucket +.evt)
%put-entry (put-entry +.evt)
%del-entry (del-entry +.evt)
==
::
++ put-bucket
2021-09-09 03:41:39 +03:00
|= [d=desk k=key b=^bucket]
2021-01-12 23:36:30 +03:00
^- json
%- pairs
:~ bucket-key+s+k
bucket+(bucket b)
2021-09-09 03:41:39 +03:00
desk+s+d
2021-01-12 23:36:30 +03:00
==
::
++ del-bucket
2021-09-09 03:41:39 +03:00
|= [d=desk k=key]
2021-01-12 23:36:30 +03:00
^- json
%- pairs
:~ bucket-key+s+k
2021-09-09 03:41:39 +03:00
desk+s+d
2021-01-12 23:36:30 +03:00
==
::
++ put-entry
2021-09-09 03:41:39 +03:00
|= [d=desk b=key k=key v=val]
2021-01-12 23:36:30 +03:00
^- json
%- pairs
:~ bucket-key+s+b
entry-key+s+k
2021-02-25 04:28:26 +03:00
value+(value v)
2021-09-09 03:41:39 +03:00
desk+s+d
2021-01-12 23:36:30 +03:00
==
::
++ del-entry
2021-09-09 03:41:39 +03:00
|= [d=desk buc=key =key]
2021-01-12 23:36:30 +03:00
^- json
%- pairs
:~ bucket-key+s+buc
2021-01-12 23:36:30 +03:00
entry-key+s+key
2021-09-09 03:41:39 +03:00
desk+s+d
2021-01-12 23:36:30 +03:00
==
::
++ value
|= =val
^- json
?- -.val
%s val
%b val
%n (numb p.val)
2021-02-25 04:28:26 +03:00
%a [%a (turn p.val value)]
2021-01-12 23:36:30 +03:00
==
::
++ bucket
|= b=^bucket
^- json
[%o (~(run by b) value)]
--
::
++ dejs
=, dejs:format
|%
++ event
|= jon=json
^- ^event
%. jon
%- of
:~ put-bucket+put-bucket
del-bucket+del-bucket
put-entry+put-entry
del-entry+del-entry
==
::
++ put-bucket
%- ot
2021-09-09 03:41:39 +03:00
:~ desk+so
bucket-key+so
2021-01-12 23:36:30 +03:00
bucket+bucket
==
::
++ del-bucket
%- ot
2021-09-09 03:41:39 +03:00
:~ desk+so
bucket-key+so
2021-01-12 23:36:30 +03:00
==
::
++ put-entry
%- ot
2021-09-09 03:41:39 +03:00
:~ desk+so
bucket-key+so
2021-01-12 23:36:30 +03:00
entry-key+so
2021-02-25 04:28:26 +03:00
value+value
2021-01-12 23:36:30 +03:00
==
::
++ del-entry
%- ot
2021-09-09 03:41:39 +03:00
:~ desk+so
bucket-key+so
2021-01-12 23:36:30 +03:00
entry-key+so
==
::
++ value
|= jon=json
^- val
?+ -.jon !!
%s jon
%b jon
%n [%n (rash p.jon dem)]
2021-02-25 04:28:26 +03:00
%a [%a (turn p.jon value)]
2021-01-12 23:36:30 +03:00
==
::
++ bucket
|= jon=json
^- ^bucket
?> ?=([%o *] jon)
(~(run by p.jon) value)
--
--