Skip to content

Instantly share code, notes, and snippets.

@huylenq
Last active January 18, 2018 12:30
Show Gist options
  • Select an option

  • Save huylenq/62d3a710de2e40df80fb397d0d36a2a9 to your computer and use it in GitHub Desktop.

Select an option

Save huylenq/62d3a710de2e40df80fb397d0d36a2a9 to your computer and use it in GitHub Desktop.
A complete Embulk Input Plugin in 2 dozens lines of code
in:
type: simple
out:
type: file
file_ext: csv
path_prefix: ''
formatter: {type: csv}
;: Run by `embulk -clj simple.clj config.yml` (and with this embulk fork https://github.com/huylenq/embulk)
(ns simple
(:require [embulk.spik.core :refer :all]
[embulk.spik.restful :refer :all]
[clojure.spec.alpha :as s]))
(s/def ::target (partial contains? #{"posts" "comments" "albums"}))
(defconfigs
:target {:type :string
:spec ::target}
{:req [:target]})
(defgraph
"https://jsonplaceholder.typicode.com/"
(posts [:id :string
:userId :string
:body :string
:title :string]
(:id (comments)))
(comments [:id :string
:email :string
:body :string])
(albums []))
(pumper (get graph (:target *task*)) :associations true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment