Skip to content

Commit

Permalink
Move action from binary to Gem
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Jul 30, 2024
1 parent 76b016f commit 7596283
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
20 changes: 1 addition & 19 deletions bin/ring.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,4 @@ module Resolver = Gem.Resolver.Make (struct
let target = Path.rel [ "_www" ]
end)

let final_message _cache = Eff.log ~level:`Debug "ring.muhokama done"

let generate_opml chain =
Action.write_static_file Resolver.Target.ring_opml
(let open Task in
Pipeline.track_files
(Resolver.Source.members :: Resolver.Source.common_deps)
>>> const chain
>>> Gem.Chain.to_opml)

let process_all () =
let open Eff in
let* cache, chain = Gem.Action.init_chain (module Resolver) in
return cache
>>= generate_opml chain
>>= Action.store_cache Resolver.Target.cache
>>= final_message

let () = Yocaml_eio.run ~level:`Debug process_all
let () = Yocaml_eio.run ~level:`Debug (Gem.Action.process_all (module Resolver))
17 changes: 17 additions & 0 deletions lib/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ let init_chain (module R : Sigs.RESOLVER) =
cache
in
(cache, Chain.init ~chain ~members)

let final_message _cache = Yocaml.Eff.log ~level:`Debug "ring.muhokama done"

let generate_opml (module R : Sigs.RESOLVER) chain =
Yocaml.Action.write_static_file R.Target.ring_opml
(let open Yocaml.Task in
Yocaml.Pipeline.track_files (R.Source.members :: R.Source.common_deps)
>>> const chain
>>> Chain.to_opml)

let process_all (module R : Sigs.RESOLVER) () =
let open Yocaml.Eff in
let* cache, chain = init_chain (module R) in
return cache
>>= generate_opml (module R) chain
>>= Yocaml.Action.store_cache R.Target.cache
>>= final_message
4 changes: 4 additions & 0 deletions lib/action.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(** All the actions used to build the ring. *)

val process_all : (module Sigs.RESOLVER) -> unit -> unit Yocaml.Eff.t
(** Process all action in order to produce [ring.muhokama]. *)

0 comments on commit 7596283

Please sign in to comment.