Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 06, 2012
@michaelklishin michaelklishin Make sure projects with artifact group id have valid namespaces in ge…
…nerated files
e06f0c0
@technomancy technomancy Merge pull request #21 from michaelklishin/namespaces-for-artifacts-w…
…ith-groups

Make sure projects with artifact group id have valid namespaces in generated files
45c386a
Showing with 13 additions and 2 deletions.
  1. +2 −2 src/leiningen/new/default.clj
  2. +11 −0 src/leiningen/new/templates.clj
View
4 src/leiningen/new/default.clj
@@ -1,12 +1,12 @@
(ns leiningen.new.default
"Generate a basic project."
- (:use [leiningen.new.templates :only [renderer sanitize year ->files]]))
+ (:use [leiningen.new.templates :only [renderer sanitize year ->files sanitize-ns]]))
(defn default
"A basic and general project layout."
[name]
(let [render (renderer "default")
- data {:name name
+ data {:name (sanitize-ns name)
:sanitized (sanitize name)
:year (year)}]
(println "Generating a project called" name "based on the 'default' template.")
View
11 src/leiningen/new/templates.clj
@@ -35,6 +35,17 @@
[s]
(string/replace s #"-" "_"))
+(defn sanitize-ns
+ "Returns project namespace name from (possibly group-qualified) project name:
+
+ mygroup/myproj => mygroup.myproj
+ myproj => myproj
+ mygroup/my_proj => mygroup.my-proj"
+ [^String s]
+ (-> s
+ (string/replace #"/" ".")
+ (string/replace #"_" "-")))
+
(defn year
"Get the current year. Useful for setting copyright years and such."
[] (+ (.getYear (java.util.Date.)) 1900))

No commit comments for this range

Something went wrong with that request. Please try again.