metafacture / metafacture-fix

Work in progress towards an implementation of the Fix language for Metafacture
Apache License 2.0
6 stars 2 forks source link

Introduce `each`-bind from Catmandu #296

Open TobiasNx opened 1 year ago

TobiasNx commented 1 year ago

each(path: JSONPath, var: NAME) Execute all the fixes in the context of every element in the JSONPath hash

do each(path: demo, var: t)
copy_field(t.value, titles.$append)
end

In OERSI I had the scenario: that I had to do this:

uniq("creator[]")
uniq("contributor[]")
uniq("sourceOrganization[]")
uniq("inLanguage[]")
uniq("learningResourceType[]")
uniq("keywords[]")
uniq("about[]")
uniq("teaches[]")
uniq("assesses[]")
uniq("competencyRequired[]")
uniq("educationalLevel[]")
uniq("encoding[]")
uniq("publisher[]")
uniq("isPartOf[]")

With do each I could do:

do each(path: ".", "var":"$i")
  if is_array(".")
    uniq(".")
  end
end
blackwinter commented 1 year ago

Use case also depends on #191.