Permalink
Browse files

Add initial version of helper utilities

In this commit, implements an API as follow;
[Function] convert-from-document-file
  • Loading branch information...
1 parent f4c43d6 commit 846e6eb1450b07ffecf4d224ca770d28da92b474 @ichimal committed Sep 17, 2012
Showing with 118 additions and 1 deletion.
  1. +4 −0 .gitattributes
  2. +5 −0 .gitignore
  3. +20 −0 MIT-LICENSE.txt
  4. +18 −1 README.md
  5. +35 −0 asdf-project-helper.asd
  6. +36 −0 asdf-project-helper.lisp
View
@@ -0,0 +1,4 @@
+*.lisp eol=lf
+*.asd eol=lf
+*.txt eol=crlf
+*.md eol=crlf
View
@@ -0,0 +1,5 @@
+.??*.sw?
+*.sw?
+*.fas
+*.fasl
+TODO.txt
View
@@ -0,0 +1,20 @@
+Copyright (C) 2012 Shingo SUZUKI, https://github.com/ichimal/asdf-project-helper
+
+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.
View
@@ -1,4 +1,21 @@
asdf-project-helper
===================
-A project maintenance helper utilities with ASDF
+A project maintenance helper utilities with ASDF
+
+## API:
+
+### *[Function]* `CONVERT-FROM-DOCUMENT-FILE`:
+
+Read a document file (included in source tree of your project) into a string.
+
+e.g. `(convert-from-document-file "readme.txt" :systemname)`
+
+* You can specify file type with `:type` keyword to convert file format *(future work)*
+
+ Default file type is `:plain-text`.
+
+ e.g. `(convert-from-document-file "readme.md" :systemname :type :markdown)`
+
+## License:
+This project is under MIT license.
View
@@ -0,0 +1,35 @@
+(cl:in-package :cl-user)
+
+(defpackage #:asdf-project-helper-asd
+ (:use :cl :asdf) )
+
+(in-package #:asdf-project-helper-asd)
+
+(defsystem asdf-project-helper
+ :name "asdf-project-helper"
+ :version "0.0.1"
+ :maintainer "SUZUKI Shingo"
+ :author "SUZUKI Shingo"
+ :license "MIT"
+ :description "A project maintenance helper utilities with ASDF"
+ :components
+ ((:file "asdf-project-helper")) )
+
+#| ; for future work
+(defsystem asdf-project-helper-test
+ :depends-on (:asdf-project-helper :rt)
+ :components
+ ((:file "asdf-project-helper-test")) )
+
+(defmethod perform ((op test-op)
+ (component (eql (find-system :asdf-project-helper))) )
+ (declare (ignore op component))
+ (operate 'load-op :asdf-project-helper-test)
+ (operate 'test-op :asdf-project-helper-test :force t) )
+
+(defmethod perform ((op test-op)
+ (component (eql (find-system :asdf-project-helper-test))) )
+ (declare (ignore op component))
+ (funcall (intern (string '#:do-tests) :rt)) )
+|#
+
View
@@ -0,0 +1,36 @@
+(cl:in-package #:asdf-project-helper-asd)
+
+(defpackage :asdf-project-helper
+ (:nicknames :aph)
+ (:use :cl)
+ (:export #:convert-from-document-file ) )
+
+(require :asdf)
+
+(in-package :asdf-project-helper)
+
+(defgeneric convert-to-string (file-type ist ost))
+
+(defun convert-from-document-file (fname system
+ &key ((:type ftype) :plain-text))
+ (with-output-to-string (ost)
+ (with-open-file (ist (merge-pathnames
+ fname
+ (asdf:component-pathname (asdf:find-system system)))
+ :direction :input
+ :if-does-not-exist :error )
+ (convert-to-string ftype ist ost) )))
+
+(defmethod convert-to-string ((file-type (eql :plain-text))
+ (ist stream) (ost stream) )
+ (loop with eof = (gensym)
+ for line = (read-line ist nil eof)
+ until (eq line eof)
+ do (princ line ost) (terpri ost) )
+ t )
+
+(defmethod convert-to-string ((file-type (eql :markdown))
+ (ist stream) (ost stream) )
+ (warn "Currently not supported markdown conversion; read as plain text, instead")
+ (convert-to-string :plain-text ist ost) )
+

0 comments on commit 846e6eb

Please sign in to comment.