aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2008-04-08 21:01:06 +0000
committerscgilardi <scgilardi@gmail.com>2008-04-08 21:01:06 +0000
commitbc1168f898e80815f10507c7c48736100c3fd21d (patch)
tree5f204f7ed7806e988cf29c0c60d953d771b34dcc
parentcd182e004ada8f1d98bf789ccfb8a4a41b51ef67 (diff)
remove obsolete pkg.clj and loader.clj: please update to lib.clj
-rw-r--r--loader.clj93
-rw-r--r--pkg.clj128
2 files changed, 0 insertions, 221 deletions
diff --git a/loader.clj b/loader.clj
deleted file mode 100644
index 9870efc1..00000000
--- a/loader.clj
+++ /dev/null
@@ -1,93 +0,0 @@
-;; Copyright (c) Stephen C. Gilardi. All rights reserved.
-;; The use and distribution terms for this software are covered by the
-;; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-;; which can be found in the file CPL.TXT at the root of this distribution.
-;; By using this software in any fashion, you are agreeing to be bound by
-;; the terms of this license.
-;; You must not remove this notice, or any other, from this software.
-;;
-;; loader.clj
-;;
-;; scgilardi (gmail)
-;; 5 April 2008
-;;
-;; load-system-resource adapted from Stuart Sierra's public domain
-;; require.clj
-
-(clojure/in-ns 'loader)
-(clojure/refer 'clojure)
-
-;; Private
-
-(def
- #^{:doc "True when an ensure-ns call has requested a reload of all of its
- dependencies (:reload-all)"
- :private true}
- reloading-all false)
-
-(def
- #^{:doc "True when an ensure-ns call has requested that 'loaded' messages
- be printed after each load (:verbose)"
- :private true}
- loading-verbosely false)
-
-(defn- load-system-resource
- "Sequentially read and evaluate forms from a resource within classpath"
- [name]
- (let [url (. ClassLoader (getSystemResource name))]
- (when-not url
- (throw (new Exception (str "'" name "' not found in classpath"))))
- (if (= "file" (. url (getProtocol)))
- (load-file (. url (getFile)))
- (with-open reader (new java.io.BufferedReader
- (new java.io.InputStreamReader
- (. url (openStream))))
- (load reader)))))
-
-;; Public
-
-(defn ensure-ns
- "Ensures that a namespace is loaded. If it is not yet loaded, searches
- for an implementation file whose name is the namespace name followed by
- '.clj' and loads it. If no :from option is present, the search considers
- only the classpath roots. Options may include one each of:
-
- :from string
- :reload boolean
- :reload-all boolean
- :verbose boolean
-
- An argument to :from specifies a path to the implementation file's parent
- directory. An absolute path (beginning with '/') specifies a directory in
- the filesystem. A relative path specifies directories relative to each of
- the classpath roots.
- When :reload is true, the namespace will be reloaded if already loaded.
- When :reload-all is true, all directly and indirectly required namespaces
- are also reloaded.
- When :verbose is true, a 'loaded' message is printed after each load."
- [ns-sym & options]
- (let [opts (apply hash-map options)
- from (:from opts)
- reload (:reload opts)
- reload-all (:reload-all opts)
- verbose (:verbose opts)]
- (binding [reloading-all (or reloading-all reload-all)
- loading-verbosely (or loading-verbosely verbose)]
- (when (or (not (find-ns ns-sym)) reload reloading-all)
- (let [resource (str from (when from \/) ns-sym ".clj")]
- (if (= (first resource) \/)
- (load-file resource)
- (load-system-resource resource))
- (when loading-verbosely
- (println "loaded" resource))
- (when-not (find-ns ns-sym)
- (throw (new Exception (str "namespace '" ns-sym
- "' not found in '"
- resource "'")))))))))
-
-(defn require
- "Ensures that a namespace is loaded and then refers to it. Options may
- include options for ensure-ns and/or filters for refer."
- [ns-sym & options]
- (apply ensure-ns ns-sym options)
- (apply refer ns-sym options))
diff --git a/pkg.clj b/pkg.clj
deleted file mode 100644
index bbe4438b..00000000
--- a/pkg.clj
+++ /dev/null
@@ -1,128 +0,0 @@
-;; Copyright (c) Stephen C. Gilardi. All rights reserved.
-;; The use and distribution terms for this software are covered by the
-;; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-;; which can be found in the file CPL.TXT at the root of this distribution.
-;; By using this software in any fashion, you are agreeing to be bound by
-;; the terms of this license.
-;; You must not remove this notice, or any other, from this software.
-;;
-;; pkg.clj
-;;
-;; Clojure package loading and dependency via require/provide.
-;;
-;; A 'package' is a named set of capabilities represented by a symbol.
-;; The capabilities are usually defined in an implementation file
-;; somewhere in CLASSPATH whose name is the package name followed by
-;; ".clj". The implementation file may be in the filesystem, in a jar
-;; file, or at any other valid CLASSPATH URL.
-;;
-;; A call to 'require' indicates that subsequent code depends on
-;; capabilities provided by one or more packages and loads any of those
-;; packages that have not already been provided.
-;;
-;; A call to 'provide' records that a package's capabilities are loaded.
-;; By default this is done automatically when 'require' loads the
-;; package's implementation file. 'provide' is also available separately
-;; to allow flexibility in making a package's capabilities available by
-;; some means other than the default.
-;;
-;; pkg.clj provides variations of 'require' that:
-;;
-;; - require a package and automatically 'refer' to a namespace of the
-;; same name. This is for the common case of a package defining its
-;; own namespace which dependent code wants to use without namespace
-;; qualifiers. 'require-ns'
-;;
-;; - force the loading of all packages and dependencies regardless of
-;; whether they have already been provided. 'require-force'
-;;
-;; - both refer to the package's namespace and force a reload of the
-;; the package and its dependencies. 'require-ns-force'
-;;
-;; The "force" variations are useful during development.
-;;
-;; scgilardi (gmail)
-;; 2 April 2008
-;;
-;; load-resource adapted from Stuart Sierra's public domain require.clj
-
-(clojure/in-ns 'pkg)
-(clojure/refer 'clojure)
-
-;; Private
-
-(def
- #^{:doc "A ref to a set of symbols representing provided packages"
- :private true}
- *packages* (ref #{}))
-
-(defn- load-resource
- "Sequentially read and evaluate forms from a resource within CLASSPATH"
- [name]
- (let [url (. ClassLoader (getSystemResource name))]
- (when-not url
- (throw (new Exception (str \" name \" " not found in CLASSPATH"))))
- (if (= "file" (. url (getProtocol)))
- (load-file (. url (getFile)))
- (with-open reader (new java.io.BufferedReader
- (new java.io.InputStreamReader
- (. url (openStream))))
- (load reader)))))
-
-;; Public
-
-(defn packages
- "Returns a set of symbols representing provided packages"
- []
- @*packages*)
-
-(defn provided?
- "Returns true if package has been provided, else false"
- [package]
- (contains? @*packages* package))
-
-(defn provide
- "Marks a package as provided"
- [package]
- (dosync
- (commute *packages* conj package)
- nil))
-
-(defn require
- "Indicates that subsequent code depends on capabilities provided by
- the specified packages. Loads any of those packages that have not
- yet been provided."
- [& packages]
- (doseq package packages
- (when-not (provided? package)
- (let [resource (str package ".clj")]
- (load-resource resource)
- (provide package)))))
-
-(defn require-ns
- "Requires a package and then refers to the namespace of the same name
- with filters"
- [package & filters]
- (require package)
- (apply refer package filters))
-
-(defn require-force
- "Like 'require' but will reload packages (and their dependencies) that
- have already been provided"
- [& packages]
- (let [forced-packages
- (binding [*packages* (ref #{})]
- (apply require packages)
- @*packages*)]
- (dosync
- (commute *packages* set/union forced-packages)))
- nil)
-
-(defn require-ns-force
- "Like 'require-ns' but will reload packages (and their dependencies)
- that have already been provided"
- [package & filters]
- (require-force package)
- (apply refer package filters))
-
-(provide 'pkg)