| language: node_js | ||
| node_js: | ||
| - "0.11" | ||
| - "0.10" |
+1
-1
| /** | ||
| * Helper for loading from JavaScript. | ||
| */ | ||
| require('coffee-script'); | ||
| require('coffee-script/register'); | ||
| module.exports = require('./src'); |
+13
-14
| { | ||
| "name": "parfait", | ||
| "version": "0.2.1", | ||
| "version": "0.4.0", | ||
| "author": "David M. Lee, II <leedm777@yahoo.com>", | ||
@@ -10,6 +10,6 @@ "description": "A sweet multi-layered configuration framework", | ||
| "lint": "coffeelint src test", | ||
| "test": "_mocha", | ||
| "test-coverage": "COVERAGE=true _mocha -R html-cov 'test/**/*.spec.coffee' > out/coverage.html", | ||
| "test-coverage-json": "COVERAGE=true _mocha -R json-cov 'test/**/*.spec.coffee' > out/coverage.json", | ||
| "test-watch": "_mocha --watch --reporter min 'test/**/*.spec.coffee'" | ||
| "test": "mocha", | ||
| "test-coverage": "COVERAGE=true mocha -R html-cov 'test/**/*.spec.coffee' > coverage.html", | ||
| "test-coverage-json": "COVERAGE=true mocha -R json-cov 'test/**/*.spec.coffee' > coverage.json", | ||
| "test-watch": "mocha --watch --reporter min 'test/**/*.spec.coffee'" | ||
| }, | ||
@@ -24,16 +24,15 @@ "repository": { | ||
| "dependencies": { | ||
| "q": "^1.0.0", | ||
| "lodash": "^2.4.1", | ||
| "appdirs": "^0.1.1", | ||
| "coffee-script": "^1.7.1", | ||
| "es6-promise": "^0.1.1", | ||
| "js-yaml": "^3.0.1", | ||
| "appdirs": "^0.1.1", | ||
| "coffee-script": "^1.7.1" | ||
| "lodash": "^2.4.1" | ||
| }, | ||
| "devDependencies": { | ||
| "mocha": "^1.17.1", | ||
| "blanket": "^1.1.6", | ||
| "chai": "^1.9.0", | ||
| "blanket": "^1.1.6", | ||
| "chai-as-promised": "^4.1.0", | ||
| "mocha-as-promised": "^2.0.0", | ||
| "coffeelint": "^1.1.0", | ||
| "codo": "^2.0.6" | ||
| "codo": "^2.0.6", | ||
| "coffeelint": "^1.2.0", | ||
| "mocha": "^1.18.2" | ||
| }, | ||
@@ -40,0 +39,0 @@ "license": "MIT", |
+10
-7
| # Parfait.js | ||
| [](https://travis-ci.org/building5/parfaitjs) | ||
| A sweet multi-layered configuration framework. | ||
@@ -81,11 +83,12 @@ | ||
| 0. The hard-coded config provided to `configure()` | ||
| 1. ${config} directory | ||
| 2. ${config}/${environment}.env directory | ||
| 1. `${config}` directory | ||
| 2. `${config}/${environment}`.env directory | ||
| If appName (and appAuthor on Windows) is set: | ||
| 3. ${siteConfig} directory | ||
| 4. ${siteConfig}/${environment}.env directory | ||
| 5. ${userConfig} directory | ||
| 6. ${userConfig}/${environment}.env directory | ||
| If `appName` (and `appAuthor` on Windows) is set: | ||
| 3. `${siteConfig} directory` | ||
| 4. `${siteConfig}/${environment}.env` directory | ||
| 5. `${userConfig} directory` | ||
| 6. `${userConfig}/${environment}.env` directory | ||
| ## Examples | ||
@@ -92,0 +95,0 @@ |
+10
-9
| # Copyright (c) 2014. David M. Lee, II <leedm777@yahoo.com> | ||
| 'use strict' | ||
| Q = require 'q' | ||
| path = require 'path' | ||
| jsyaml = require 'js-yaml' | ||
| Promise = (require 'es6-promise').Promise | ||
| appdirsDefault = require 'appdirs' | ||
| confmerge = require './confmerge' | ||
| jsyaml = require 'js-yaml' | ||
| path = require 'path' | ||
@@ -19,3 +19,4 @@ {readFile, stat, readdir} = require './fs-promise' | ||
| @param {*} postConfig Config to merge on top of final result. | ||
| @param {appdirs} appdirs Methods `siteDataDir` and `userDataDir` for locating site and user data directories, respectively. | ||
| @param {appdirs} appdirs Methods `siteDataDir` and `userDataDir` for locating | ||
| site and user data directories, respectively. | ||
| @return {Promise<Object>} Consolidated configuration object. | ||
@@ -73,10 +74,10 @@ ### | ||
| if not directory | ||
| Q.fulfill baseConfig | ||
| Promise.resolve baseConfig | ||
| else | ||
| readdir directory | ||
| .then (dir) -> | ||
| Q.all dir.map (file) -> process(directory, file) | ||
| Promise.all dir.map (file) -> process(directory, file) | ||
| .then (res) -> | ||
| res.reduce confmerge, baseConfig | ||
| .fail (err) -> | ||
| .catch (err) -> | ||
| # Missing directories are fine; just return the base config | ||
@@ -86,3 +87,3 @@ if err.code != 'ENOENT' | ||
| throw err | ||
| Q.fulfill baseConfig | ||
| Promise.resolve baseConfig | ||
@@ -117,3 +118,3 @@ | ||
| # Environment; skip | ||
| Q.resolve {} | ||
| Promise.resolve {} | ||
| else | ||
@@ -120,0 +121,0 @@ stat file |
| # Copyright (c) 2014. David M. Lee, II <leedm777@yahoo.com> | ||
| 'use strict' | ||
| Promise = (require 'es6-promise').Promise | ||
| fs = require 'fs' | ||
| Q = require 'q' | ||
@@ -15,3 +15,8 @@ ### | ||
| readFile = (path) -> | ||
| Q.nfcall fs.readFile, path, 'utf-8' | ||
| new Promise (resolve, reject) -> | ||
| fs.readFile path, 'utf-8', (err, contents) -> | ||
| if (err) | ||
| reject err | ||
| else | ||
| resolve contents | ||
@@ -26,3 +31,8 @@ ### | ||
| stat = (path) -> | ||
| Q.nfcall fs.stat, path | ||
| new Promise (resolve, reject) -> | ||
| fs.stat path, (err, stat) -> | ||
| if (err) | ||
| reject err | ||
| else | ||
| resolve stat | ||
@@ -37,4 +47,9 @@ ### | ||
| readdir = (directory) -> | ||
| Q.nfcall fs.readdir, directory | ||
| new Promise (resolve, reject) -> | ||
| fs.readdir directory, (err, dir) -> | ||
| if (err) | ||
| reject err | ||
| else | ||
| resolve dir | ||
| module.exports = {readFile, stat, readdir} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectCodeStyleSettingsManager"> | ||
| <option name="PER_PROJECT_SETTINGS"> | ||
| <value> | ||
| <option name="OTHER_INDENT_OPTIONS"> | ||
| <value> | ||
| <option name="INDENT_SIZE" value="4" /> | ||
| <option name="CONTINUATION_INDENT_SIZE" value="8" /> | ||
| <option name="TAB_SIZE" value="8" /> | ||
| <option name="USE_TAB_CHARACTER" value="false" /> | ||
| <option name="SMART_TABS" value="false" /> | ||
| <option name="LABEL_INDENT_SIZE" value="0" /> | ||
| <option name="LABEL_INDENT_ABSOLUTE" value="false" /> | ||
| <option name="USE_RELATIVE_INDENTS" value="false" /> | ||
| </value> | ||
| </option> | ||
| <option name="RIGHT_MARGIN" value="80" /> | ||
| <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" /> | ||
| <option name="FORMATTER_TAGS_ENABLED" value="true" /> | ||
| <XML> | ||
| <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> | ||
| </XML> | ||
| <codeStyleSettings language="CoffeeScript"> | ||
| <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" /> | ||
| <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" /> | ||
| <indentOptions> | ||
| <option name="CONTINUATION_INDENT_SIZE" value="4" /> | ||
| <option name="TAB_SIZE" value="8" /> | ||
| </indentOptions> | ||
| </codeStyleSettings> | ||
| <codeStyleSettings language="JavaScript"> | ||
| <option name="KEEP_FIRST_COLUMN_COMMENT" value="false" /> | ||
| <option name="PARENTHESES_EXPRESSION_RPAREN_WRAP" value="true" /> | ||
| <option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" /> | ||
| <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" /> | ||
| <indentOptions> | ||
| <option name="INDENT_SIZE" value="2" /> | ||
| <option name="TAB_SIZE" value="8" /> | ||
| </indentOptions> | ||
| </codeStyleSettings> | ||
| </value> | ||
| </option> | ||
| <option name="USE_PER_PROJECT_SETTINGS" value="true" /> | ||
| <option name="PREFERRED_PROJECT_CODE_STYLE" value="dlee" /> | ||
| </component> | ||
| </project> | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="CompilerConfiguration"> | ||
| <option name="DEFAULT_COMPILER" value="Javac" /> | ||
| <resourceExtensions /> | ||
| <wildcardResourcePatterns> | ||
| <entry name="!?*.java" /> | ||
| <entry name="!?*.form" /> | ||
| <entry name="!?*.class" /> | ||
| <entry name="!?*.groovy" /> | ||
| <entry name="!?*.scala" /> | ||
| <entry name="!?*.flex" /> | ||
| <entry name="!?*.kt" /> | ||
| <entry name="!?*.clj" /> | ||
| </wildcardResourcePatterns> | ||
| <annotationProcessing> | ||
| <profile default="true" name="Default" enabled="false"> | ||
| <processorPath useClasspath="true" /> | ||
| </profile> | ||
| </annotationProcessing> | ||
| </component> | ||
| </project> | ||
| <component name="CopyrightManager"> | ||
| <copyright> | ||
| <option name="notice" value="Copyright (c) &#36;today.year. David M. Lee, II <leedm777@yahoo.com>" /> | ||
| <option name="keyword" value="Copyright" /> | ||
| <option name="allowReplaceKeyword" value="David M. Lee, II" /> | ||
| <option name="myName" value="dave" /> | ||
| <option name="myLocal" value="true" /> | ||
| </copyright> | ||
| </component> |
| <component name="CopyrightManager"> | ||
| <settings default="dave"> | ||
| <LanguageOptions name="__TEMPLATE__"> | ||
| <option name="addBlankAfter" value="false" /> | ||
| <option name="block" value="false" /> | ||
| </LanguageOptions> | ||
| </settings> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | ||
| </project> | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="JavaScriptLibraryMappings"> | ||
| <file url="file://$PROJECT_DIR$" libraries="{Node.js Dependencies for parfaitjs}" /> | ||
| <file url="PROJECT" libraries="{Node.js v0.10.26 Core Modules}" /> | ||
| <includedPredefinedLibrary name="Node.js Globals" /> | ||
| </component> | ||
| </project> | ||
| <component name="libraryTable"> | ||
| <library name="Node.js Dependencies for parfaitjs" type="javaScript"> | ||
| <properties> | ||
| <sourceFilesUrls> | ||
| <item url="file://$PROJECT_DIR$/node_modules" /> | ||
| </sourceFilesUrls> | ||
| </properties> | ||
| <CLASSES> | ||
| <root url="file://$PROJECT_DIR$/node_modules" /> | ||
| </CLASSES> | ||
| <JAVADOC /> | ||
| <SOURCES /> | ||
| </library> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="FrameworkDetectionExcludesConfiguration"> | ||
| <type id="JRUBY" /> | ||
| <type id="Python" /> | ||
| <type id="sass-stdlib" /> | ||
| </component> | ||
| <component name="IdProvider" IDEtalkID="20364A77574125419E815085C6DCB674" /> | ||
| <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true"> | ||
| <output url="file://$PROJECT_DIR$/out" /> | ||
| </component> | ||
| <component name="SbtLocalSettings"> | ||
| <option name="modificationStamps"> | ||
| <map> | ||
| <entry key="$PROJECT_DIR$/../dcs/usage-api-scala" value="1384793678000" /> | ||
| <entry key="$PROJECT_DIR$/../dlee/movie-hunt" value="1386049338000" /> | ||
| <entry key="$PROJECT_DIR$/../scala/close_wait" value="1384839252000" /> | ||
| </map> | ||
| </option> | ||
| </component> | ||
| </project> | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectModuleManager"> | ||
| <modules> | ||
| <module fileurl="file://$PROJECT_DIR$/parfaitjs.iml" filepath="$PROJECT_DIR$/parfaitjs.iml" /> | ||
| </modules> | ||
| </component> | ||
| </project> | ||
| <component name="DependencyValidationManager"> | ||
| <state> | ||
| <option name="SKIP_IMPORT_STATEMENTS" value="false" /> | ||
| </state> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="VcsDirectoryMappings"> | ||
| <mapping directory="" vcs="Git" /> | ||
| </component> | ||
| </project> | ||
Sorry, the diff of this file is not supported yet
| # Copyright (c) 2014. David M. Lee, II <leedm777@yahoo.com> | ||
| 'use strict' | ||
| if process.env.COVERAGE = 'true' | ||
| console.error 'Enabling code coverage' | ||
| require('blanket')() |
| # Copyright (c) 2014. David M. Lee, II <leedm777@yahoo.com> | ||
| 'use strict' | ||
| mocha = require 'mocha' | ||
| chai = require 'chai' | ||
| assert = chai.assert | ||
| expect = chai.expect | ||
| chaiAsPromised = require 'chai-as-promised' | ||
| Q = require 'q' | ||
| chai.Assertion.includeStack = true | ||
| chai.use chaiAsPromised | ||
| require('mocha-as-promised')() | ||
| require './bootstrap' | ||
| parfait = require '../src' | ||
| class MockAppDirs | ||
| constructor: (@basedir) -> | ||
| siteDataDir: (appName, appAuthor) -> | ||
| expect(appName).to.equal('someApp') | ||
| expect(appAuthor).to.equal('someAuthor') | ||
| "#{@basedir}/site" | ||
| userDataDir: (appName, appAuthor) -> | ||
| expect(appName).to.equal('someApp') | ||
| expect(appAuthor).to.equal('someAuthor') | ||
| "#{@basedir}/user" | ||
| describe 'For sample configs', -> | ||
| it 'should parse JSON', -> | ||
| expected = foo: bar: 'simple-json' | ||
| actual = parfait.configure { directory: 'test/simple-json.config' } | ||
| expect(actual).to.eventually.deep.equal expected | ||
| it 'should parse YAML', -> | ||
| expected = foo: bar: 'simple-yaml' | ||
| actual = parfait.configure { directory: 'test/simple-yaml.config' } | ||
| expect(actual).to.eventually.deep.equal expected | ||
| it 'should parse multi-file config', -> | ||
| expected = | ||
| foo: test: 'foo' | ||
| bar: test: 'bar' | ||
| actual = parfait.configure { directory: 'test/multi-file.config' } | ||
| expect(actual).to.eventually.deep.equal expected | ||
| it 'should parse subdir config', -> | ||
| expected = | ||
| foo: test: 'foo' | ||
| bar: bam: test: 'bam' | ||
| actual = parfait.configure { directory: 'test/subdir.config' } | ||
| expect(actual).to.eventually.deep.equal expected | ||
| it 'should parse site and user configs', -> | ||
| expected = | ||
| foo: | ||
| 'set-by-base': 'base' | ||
| 'set-by-user': 'user' | ||
| 'set-by-site': 'site' | ||
| parfait: | ||
| appName: 'someApp', | ||
| appAuthor: 'someAuthor' | ||
| actual = parfait.configure { | ||
| directory: 'test/site-user.config/base', | ||
| preConfig: | ||
| parfait: | ||
| appName: 'someApp', | ||
| appAuthor: 'someAuthor' | ||
| appdirs: new MockAppDirs('test/site-user.config') | ||
| } | ||
| expect(actual).to.eventually.deep.equal expected | ||
| it 'should parse environment configs', -> | ||
| expected = | ||
| foo: | ||
| 'set-by-base': 'base' | ||
| 'set-by-base-env': 'base-env' | ||
| 'set-by-user': 'user' | ||
| 'set-by-user-env': 'user-env' | ||
| 'set-by-site': 'site' | ||
| 'set-by-site-env': 'site-env' | ||
| parfait: | ||
| appName: 'someApp', | ||
| appAuthor: 'someAuthor' | ||
| actual = parfait.configure { | ||
| directory: 'test/env.config/base', | ||
| environment: 'test', | ||
| preConfig: | ||
| parfait: | ||
| appName: 'someApp', | ||
| appAuthor: 'someAuthor' | ||
| appdirs: new MockAppDirs('test/env.config') | ||
| } | ||
| expect(actual).to.eventually.deep.equal expected |
| set-by-base: base | ||
| set-by-base-env: base | ||
| set-by-user: base | ||
| set-by-user-env: base | ||
| set-by-site: base | ||
| set-by-site-env: base |
| set-by-base-env: base-env | ||
| set-by-user: base-env | ||
| set-by-user-env: base-env | ||
| set-by-site: base-env | ||
| set-by-site-env: base-env |
| set-by-user: site | ||
| set-by-user-env: site | ||
| set-by-site: site | ||
| set-by-site-env: site |
| set-by-user: site-env | ||
| set-by-user-env: site-env | ||
| set-by-site-env: site-env |
| set-by-user: user | ||
| set-by-user-env: user |
| set-by-user-env: user-env |
Sorry, the diff of this file is not supported yet
| test: bar |
| test: foo |
| { | ||
| "bar": "simple-json" | ||
| } |
| bar: simple-yaml |
| set-by-base: base | ||
| set-by-user: base | ||
| set-by-site: base |
| set-by-site: site | ||
| set-by-user: site |
| set-by-user: user |
| test: bam |
| test: foo |
Sorry, the diff of this file is not supported yet
6
-14.29%124
2.48%14223
-39.94%14
-68.89%48
-5.88%+ Added
+ Added
- Removed
- Removed