Create preset generators
This commit is contained in:
@@ -27,10 +27,9 @@
|
|||||||
(produce-items items nights i18n))))
|
(produce-items items nights i18n))))
|
||||||
|
|
||||||
(defn produce-all [store profile nights i18n]
|
(defn produce-all [store profile nights i18n]
|
||||||
(let [nights (util/ask-int (:nights? i18n))]
|
|
||||||
(->> store
|
(->> store
|
||||||
keys
|
keys
|
||||||
(map (fn [category] [category (filter #(.contains profile (:key %)) (get store category))]))
|
(map (fn [category] [category (filter #(.contains profile (:key %)) (get store category))]))
|
||||||
(filter #(not (empty? (second %))))
|
(filter #(not (empty? (second %))))
|
||||||
(map #(produce-category (first %) (second %) nights i18n))
|
(map #(produce-category (first %) (second %) nights i18n))
|
||||||
(clojure.string/join "\n\n"))))
|
(clojure.string/join "\n\n")))
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
(ns packer.database
|
(ns packer.database
|
||||||
(:use packer.model)
|
(:use packer.model)
|
||||||
(:require packer.i18n.pl)
|
(:require packer.i18n.pl)
|
||||||
|
(:require [packer.util :as util])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
; Choose language to Polish
|
; Choose language to Polish
|
||||||
@@ -19,9 +20,12 @@
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(defn simple-preset [question items seq]
|
||||||
|
(if (util/ask-bool question)
|
||||||
|
(concat seq items)
|
||||||
|
seq))
|
||||||
|
|
||||||
; Define profile getter
|
; Define profile getter
|
||||||
(defn get-profile []
|
(defn get-profile [nights]
|
||||||
(->> store
|
(->> [:t-shirt]
|
||||||
vals
|
(simple-preset "Bierzesz telefon?" [:smartphone])))
|
||||||
flatten
|
|
||||||
(map #(:key %))))
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
(ns packer.main
|
(ns packer.main
|
||||||
(:use packer.model)
|
(:use packer.model)
|
||||||
(:require packer.core packer.database)
|
(:require packer.core packer.database packer.util)
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& args]
|
[& args]
|
||||||
(println (packer.core/produce-all packer.database/store (packer.database/get-profile) 15 packer.database/i18n)))
|
(let [nights (packer.util/ask-int (:nights? packer.database/i18n))]
|
||||||
|
(println (packer.core/produce-all packer.database/store (packer.database/get-profile nights) nights packer.database/i18n))))
|
||||||
Reference in New Issue
Block a user