Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added documentation and a couple tweaks

  • Loading branch information...
commit ec30f8b8fa50d520d87cde1e6e29e712a5e65f48 1 parent 9ebc969
@slagyr authored
View
2  .idea/vcs.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
- <mapping directory="" vcs="" />
+ <mapping directory="" vcs="Git" />
</component>
</project>
View
169 .idea/workspace.xml
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
- <list default="true" id="03642ea4-a265-4aa6-855d-576f3c2ddd52" name="Default" comment="" />
+ <list default="true" id="03642ea4-a265-4aa6-855d-576f3c2ddd52" name="Default" comment="">
+ <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/README.md" />
+ <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/example/console.clj" />
+ <change type="DELETED" beforePath="$PROJECT_DIR$/README" afterPath="" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/vcs.xml" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/project.clj" afterPath="$PROJECT_DIR$/project.clj" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/fresh/core.clj" afterPath="$PROJECT_DIR$/src/fresh/core.clj" />
+ </list>
<ignored path="fresh.iws" />
<ignored path=".idea/workspace.xml" />
<option name="TRACKING_ENABLED" value="true" />
@@ -59,19 +67,28 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="project.clj" pinned="false" current="false" current-in-tab="false">
+ <file leaf-file-name="project.clj" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/project.clj">
<provider selected="true" editor-type-id="text-editor">
- <state line="1" column="24" selection-start="50" selection-end="50" vertical-scroll-proportion="0.0">
+ <state line="0" column="24" selection-start="24" selection-end="24" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name=".gitignore" pinned="false" current="true" current-in-tab="true">
+ <file leaf-file-name=".gitignore" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="7" selection-start="32" selection-end="32" vertical-scroll-proportion="0.07373272">
+ <state line="5" column="0" selection-start="36" selection-end="36" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="README.md" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/README.md">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="105" column="33" selection-start="4364" selection-end="4364" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -89,7 +106,25 @@
<file leaf-file-name="core.clj" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/fresh/core.clj">
<provider selected="true" editor-type-id="text-editor">
- <state line="201" column="52" selection-start="8042" selection-end="8042" vertical-scroll-proportion="0.0">
+ <state line="22" column="51" selection-start="800" selection-end="800" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="console.clj" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/example/console.clj">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="30" column="2" selection-start="664" selection-end="664" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="timed.clj" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/example/timed.clj">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="668" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -102,14 +137,23 @@
<setting name="OPEN_NEW_TAB" value="false" />
</FindUsagesManager>
</component>
+ <component name="Git.Settings">
+ <option name="CHECKOUT_INCLUDE_TAGS" value="false" />
+ <option name="UPDATE_CHANGES_POLICY" value="STASH" />
+ </component>
<component name="IdeDocumentHistory">
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/LICENSE" />
<option value="$PROJECT_DIR$/spec/fresh/core_spec.clj" />
+ <option value="$PROJECT_DIR$/.gitignore" />
+ <option value="$PROJECT_DIR$/example/one.clj" />
+ <option value="$PROJECT_DIR$/example/two.clj" />
+ <option value="$PROJECT_DIR$/example/console.clj" />
<option value="$PROJECT_DIR$/src/fresh/core.clj" />
+ <option value="$PROJECT_DIR$/example/timed.clj" />
+ <option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/project.clj" />
- <option value="$PROJECT_DIR$/.gitignore" />
</list>
</option>
</component>
@@ -201,6 +245,34 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="fresh" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="fresh" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="lib" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="fresh" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="fresh" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="example" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
</subPane>
</pane>
<pane id="Favorites" />
@@ -222,6 +294,20 @@
<property name="MemberChooser.copyJavadoc" value="false" />
</component>
<component name="RunManager" selected="Application.Spec Vigilance">
+ <configuration default="true" type="ClojureScriptRunConfiguration" factoryName="Clojure Script">
+ <module name="" />
+ <setting name="path" value="" />
+ <setting name="vmparams" value="" />
+ <setting name="params" value="" />
+ <setting name="workDir" value="" />
+ <setting name="repl" value="false" />
+ <method>
+ <option name="AntTarget" enabled="false" />
+ <option name="BuildArtifacts" enabled="false" />
+ <option name="Make" enabled="true" />
+ <option name="Maven.BeforeRunTask" enabled="false" />
+ </method>
+ </configuration>
<configuration default="true" type="Remote" factoryName="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true" />
<option name="SERVER_MODE" value="false" />
@@ -350,28 +436,28 @@
<frame x="0" y="22" width="1920" height="1174" extended-state="6" />
<editor active="true" />
<layout>
- <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
- <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
+ <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
+ <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
+ <window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
- <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.18589744" sideWeight="0.6451613" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3548387" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
- <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
- <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
+ <window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3548387" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
+ <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
- <window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
- <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
- <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+ <window_info id="EJB" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
+ <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
+ <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsManagerConfiguration">
@@ -424,23 +510,44 @@
</state>
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/.gitignore">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="5" column="0" selection-start="36" selection-end="36" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
<entry file="file://$PROJECT_DIR$/src/fresh/core.clj">
<provider selected="true" editor-type-id="text-editor">
- <state line="201" column="52" selection-start="8042" selection-end="8042" vertical-scroll-proportion="0.0">
+ <state line="22" column="51" selection-start="800" selection-end="800" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/project.clj">
+ <entry file="file://$PROJECT_DIR$/example/console.clj">
<provider selected="true" editor-type-id="text-editor">
- <state line="1" column="24" selection-start="50" selection-end="50" vertical-scroll-proportion="0.0">
+ <state line="30" column="2" selection-start="664" selection-end="664" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
+ <entry file="file://$PROJECT_DIR$/example/timed.clj">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="0" selection-start="0" selection-end="668" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/README.md">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="105" column="33" selection-start="4364" selection-end="4364" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/project.clj">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="7" selection-start="32" selection-end="32" vertical-scroll-proportion="0.07373272">
+ <state line="0" column="24" selection-start="24" selection-end="24" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
View
13 README
@@ -1,13 +0,0 @@
-# fresh
-
-FIXME: write description
-
-## Usage
-
-FIXME: write
-
-## License
-
-Copyright (C) 2010 FIXME
-
-Distributed under the Eclipse Public License, the same as Clojure.
View
106 README.md
@@ -0,0 +1,106 @@
+# fresh
+### A library to keep your clojure runtime 'Fresh' ###
+
+## About
+
+Clojure's dynamic nature allows you to add definitions or even change existing definition in a live runtime.
+It's brilliant and powerful. Yet, to do so you typically have to run in the REPL and it can become a tedious task
+to reload files with every change you make, not to mention the dependencies of changes you make.
+
+Fresh simplifies it all. The source code was extracted from [Speclj's][https://github.com/slagyr/speclj] vigilant runner
+(autotest) because of it's usefulness. Simply tell Fresh which source code you want to keep fresh and it'll take care
+of the rest for you.
+
+## Usage
+
+The primary function is `freshener`.
+
+ user=> (doc freshener)
+ -------------------------
+ fresh.core/freshener
+ ([provider] [provider auditor])
+ Returns a freshener function that, when invoked, will ensure
+ the freshness of all files provided by the provider function.
+ The provider must be a no-arg function that returns a seq of java.io.File
+ objects. If any of the files have been modified, they (and all
+ thier dependent files), will be reloaded. New files will be loaded and
+ tracked. Deleted files will be unloaded along with any dependant files
+ that are no longer referenced. The freshener function returns a report map
+ of seqs containings File objects: {:new :modified :deleted :reloaded}.
+ The optional auditor function is called, passing in the report map,
+ before the state of the runtime has been modified. Only when the auditor
+ returns a truthy value will the runtime be modified.
+
+## Examples
+
+### Example #1
+
+Below is a script that will reload all the Clojure source files in the src and spec directories. It sits in an infinite
+loop on the console waiting for you to press Enter. Each time you press Enter, it printes a report and reloads. Simple!
+
+ (ns console
+ (:use
+ [fresh.core :only (clj-files-in freshener)]
+ [clojure.java.io :only (file)]))
+
+ (defn files-to-keep-fresh []
+ (clj-files-in (file "src") (file "spec")))
+
+ (defn report-refresh [report]
+ (println "Refreshing...")
+ (println "(:new report): " (:new report))
+ (println "(:modified report): " (:modified report))
+ (println "(:deleted report): " (:deleted report))
+ (println "(:reloaded report): " (:reloaded report))
+ (println "")
+ true)
+
+ (def refresh-src (freshener files-to-keep-fresh report-refresh))
+
+ (loop [key nil]
+ (refresh-src)
+ (println "Press any RETURN to reload, CTR-C to quit.")
+ (recur (.read System/in)))
+
+Assuming you have the Fresh source code checked out on your filesystem you can execute this command like so:
+
+ $ java -cp src:spec:lib/clojure-1.2.0.jar:lib/dev/speclj-1.2.0.jar:path/to/fresh/src clojure.main path/to/fresh/example/console.clj
+
+### Example #2
+
+This example show two new techniques. First notice how it produces a list of all the Clojure source files currently
+loaded in the runtime. Second, it uses the `ScheduledThreadPoolExecutor` to refresh every second. Reloaded files
+are printed.
+
+ (ns timed
+ (:use
+ [fresh.core :only (ns-to-file freshener)])
+ (:import
+ [java.util.concurrent ScheduledThreadPoolExecutor TimeUnit]))
+
+ (defn files-to-keep-fresh []
+ (filter identity (map #(ns-to-file (.name %)) (all-ns))))
+
+ (defn report-refresh [report]
+ (when-let [reloaded (seq (:reloaded report))]
+ (println "Refreshing...")
+ (doseq [file reloaded] (println file))
+ (println ""))
+ true)
+
+ (def refresh! (freshener files-to-keep-fresh report-refresh))
+ (refresh!)
+ (def scheduler (ScheduledThreadPoolExecutor. 1))
+ (.scheduleWithFixedDelay scheduler refresh! 0 1000 TimeUnit/MILLISECONDS)
+ (.awaitTermination scheduler Long/MAX_VALUE TimeUnit/SECONDS)
+
+Now typically, you might include similar code in your dev environment. This script, nor Example #1, are very useful
+by them selves. But to make this script interesting we'll have to load some of our code using the -i option.
+
+ java -cp src:spec:lib/clojure-1.2.0.jar:lib/dev/speclj-1.2.0.jar:path/to/fresh/src clojure.main -i spec/your_package/core.clj path/to/fresh/example/timed.clj
+
+## License
+
+Copyright (C) 2011 Micah Martin All Rights Reserved.
+
+Distributed under the The MIT License.
View
30 example/console.clj
@@ -0,0 +1,30 @@
+(ns console
+ (:use
+ [fresh.core :only (clj-files-in freshener)]
+ [clojure.java.io :only (file)]))
+
+(defn files-to-keep-fresh []
+ (clj-files-in (file "src") (file "spec")))
+
+(defn report-refresh [report]
+ (println "Refreshing...")
+ (println "(:new report): " (:new report))
+ (println "(:modified report): " (:modified report))
+ (println "(:deleted report): " (:deleted report))
+ (println "(:reloaded report): " (:reloaded report))
+ (println "")
+ true)
+
+(def refresh-src (freshener files-to-keep-fresh report-refresh))
+
+(loop [key nil]
+ (refresh-src)
+ (println "Press any RETURN to reload, CTR-C to quit.")
+ (recur (.read System/in)))
+
+
+
+
+
+
+
View
21 example/timed.clj
@@ -0,0 +1,21 @@
+(ns timed
+ (:use
+ [fresh.core :only (ns-to-file freshener)])
+ (:import
+ [java.util.concurrent ScheduledThreadPoolExecutor TimeUnit]))
+
+(defn files-to-keep-fresh []
+ (filter identity (map #(ns-to-file (.name %)) (all-ns))))
+
+(defn report-refresh [report]
+ (when-let [reloaded (seq (:reloaded report))]
+ (println "Refreshing...")
+ (doseq [file reloaded] (println file))
+ (println ""))
+ true)
+
+(def refresh! (freshener files-to-keep-fresh report-refresh))
+(refresh!)
+(def scheduler (ScheduledThreadPoolExecutor. 1))
+(.scheduleWithFixedDelay scheduler refresh! 0 1000 TimeUnit/MILLISECONDS)
+(.awaitTermination scheduler Long/MAX_VALUE TimeUnit/SECONDS)
View
2  project.clj
@@ -1,4 +1,4 @@
-(defproject fresh "1.0.0"
+(defproject fresh "1.0.1"
:description "A library to keep your clojure runtime 'Fresh'."
:dependencies [[org.clojure/clojure "1.2.0"]]
:dev-dependencies [[speclj "1.2.0"]
View
6 src/fresh/core.clj
@@ -10,8 +10,10 @@
(defn clj-files-in
"Returns a seq of all clojure source files contained in the given directories."
[& dirs]
- (let [files (reduce #(into %1 (file-seq (file %2))) [] dirs)]
- (filter #(re-matches clj-file-regex (.getName %)) files)))
+ (let [dirs (map #(.getCanonicalFile %) dirs)
+ files (reduce #(into %1 (file-seq (file %2))) [] dirs)
+ clj-files (filter #(re-matches clj-file-regex (.getName %)) files)]
+ clj-files))
;; Resolving ns names ---------------------------------------------------------------------------------------------------
;
Please sign in to comment.
Something went wrong with that request. Please try again.