Permalink
Browse files

Completed coffee-script support

  • Loading branch information...
1 parent 0725d78 commit 558dc3af44fe764938cd55b62e70d6ca459fdd80 Loren West committed Jan 7, 2012
View
@@ -1,3 +1,12 @@
+0.4.9 / 2012-01-06
+==================
+
+ * Added coffee-script file type support with extension .coffee
+ * Added an example coffee-script configuration file
+ * Added coffee-script module dependency
+ * Added a test for coffee-script configuration files
+ * Documented coffee-script support, regenerated documentation
+
0.4.8 / 2011-12-20
==================
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test 1-protected-test.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.71" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.71" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.5" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.5" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.71"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.71"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.5"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.5"></script>
</head>
<body id="node-monitor">
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test 2-config-test.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.71" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.71" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.5" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.5" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.71"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.71"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.5"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.5"></script>
</head>
<body id="node-monitor">
@@ -96,6 +96,10 @@
<span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">AnotherModule</span><span class="p">.</span><span class="nx">parm2</span><span class="p">,</span> <span class="s1">&#39;value2&#39;</span><span class="p">);</span>
<span class="p">},</span>
+ <span class="s1">&#39;Loading configurations from a Coffee-Script file is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">AnotherModule</span><span class="p">.</span><span class="nx">parm3</span><span class="p">,</span> <span class="s1">&#39;value3&#39;</span><span class="p">);</span>
+ <span class="p">},</span>
+
<span class="s1">&#39;Loading prior runtime.json configurations is correct&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">assert</span><span class="p">.</span><span class="nx">equal</span><span class="p">(</span><span class="nx">CONFIG</span><span class="p">.</span><span class="nx">Customers</span><span class="p">.</span><span class="nx">dbName</span><span class="p">,</span> <span class="s1">&#39;override_from_runtime_json&#39;</span><span class="p">);</span>
<span class="p">}</span>
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config Config </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.73" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.73" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.52" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.52" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.73"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.73"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.52"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.52"></script>
</head>
<body id="node-monitor">
@@ -533,7 +533,8 @@ <h3 id="methods">Methods</h3>
runtime.json
</pre>
<p>
-EXT can be yaml, json, or js signifying the file type. yaml is in YAML format,
+EXT can be yaml, coffee, json, or js signifying the file type.
+yaml is in YAML format, coffee is a coffee-script,
json is in strict JSON format, and js is a javascript executable file that is
require()'d with module.exports being the config object.
</p>
@@ -596,6 +597,7 @@ <h3 id="methods">Methods</h3>
The file extension determines the parser to use.
.js = File to run that has a module.exports containing the config object
.json = File is parsed using JSON.parse()
+.coffee = File to run that has a module.exports with coffee-script containing the config object
.yaml = Parsed with a YAML parser
If the file doesn't exist, a null will be returned.
If the file can't be parsed, an exception will be thrown.
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test ConfigTest </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.71" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.71" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.5" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.5" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.71"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.71"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.5"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.5"></script>
</head>
<body id="node-monitor">
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test ProtectedTest </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.71" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.71" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.5" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.5" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.71"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.71"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.5"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.5"></script>
</head>
<body id="node-monitor">
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config config.js </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.73" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.73" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.52" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.52" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.73"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.73"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.52"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.52"></script>
</head>
<body id="node-monitor">
@@ -50,6 +50,7 @@
<span class="kd">var</span> <span class="nx">Sys</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;sys&#39;</span><span class="p">),</span>
<span class="nx">File</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
<span class="nx">Yaml</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;yaml&#39;</span><span class="p">),</span>
+ <span class="nx">Coffee</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;coffee-script&#39;</span><span class="p">),</span>
<span class="nx">FileSystem</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">);</span>
<span class="c1">// Static members</span>
@@ -562,7 +563,8 @@
<span class="cm"> * &lt;/pre&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;p&gt;</span>
-<span class="cm"> * EXT can be yaml, json, or js signifying the file type. yaml is in YAML format,</span>
+<span class="cm"> * EXT can be yaml, coffee, json, or js signifying the file type.</span>
+<span class="cm"> * yaml is in YAML format, coffee is a coffee-script,</span>
<span class="cm"> * json is in strict JSON format, and js is a javascript executable file that is</span>
<span class="cm"> * require()&#39;d with module.exports being the config object.</span>
<span class="cm"> * &lt;/p&gt;</span>
@@ -610,7 +612,7 @@
<span class="c1">// Read each file in turn</span>
<span class="kd">var</span> <span class="nx">baseNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;default&#39;</span><span class="p">,</span> <span class="nx">hostName</span><span class="p">,</span> <span class="nx">deployment</span><span class="p">,</span> <span class="nx">hostName</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">deployment</span><span class="p">];</span>
- <span class="kd">var</span> <span class="nx">extNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;js&#39;</span><span class="p">,</span> <span class="s1">&#39;json&#39;</span><span class="p">,</span> <span class="s1">&#39;yaml&#39;</span><span class="p">];</span>
+ <span class="kd">var</span> <span class="nx">extNames</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;js&#39;</span><span class="p">,</span> <span class="s1">&#39;json&#39;</span><span class="p">,</span> <span class="s1">&#39;coffee&#39;</span><span class="p">,</span> <span class="s1">&#39;yaml&#39;</span><span class="p">];</span>
<span class="nx">baseNames</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">baseName</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">extNames</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">extName</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Try merging the config object into this object</span>
@@ -646,6 +648,7 @@
<span class="cm"> *</span>
<span class="cm"> * .js = File to run that has a module.exports containing the config object</span>
<span class="cm"> * .json = File is parsed using JSON.parse()</span>
+<span class="cm"> * .coffee = File to run that has a module.exports with coffee-script containing the config object</span>
<span class="cm"> * .yaml = Parsed with a YAML parser</span>
<span class="cm"> *</span>
<span class="cm"> * If the file doesn&#39;t exist, a null will be returned.</span>
@@ -702,6 +705,10 @@
<span class="c1">// Use the built-in parser for .js files</span>
<span class="nx">configObject</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="nx">fullFilename</span><span class="p">);</span>
<span class="p">}</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">extension</span> <span class="o">==</span> <span class="s1">&#39;coffee&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="c1">// Use the built-in parser for .coffee files with coffee-script</span>
+ <span class="nx">configObject</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="nx">fullFilename</span><span class="p">);</span>
+ <span class="p">}</span>
<span class="p">}</span>
<span class="k">catch</span> <span class="p">(</span><span class="nx">e3</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Cannot parse config file: &#39;&quot;</span> <span class="o">+</span> <span class="nx">fullFilename</span> <span class="o">+</span> <span class="s2">&quot;&#39;: &quot;</span> <span class="o">+</span> <span class="nx">e3</span><span class="p">);</span>
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title> </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.76" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.76" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.55" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.55" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.76"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.76"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.55"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.55"></script>
</head>
<body id="node-monitor">
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>config </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.73" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.73" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.52" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.52" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.73"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.73"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.52"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.52"></script>
</head>
<body id="node-monitor">
View
@@ -4,11 +4,11 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>test </title>
- <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1324374396.71" />
- <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1324374396.71" />
+ <link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1325918557.5" />
+ <link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1325918557.5" />
- <script type="text/javascript" src="assets/api-js?stamp=1324374396.71"></script>
- <script type="text/javascript" src="assets/ac-js?stamp=1324374396.71"></script>
+ <script type="text/javascript" src="assets/api-js?stamp=1325918557.5"></script>
+ <script type="text/javascript" src="assets/ac-js?stamp=1325918557.5"></script>
</head>
<body id="node-monitor">
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "config",
- "version": "0.4.8",
+ "version": "0.4.9",
"main": "./lib/config.js",
"description": "Configuration control for production node deployments",
"author": "Loren West <open_source@lorenwest.com>",

0 comments on commit 558dc3a

Please sign in to comment.