Reading your Project configuration
Information about our Clojure project is contained within our
project.clj file. We can read in this file and check the project information in that way.
slurp function reads in the contents of a file or content from a web page / URL.
Read the Clojure
project.cljfile using the
The output of slurping the project file should similar to the following
Tidy up the result of the
slurpvalue using the function
(read-string (slurp "project.clj"))
Just the project version
Really we just want to get the project version, not all the information. As a list is returned from
read-string then we can simply wrap a function around the first two functions to get the value we want
nth funtion takes the data structure as the first argument and the element number (starting from zero) as the second argument.
slurpto select the element we actually want.
(nth (read-string (slurp "project.clj")) 2)