Giter Site home page Giter Site logo

abio's Introduction

Abio

A set of host abstractions mimicking similar facilities available in Clojure for I/O, shell access, etc., along with mechanisms to bind the abstractions to host-specific implementations.

Architectural Design

  1. Use a dynamic variable that is referenced throughout the library. This holds the host implementations and makes using them straightforward
  2. Define Protocols for Reading/Writing/Streaming
  3. Define a Bindings protocol for creating and interacting with the host implementation to construct the records that implement the R/W/S protocols from #2
  4. Define helper functions to tie into the host implementation

Usage

See the examples directory in the Node bindings implementation.

$ lumo -qc abio.jar:abio-node.jar
cljs.user=> (require 'abio.core '[abio.io :as io] 'abio.node)
nil
cljs.user=> (abio.core/set-bindings! (abio.node/bindings))
nil
cljs.user=> (def users-dir (io/as-file "/Users"))
#'cljs.user/users-dir
cljs.user=> users-dir
#abio.io.File{:path "/Users"}
cljs.user=> (io/directory? users-dir)
true
cljs.user=> (io/directory? "/etc/hosts")
false
cljs.user=> (def r (io/reader "/usr/share/dict/words" :encoding "UTF8"))
#'cljs.user/r
cljs.user=> (take 8 (io/line-seq r))
("A" "a" "aa" "aal" "aalii" "aam" "Aani" "aardvark")

License

Copyright © 2017 abiocljs and Contributors

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

abio's People

Contributors

arichiardi avatar futuro avatar mfikes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

abio's Issues

Roadmap to the first release

Hey @mfikes,

As I've been working on asynchronous IO over at https://github.com/futuro/abio/tree/async-io I've
been starting to think about this from a higher level, and I'm interested in your thoughts on what a
v1 might look like for abio.

I've put the list in rough order of importance to immediate usability, and it ignores shell
abstraction for the moment, focusing specifically on abio.io.

Reading/Writing Data

  • Reading from a file
    • Synchronous
      • Buffered
      • Unbuffered
    • Asynchronous
      • Buffered
      • Unbuffered
  • Writing to a file
    • Synchronous
      • Buffered
      • Unbuffered
    • Asynchronous
      • Buffered
      • Unbuffered
  • Streaming
    • Input streams
      • Synchronous
        • Buffered
        • Unbuffered
      • Asynchronous
        • Buffered
        • Unbuffered
    • Output Streams
      • Synchronous
        • Buffered
        • Unbuffered
      • Asynchronous
        • Buffered
        • Unbuffered
    • Duplex Streams
      • Reading
        • Synchronous
          • Buffered
          • Unbuffered
        • Asynchronous
          • Buffered
          • Unbuffered
      • Writing
        • Synchronous
          • Buffered
          • Unbuffered
        • Asynchronous
          • Buffered
          • Unbuffered

Pushing files around

  • Rename
  • Move
  • Copy
  • Delete

Making files

  • Make a directory
  • Make a link
  • Make a temp directory

General

  • stating a file
  • List files in a directory

Altering metadata

  • Change owner
  • Change group
  • Change mode/perms
  • Change timestamps

I originally started work on this in tandem with a fork of abio-node, but I wanted to sanity check
things before I went too far down the rabbit hole in implementation.

Does this look pretty sane?

EDIT: Fixed list format

Directory? throws on non-existing path

Hi folks, we started to use this lib here and noticed that directory? throws when the path is missing if the underlying implementation throws.

I was wondering whether we should catch and return false instead so that we keep the predicate behavior correct.

Add exists? to IBindings protocol

Hi folks!

This is a great addition to the mix IMHO.

It goes hand in hand with directory?.

At this point we are though a bit deviating from clojure.java.io, which relies on interoffice for that.

I guess it is kind of fine in this case?

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.