}, function(err, instances) { if (err) throw err; var instance = _(instances).first(); var hash = {}; if (instance['PuppetClasses']) hash['classes'] = JSON.parse(instance['PuppetClasses']); if (instance['PuppetParameters']) hash['parameters'] = JSON.parse(instance['PuppetParameters']); if (instance['PuppetEnvironment']) hash['environment'] = instance['PuppetEnvironment']; console.log(yamlish.encode(hash)); });
ret += messages.map(function (el) { var severity = 'warning'; if (el.fatal || el.severity === 2) { severity = 'error'; } return '\nnot ok ' + (++total) + '\n ---' + yamlish.encode({ message: el.message.replace(/'/g, ''), severity: severity, file: result.filePath, line: el.line || 0, name: el.ruleId }) + '\n ...'; }).join('\n') + '\n';
function encodeResult (res, count, diag) { // console.error(res, count, diag) if (typeof res === "string") { res = res.split(/\r?\n/).map(function (l) { if (!l.trim()) return l.trim() return "# " + l }).join("\n") if (res.substr(-1) !== "\n") res += "\n" return res } if (res.bailout) return "" if (!!process.env.TAP_NODIAG) diag = false else if (!!process.env.TAP_DIAG) diag = true else if (diag === undefined) diag = !res.ok var output = "" res.name = res.name && ("" + res.name).trim() output += ( !res.ok ? "not " : "") + "ok " + count + ( !res.name ? "" : " " + res.name.replace(/[\r\n]/g, " ") ) + ( res.skip ? " # SKIP" : res.todo ? " # TODO" : "" ) + "\n" if (!diag) return output var d = {} , dc = 0 Object.keys(res).filter(function (k) { return k !== "ok" && k !== "name" && k !== "id" }).forEach(function (k) { dc ++ d[k] = res[k] }) //console.error(d, "about to encode") if (dc > 0) output += " ---"+yamlish.encode(d)+"\n ...\n" return output }
config.operations.forEach(function(method) { var result = { httpMethod: method, consumes: "application/json", produces: "application/json", protocols: "http", nickname: method.toLowerCase() + modelName, parameters: [] }; if (method === "PUT" || method === "DELETE") { var param = { name: "id", description: "The id of the element", dataType: "integer", paramType: "query", required: true }; result.parameters.push(param); } Object.keys(model.attributes).forEach(function(attribute) { var type = model.attributes[attribute].type; if (type === "array") { type = "string"; } else if (!type) { type = "foreignKey"; } if (model.descriptions) var desc = model.descriptions[attribute]; var param = { name: attribute, description: desc || "", dataType: type, paramType: "query" }; if (model.attributes[attribute].required && method === 'POST') param.required = model.attributes[attribute].required; if (model.attributes[attribute].unique) param.unique = model.attributes[attribute].unique; result.parameters.push(param); }); spec.apis[0].operations.push(result); // fs.writeFile(path.resolve(__dirname, outputFolder, modelName + ".json"), JSON.stringify(spec), function(err) { // if (err) throw err; // }); fs.writeFile(path.resolve(__dirname, '..', config.docsFolder, modelName + ".yml"), YAML.encode(spec), function(err) { if (err) throw err; }); });