{"id":6527,"date":"2011-11-26T03:42:39","date_gmt":"2011-11-25T18:42:39","guid":{"rendered":"http:\/\/fukata.org\/?p=6527"},"modified":"2017-08-11T22:58:48","modified_gmt":"2017-08-11T22:58:48","slug":"clojure-clojure-config","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6527\/","title":{"rendered":"Clojure\u3067\u74b0\u5883\u5225\u8a2d\u5b9a\u306e\u5207\u308a\u5206\u3051\u3092\u884c\u3046\u300cclojure-config\u300d"},"content":{"rendered":"
YouSee\/clojure-config – GitHub<\/a><\/p>\n \u81ea\u5206\u3067json\u66f8\u3044\u3066\u3001\u30d1\u30fc\u30b9\u3057\u3066\u3063\u3066\u3084\u308c\u3070\u3001\u7c21\u5358\u306a\u7269\u306f\u3067\u304d\u308b\u306e\u3067\u3001\u4f5c\u3063\u3066\u3082\u826f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3060\u308b\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308b\u3060\u308d\u3046\u304b\u3089\u3001\u63a2\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3084\u3063\u3071\u308a\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n \u540d\u524d\u304c\u304b\u306a\u308a\u5206\u304b\u308a\u3065\u3089\u3044\u3067\u3059\u3051\u3069\u3001clojure-config\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<\/p>\n \u3053\u308c\u306f\u3001\u74b0\u5883\u8b58\u5225\u306e\u8a2d\u5b9a\u3092\u74b0\u5883\u5909\u6570\u300cENV\u300d\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u74b0\u5883\u8b58\u5225\u5b50\u3001\u30db\u30b9\u30c8\u540d\u307e\u305f\u306f\u30e6\u30fc\u30b6\u540d\u306b\u57fa\u3065\u3044\u3066\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n \u307e\u305a\u306f\u3001project.clj\u306b\u4e0b\u8a18\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n \u4f7f\u3044\u65b9\u306f\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u3067\u3001\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306bENV\u306b\u5404\u74b0\u5883\u306e\u8b58\u5225\u5b50\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n \u3053\u306e\u3001clojure-config\u3067\u3059\u304c\u3001:type\u306b”host”\u307e\u305f\u306f”user”\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001host\u306e\u5834\u5408\u306f\u5b9f\u884c\u74b0\u5883\u306e\u30db\u30b9\u30c8\u540d\u304c:value\u306e\u5024\u3068\u4e00\u81f4\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002\u540c\u3058\u3088\u3046\u306b:type\u306b”user”\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306b\u306f\u3001:value\u306e\u5024\u304c\u5b9f\u884c\u30e6\u30fc\u30b6\u540d\u3068\u4e00\u81f4\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" YouSee\/clojure-config – GitHub \u81ea\u5206\u3067json\u66f8\u3044\u3066\u3001\u30d1\u30fc\u30b9\u3057\u3066\u3063\u3066\u3084\u308c\u3070\u3001\u7c21\u5358\u306a\u7269\u306f\u3067\u304d\u308b\u306e\u3067\u3001\u4f5c\u3063\u3066\u3082\u826f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3060\u308b\u304b\u3063\u305f\u306e\u3067\u3001\u65e2\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042 … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[942],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6527"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=6527"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6527\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=6527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=6527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=6527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\r\n[clojure-config \"1.0.5\"]\r\n<\/pre>\n
\r\n(ns hoge.environment_test\r\n (:use clojure-config.core))\r\n\r\n(set-properties [\r\n ;; ===============================\r\n ;; GLOBAL Settings\r\n ;; ===============================\r\n {:name \"global\"\r\n :properties {:port 8080\r\n :db-name \"example_development\"\r\n :db-host \"localhost\"}}\r\n ;; ===============================\r\n ;; DEVELOPMENT Settings\r\n ;; ===============================\r\n {:name \"development\" :type \"user\" :value \"ubuntu\"}\r\n ;; ===============================\r\n ;; TEST Settings\r\n ;; ===============================\r\n {:name \"test\" \r\n :type \"user\" \r\n :value \"ubuntu\"\r\n :properties {:db-name \"example_test\"}}\r\n ;; ===============================\r\n ;; PRODUCTION Settings\r\n ;; ===============================\r\n {:name \"production\" \r\n :type \"user\" \r\n :value \"ubuntu\"\r\n :properties {:db-name \"example_production\"}}\r\n ;; ===============================\r\n ;; LOCAL Settings\r\n ;; ===============================\r\n {:name \"local\" :type \"user\" :value \"tatsuya\" :parent \"dev\"}])\r\n \r\n(defn -main []\r\n ;; \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5024\u3092\u30ad\u30fc\u3092\u57fa\u306b\u53d6\u5f97\r\n (println (property :db-name))\r\n ;; \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u30de\u30c3\u30d7\u3092\u53d6\u5f97\r\n (println (properties))\r\n<\/pre>\n
\r\n$ ENV=development lein run -m hoge.environment_test\r\n$ ENV=test lein run -m hoge.environment_test\r\n$ ENV=production lein run -m hoge.environment_test\r\n$ ENV=local lein run -m hoge.environment_test\r\n<\/pre>\n