forked from ecukes/ecukes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecukes-new.el
73 lines (59 loc) · 2.25 KB
/
ecukes-new.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;;; ecukes-new.el --- Setup up Ecukes for a project
(require 'f)
(require 's)
(require 'dash)
(require 'ansi)
(require 'ecukes-template)
(defvar ecukes-new-features-path
(f-expand "features" default-directory))
(defvar ecukes-new-project-name
(f-filename default-directory))
(defun ecukes-new ()
"Create new Ecukes setup for project."
(if (ecukes-new-exists-p)
(error
(ansi-red "Ecukes already exists for this project"))
(ecukes-new-create-root)
(ecukes-new-create-step-definitions)
(ecukes-new-create-support)
(ecukes-new-create-feature)))
(defun ecukes-new-create-root ()
"Create features directory."
(f-mkdir ecukes-new-features-path)
(ecukes-new-message 0 "features"))
(defun ecukes-new-create-step-definitions ()
"Create step-definitions directory and step definition."
(let ((step-definitions-path (f-expand "step-definitions" ecukes-new-features-path)))
(f-mkdir step-definitions-path)
(ecukes-new-message 2 "step-definition")
(let ((step-definition
(f-expand (format "%s-steps.el" ecukes-new-project-name) step-definitions-path)))
(ecukes-template-write step-definition 'step-definition))
(ecukes-new-message 4 ecukes-new-project-name "-steps.el")))
(defun ecukes-new-create-support ()
"Create support directory."
(let ((support (f-expand "support" ecukes-new-features-path)))
(f-mkdir support)
(ecukes-new-message 2 "support")
(let ((env (f-expand "env.el" support)))
(ecukes-template-write env 'env `(("project-name" . ,ecukes-new-project-name)))))
(ecukes-new-message 4 "env.el"))
(defun ecukes-new-create-feature ()
"Create feature file."
(let ((feature
(f-expand
(format "%s.feature" ecukes-new-project-name) ecukes-new-features-path)))
(ecukes-template-write feature 'feature))
(ecukes-new-message 2 (format "%s.feature" ecukes-new-project-name)))
(defun ecukes-new-exists-p ()
"Check if there already exist an Ecukes setup."
(f-dir? ecukes-new-features-path))
(defun ecukes-new-message (indent &rest objects)
"Print message about created file."
(let ((ecukes-verbose t))
(message
"create%s%s"
(s-repeat (1+ indent) " ")
(ansi-green (apply 's-concat objects)))))
(provide 'ecukes-new)
;;; ecukes-new.el ends here