From fefa1aafd88a06f096a6a266053cdb64fe98328b Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Wed, 23 May 2018 15:23:11 -0700 Subject: [PATCH] %bake schematic --- gen/ford-turbo.hoon | 152 ++++++++++++++++++++++++++++++++++++++++++++ lib/ford-turbo.hoon | 58 ++++++++++++++++- 2 files changed, 209 insertions(+), 1 deletion(-) diff --git a/gen/ford-turbo.hoon b/gen/ford-turbo.hoon index 07659b883d..477e82497a 100644 --- a/gen/ford-turbo.hoon +++ b/gen/ford-turbo.hoon @@ -104,6 +104,8 @@ test-cast test-cast-grow test-mute + test-bake-renderer + test-bake-mark == ++ test-tear :- `tank`leaf+"test-tear" @@ -5380,6 +5382,156 @@ (expect-ford-empty ford ~nul) == :: +++ test-bake-renderer + :- `tank`leaf+"test-bake-renderer" + :: + =/ ford *ford-gate + :: + =/ hoon-src-type=type [%atom %$ ~] + =/ scry-results=(map [term beam] cage) + %- my :~ + :- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo/ren]] + :- %hoon + :- hoon-src-type + ''' + /= data /!noun/ + data + ''' + :: + :- [%cx [[~nul %home %da ~1234.5.6] /hoon/data]] + :- %hoon + :- hoon-src-type + ''' + [1 2 3 ~] + ''' + == + :: + =^ results1 ford + %- test-ford-call-with-comparator :* + ford + now=~1234.5.6 + scry=(scry-with-results scry-results) + :: + :: + ^= call-args + :* duct=~[/path] type=~ %make ~nul + %pin ~1234.5.6 + [%bake %foo *coin `rail:ford-gate`[[~nul %home] /data]] + == + :: + ^= comparator + |= moves=(list move:ford-gate) + :: + ?> =(1 (lent moves)) + ?> ?=(^ moves) + ?> ?=([* %give %made @da %complete %success %pin *] i.moves) + =/ result result.p.card.i.moves + =/ pin-result build-result.result + ?> ?=([%success %bake *] build-result.pin-result) + :: + =/ =cage cage.build-result.pin-result + :: + %+ weld + %- expect-eq !> + :- %noun + p.cage + :: + %+ weld + %- expect-eq !> + :- [1 2 3 ~] + q.q.cage + :: + %- expect-eq !> + :- & + (~(nest ut p.q.cage) | -:!>([1 2 3 ~])) + == + :: + ;: weld + results1 + (expect-ford-empty ford ~nul) + == +:: +++ test-bake-mark + :- `tank`leaf+"test-bake-mark" + :: + =/ ford *ford-gate + :: + =/ hoon-src-type=type [%atom %$ ~] + :: + =/ hoon-src=@ta + ''' + |_ cell=^ + ++ grab + |% + ++ noun ^ + -- + -- + ''' + =/ scry-results=(map [term beam] (unit cage)) + %- my :~ + :- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo/mar]] + :- ~ + :- %hoon + :- hoon-src-type + hoon-src + :: + :- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo/ren]] + ~ + :: + :- [%cx [[~nul %home %da ~1234.5.6] /hoon/data]] + :- ~ + :- %hoon + :- hoon-src-type + ''' + [12 13] + ''' + == + :: + =^ results1 ford + %- test-ford-call-with-comparator :* + ford + now=~1234.5.6 + scry=(scry-with-results-and-failures scry-results) + :: + :: + ^= call-args + :* duct=~[/path] type=~ %make ~nul + %pin ~1234.5.6 + [%bake %foo *coin `rail:ford-gate`[[~nul %home] /hoon/data]] + == + :: + ^= comparator + |= moves=(list move:ford-gate) + :: + ?> =(1 (lent moves)) + ?> ?=(^ moves) + ?> ?=([* %give %made @da %complete %success %pin *] i.moves) + =/ result result.p.card.i.moves + =/ pin-result build-result.result + ?> ?=([%success %bake *] build-result.pin-result) + :: + =/ =cage cage.build-result.pin-result + :: + %+ weld + %- expect-eq !> + :- %foo + p.cage + :: + %+ weld + %- expect-eq !> + :- [12 13] + q.q.cage + :: + %- expect-eq !> + :- & + (~(nest ut p.q.cage) | -:!>([12 13])) + == + :: + ;: weld + results1 + (expect-ford-empty ford ~nul) + == +:: :: :: |utilities: helper arms :: diff --git a/lib/ford-turbo.hoon b/lib/ford-turbo.hoon index fa5af77671..6f09c390a6 100644 --- a/lib/ford-turbo.hoon +++ b/lib/ford-turbo.hoon @@ -2689,7 +2689,7 @@ :: %pin (make-pin date schematic) %alts (make-alts choices) - %bake !! + %bake (make-bake renderer query-string path-to-render) %bunt (make-bunt disc mark) %call (make-call gate sample) %cast (make-cast disc mark input) @@ -2778,6 +2778,62 @@ :: [build [%build-result %success %alts u.result] accessed-builds] :: + ++ make-bake + |= [renderer=term query-string=coin path-to-render=rail] + ^- build-receipt + :: + =/ path-build=^build + [date.build [%path disc.path-to-render %ren renderer]] + :: + =^ path-result accessed-builds (depend-on path-build) + ?~ path-result + [build [%blocks [path-build]~ ~] accessed-builds] + :: if no renderer at :renderer path, try a mark instead + :: + ?. ?=([~ %success %path *] path-result) + :: + =/ mark-build=^build + :- date.build + [%cast disc.path-to-render renderer [%core path-to-render]] + :: + =^ mark-build-result accessed-builds (depend-on mark-build) + ?~ mark-build-result + [build [%blocks [mark-build]~ ~] accessed-builds] + :: + ?. ?=([~ %success %cast *] mark-build-result) + (wrap-error mark-build-result) + :: + =/ =build-result + [%success %bake cage.u.mark-build-result] + :: + [build [%build-result build-result] accessed-builds] + :: build a +scaffold from the renderer source + :: + =/ hood-build=^build [date.build [%hood rail.u.path-result]] + :: + =^ hood-result accessed-builds (depend-on hood-build) + ?~ hood-result + [build [%blocks [hood-build]~ ~] accessed-builds] + :: + ?. ?=([~ %success %hood *] hood-result) + (wrap-error hood-result) + :: link the renderer, passing through :path-to-render and :query-string + :: + =/ plan-build=^build + [date.build [%plan path-to-render query-string scaffold.u.hood-result]] + :: + =^ plan-result accessed-builds (depend-on plan-build) + ?~ plan-result + [build [%blocks [plan-build]~ ~] accessed-builds] + :: + ?. ?=([~ %success %plan *] plan-result) + (wrap-error plan-result) + :: + =/ =build-result + [%success %bake %noun vase.u.plan-result] + :: + [build [%build-result build-result] accessed-builds] + :: ++ make-bunt |= [=disc mark=term] ^- build-receipt