Giter VIP home page Giter VIP logo

klojure's Introduction

klojure

Build Status

A blueprint bundle for deploying a nrepl server to a karaf container.

Installing

To install the bundle in a running karaf instance, do:

bundle:install https://git.io/fjHIs; start klojure

NOTE: you will probably need to disable the DDF Security Manager as clojure brings along its own classloader which causes problems with security.

Running a REPL

To run a repl in the karaf console, do:

clj:repl

To connect to the nrepl server with lein, do:

lein repl :connect 7888

The nrepl server is also available for clients such as cursive and vim-fireplace.

DDF Clojure API

Klojure exposes a clojure API for DDF. It can be found in the catalog.core namespace.

Below is an example of the API:

(require '[catalog.core :as c])

; query for exisitng metacards
(c/query [[:attribute "id"] :is :like [:text "*"]])

; create a new metacard
(c/create! {:id "" :title "one"})

; delete a metacard by id
(c/delete! "afa5099ccfcb40c3b39bade0148fc342")

; delete all metacards
(->> (c/query [[:attribute "id"] :is :like [:text "*"]])
     (map ::id)
     (apply c/delete!))

; query for all workspaces
(c/query [[:attribute "metacard-tags"] :is :like [:text "workspace"]])

Building

To build the klojure jar, do:

mvn clean install

To hot deploy a development version, do:

cp target/klojure-*.jar $DDF_HOME/deploy

Documentation

License

Copyright (c) 2019 Chris Badahdah

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

klojure's People

Contributors

dependabot[bot] avatar djblue avatar lambeaux avatar rzwiefel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

klojure's Issues

Reconfigure API documentation for project because Codox won't locate namespaces in external modules

The objective of this issue is to restore the Codox API documentation generation which was being published to Github Pages (the gh-pages branch).

Originally this project was using Codox to generate API documentation. The main.clj file for the docs generation, along with some troubleshooting code, looked like this:

(ns main
  (:require clojure.pprint
            [clojure.xml :as xml]
            [codox.main :refer [generate-docs]]))

(def sep (apply str (take 100 (repeat "-"))))
(defn- shout!
  ([data]
   (do (println sep) (println sep) (println data) data))
  ([msg data]
   (do (println sep) (println sep) (println msg) (println data) data)))

(defn- get-source-paths []
  (->> ["../klojure-catalog" "../klojure-deps"]
         (map #(str % "/src/main/clojure"))
         vec
         shout!))

(defn- project-info []
  (->>
    ;; Need to verify what mvn sets as working dir when building sub-modules
    (:content (xml/parse "../pom.xml"))
    (shout! (System/getProperty "user.dir"))
    (filter #(#{:artifactId :groupId :version :description} (:tag %)))
    (map #(-> [(:tag %) (first (:content %))]))
    (into {})
    shout!))

(defn -main []
  (let [{:keys [artifactId groupId version description]} (project-info)]
    (generate-docs)
    {:doc-files ["../README.md"]}
    :source-paths (get-source-paths)
    :name artifactId
    :package (symbol groupId artifactId)
    :version version
    :description description
    :namespaces [#"^(?!(doc|klojure)).*"]
    :metadata {:doc/format :markdown}
    :source-uri (str "https://github.com/djblue/" artifactId "/blob/master/{filepath}#L{line}")))

(-main)

Assuming mvn:codox/codox/0.10.7 and mvn:org.clojure/clojure/1.10.0 are on the build classpath, the above can be tested and the issue reproduced by running the following:

mvn clojure:run -Dclojure.script=src/main/clojure/main.clj

Several notes:

  • The Clojure script itself can find files and follow paths just fine
  • All the data is valid when sent to Codox's (generate-docs) function
  • The docs are not being generated properly, as if no source code exists
  • Tests were done with both absolute and various relative paths but did not produce results

Codox must be limiting itself internally to only the current module or build context's set of resources, either by a classloader or some other mechanism. Or additional functions need to be called since we are scripting around Codox

An alternate approach might be to setup a proper project.clj at the root, which can parse redundant info from the pom, and use that for the Codox declaration. Then using the Maven Exec Plugin we could invoke Leiningen to run the docs job (see compiling a leiningen project from maven for more on that). Here's an example of how the ring project does it.

Codox also supports markdown, so restoring it means any dependency analysis walkthroughs or "how-to" guides can also be published, linked, and referenced separately from GitHub.

Relevant links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.