GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - clj-pour/pour: Declarative, composable and extensible tree querying and transformation based on EQL.

BranchesTags
Open more actions menu

Latest commit

 

History

71 Commits
71 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
dev
dev
 
 
src/pour
src/pour
 
 
test/pour
test/pour
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
deps.edn
deps.edn
 
 

Repository files navigation

Pour

CircleCI

Pour consists of a library for applying EQL queries to a value, and a tool for composing queries from functions annotated with a query (examples at the bottom). The primary use case is for functions that return hiccup.

Pour allows you to define custom resolvers that can be run at arbitrary points inside a query.

It currently only supports JVM clojure but cljs support is under development.

Resolution is run inside core async processes, and runs in parallel as far as possible.

  • available as a git dependency via deps, eg (latest stable):
{:deps {pour {:git/url "https://github.com/clj-pour/pour.git"
              :sha     "07efe0455b5473dab89af6e29bc5905a74cfd118"}}}

Usage

Pour is based on EQL.

There are two arities of the main pour/pour function.

query, value

The arity-2 version is a mostly barebones implementation of extracting data from a map with EQL.

Apply the query to the provided value, eg:

(require '[pour.core :as pour])

(pour/pour [:a :b] {:a 1 :b 2 :c 3})
=> {:a 1 :b 2}

If a requested key is not present in the value, it is not present in the output.

(pour/pour [:b] {:a 1 :c 3})
=> {}

env, query, value

The Arity-3 version can take an env argument in the first position.

Here the user can specify an environment, or context, in which the query is operating. The user can supply a map of keys to resolver functions on the resolvers key on the env which, when present, will be used preferentially over direct access to the value, as in the example below.

Resolvers are functions that take two arguments - env and the current node upon which it is operating. The env can contain arbitrary data, it is up to you. The node provides the value, and the EQL information about that position in the query, eg params, type..

(pour/pour
  {:now       (inst-ms (java.util.Date.))
   :resolvers {:days-ago-timestamp (fn [{:keys [now] :as env} {:keys [value params]
                                                               :as node}]
                                     (let [days-ago (:days-ago params)
                                           days-ago-ms (* days-ago 24 60 60 1000)]
                                       (- now days-ago-ms)))}}
  '[(:days-ago-timestamp {:days-ago 7})
    :foo]
  {:foo :bar})

Compose Usage

Tool for composing and executing defcup components together. Pour knows nothing about what the output might be - that's up to you - but we'll be building hiccup in the examples below.

:coming/soon!

About

Declarative, composable and extensible tree querying and transformation based on EQL.

Topics

clojureeqlhiccuptrees

Resources

Readme
MIT license
Activity
Custom properties

Stars

41 stars

Watchers

3 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.