Permalink
Browse files

Merge branch 'release/0.8.0-beta.2'

  • Loading branch information...
2 parents 8f7b11e + 0cee233 commit de238b69dd44734995f18c2350319d40764fc009 @hugoduncan hugoduncan committed Mar 16, 2013
View
@@ -1,3 +1,16 @@
-doc
-target
-logs
+/target
+/lib
+/classes
+/checkouts
+/logs
+/doc
+doc-src/VERSIONS.md
+doc-src/INTRO.md
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
+.lein-repl-history
View
@@ -10,33 +10,31 @@ See [tests](https://github.com/pallet/stevedore/tree/develop/test/pallet/stevedo
## Installation
stevedore is distributed as a jar, and is available in the
-[sonatype repository](http://oss.sonatype.org/content/repositories/releases/org/cloudhoist).
+[clojars repository](http://clojars.org/com.palletops/stevedore).
-Installation is with maven or your favourite maven repository aware build tool.
+Installation is with lein or your favourite maven repository aware build tool.
-### lein/cake project.clj
+### lein project.clj
```clj
-:dependencies [[org.cloudhoist/stevedore "0.8.0-beta.1"]]
-:repositories {"sonatype"
- "http://oss.sonatype.org/content/repositories/releases"}
+:dependencies [[com.palletops/stevedore "0.8.0-beta.2"]]
```
### maven pom.xml
```xml
<dependencies>
<dependency>
- <groupId>org.cloudhoist</groupId>
+ <groupId>com.palletops</groupId>
<artifactId>stevedore</artifactId>
- <version>0.8.0-beta.1</version>
+ <version>0.8.0-beta.2</version>
</dependency>
<dependencies>
<repositories>
<repository>
- <id>sonatype</id>
- <url>http://oss.sonatype.org/content/repositories/releases</url>
+ <id>clojars</id>
+ <url>http://clojars.org/repo</url>
</repository>
</repositories>
```
@@ -2,6 +2,14 @@
The latest stable release is 0.7.3.
+## 0.8.0-beta.2
+
+- Allow mulitple arguments to quote
+
+- Remove reflection warnings
+
+- Fix unquote splicing
+
## 0.8.0-beta.1
- Change groupID to com.palletops
View
@@ -11,4 +11,4 @@
{:plugins [[lein-set-version "0.2.1"]]
:set-version
{:updates [{:path "README.md" :no-snapshot true}]}}
- :clojure-1.5.0 {:dependencies [[org.clojure/clojure "1.5.0-RC15"]]}}
+ :clojure-1.5.0 {:dependencies [[org.clojure/clojure "1.5.1"]]}}
View
@@ -1,4 +1,4 @@
-(defproject com.palletops/stevedore "0.8.0-beta.1"
+(defproject com.palletops/stevedore "0.8.0-beta.2"
:description "Embeds shell script in clojure"
:url "http://palletops.com"
:license {:name "Eclipse Public License"
@@ -7,6 +7,6 @@
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/tools.logging "0.2.0"]
- [org.cloudhoist/pallet-common "0.3.1"]]
+ [com.palletops/pallet-common "0.4.0"]]
:profiles
{:dev {:dependencies [[ch.qos.logback/logback-classic "1.0.9"]]}})
@@ -68,7 +68,7 @@
- A function specialiser matches if it returns true when passed
`*script-context*`"
[specialiser]
- {:pre [*script-context* (seq *script-context*)]}
+ {:pre [(bound? #'*script-context*) *script-context* (seq *script-context*)]}
(cond
(keyword? specialiser) (some #(= specialiser %) *script-context*)
(set? specialiser) (some #(specialiser %) *script-context*)
@@ -188,7 +188,7 @@
;;
;; 4. A string results from the form.
-(defmulti emit
+(defmulti ^String emit
"Emit a shell expression as a string. Dispatched on the :type of the
expression."
(fn [ expr ] [*script-language* (type expr)]))
@@ -255,27 +255,24 @@
;; These are a set of splicing utility functions.
(def
- ^{:doc "The empty splice"}
- empty-splice
- ::empty-splice)
+ ^{:doc "A sequence to splice"}
+ splice-seq
+ ::splice)
-(defn- splice-list
- "Emit a collection as a space separated list.
- (splice-list [a b c]) => \"a b c\""
+(defn splice-list
+ "Mark a collection for splicing"
[coll]
- (if (seq coll)
- (string/join " " coll)
- ;; to maintain unquote splicing semantics, this term has to disappear
- ;; from the result
- empty-splice))
+ (list ::splice coll))
-(defn filter-empty-splice
+(defn splice-args
[args]
- (filter #(not= empty-splice %) args))
-
+ (mapcat
+ #(if (and (coll? %) (= ::splice (first %)))
+ (second %)
+ [%])
+ args))
;; Unquote/splicing handling utility functions.
-
(defn- unquote?
"Tests whether the form is (clj ...) or (unquote ...) or ~expr."
[form]
@@ -292,14 +289,8 @@
(defn- handle-unquote [form]
(second form))
-(declare emit)
-(defn splice [form]
- (if (seq form)
- (string/join " " (map emit form))
- empty-splice))
-
(defn- handle-unquote-splicing [form]
- (form-meta (list `splice (second form)) form))
+ (list `splice-list (second form)))
(def resolve-script-fns true)
@@ -311,18 +302,18 @@
functions. Applies inner to each element of form, building up a
data structure of the same type, then applies outer to the result.
Recognizes all Clojure data structures. Consumes seqs as with doall."
-
- {:added "1.1"}
[inner outer form]
- (tracef "walk %s %s" form (meta form))
+ (tracef "walk %s %s %s" form (meta form) (class form))
(cond
- (list? form) (outer (with-meta
- (if (and resolve-script-fns
- (symbol? (first form))
- (not (unresolved (first form))))
- (list* (first form) (map inner (rest form)))
- (list* (map inner form)))
- (meta form)))
+ (or (list? form) (instance? clojure.lang.Cons form))
+ (outer (with-meta
+ (if (and resolve-script-fns
+ (symbol? (first form))
+ (not (unresolved (symbol (name (first form))))))
+ (list* (first form) (map inner (rest form)))
+ (list* (map inner form)))
+ (meta form)))
+
(instance? clojure.lang.IMapEntry form) (outer (vec (map inner form)))
(seq? form) (outer (with-meta (doall (map inner form)) (meta form)))
(coll? form) (outer (with-meta
@@ -333,7 +324,7 @@
(declare inner-walk outer-walk)
(defn- inner-walk [form]
- (tracef "inner-walk %s %s" form (meta form))
+ (tracef "inner-walk %s %s" form (meta form) (class form))
(cond
(unquote? form) (handle-unquote form)
(unquote-splicing? form) (handle-unquote-splicing form)
@@ -343,12 +334,12 @@
:else (walk inner-walk outer-walk form)))
(defn- outer-walk [form]
- (tracef "outer-walk %s %s" form (meta form))
+ (tracef "outer-walk %s %s %s" form (meta form) (class form))
(cond
(symbol? form) (form-meta (list 'quote form) form)
(seq? form)
(do
- (tracef "outer-walk %s %s" form (meta form))
+ (tracef "outer-walk 2 %s %s %s" form (meta form) (class form))
(form-meta (list* `list form) form))
:else form))
@@ -378,7 +369,7 @@
(defn statement
"Emit an expression as a valid shell statement, with separator."
- [form script]
+ [form ^String script]
;; check the substring count, as it can be negative if there is a syntax issue
;; in a stevedore expression, and generates a cryptic error message otherwise
(let [n (- (count script) (count statement-separator))
@@ -390,28 +381,27 @@
statement-separator)
script)))
+(declare ^String emit)
+
(defn emit-do [exprs]
- (let [exprs (filter-empty-splice exprs)]
- (->> exprs
- (map emit)
- (map statement exprs)
- string/join)))
+ (->> exprs
+ (map emit)
+ (map statement exprs)
+ string/join))
(defn emit-script
[forms]
(tracef "emit-script %s" forms)
(tracef "emit-script metas %s" (vec (map meta forms)))
(let [code (if (> (count forms) 1)
- (emit-do (filter-empty-splice forms))
+ (emit-do forms)
(let [form (first forms)
m (meta form)]
- (if (= form empty-splice)
- ""
- (let [s (emit form)]
- (str
- (when (and m *src-line-comments* (not (string/blank? s)))
- (script-location-comment m))
- s)))))]
+ (let [s (emit form)]
+ (str
+ (when (and m *src-line-comments* (not (string/blank? s)))
+ (script-location-comment m))
+ s))))]
code))
;;; Script argument helpers
@@ -6,7 +6,7 @@
(:use
[pallet.stevedore.common]
[pallet.stevedore
- :only [emit emit-do empty-splice special-forms with-source-line-comments]]
+ :only [emit emit-do special-forms splice-seq with-source-line-comments]]
[pallet.common.string :only [quoted substring underscore]]))
(derive ::bash :pallet.stevedore.common/common-impl)
@@ -214,8 +214,8 @@
(defmethod emit-special [::bash 'str] [type [str & args]]
(apply clojure.core/str (map emit args)))
-(defmethod emit-special [::bash 'quoted] [type [quoted arg]]
- (common-string/quoted (emit arg)))
+(defmethod emit-special [::bash 'quoted] [type [quoted & args]]
+ (common-string/quoted (string/join " " (map emit args))))
(defmethod emit-special [::bash 'println] [type [println & args]]
(str "echo " (string/join " " (map emit args))))
@@ -262,9 +262,6 @@
;;(defmethod emit [::bash java.lang.Object] [expr]
;; (str expr))
-(defmethod emit [::bash empty-splice] [expr]
- "")
-
(defmethod emit [::bash clojure.lang.IPersistentVector] [expr]
(str (if *delimited-sequence* "(" "")
(string/join " " (map emit expr))
Oops, something went wrong. Retry.

0 comments on commit de238b6

Please sign in to comment.