adamocomp/README.md
2020-05-21 08:08:44 -04:00

1.9 KiB

Adamocomp Data Parser

This library provides methods to interpret the adamocomp data file.

Example Usage

const Parser = require('adamocomp/parser.js');

var parser = new Parser();

parser.get.data('gitlab repo').then(function(data){
 // "data" contains all data for the gitlab deal
})

parser.get_formatted.data('gitlab repo').then(function(printable){
   // Standard output as stringified json.
   console.log(printable)
})

// parser.get_formatted.root('gitlab').then(function(str){
//   console.log(str)
// }
// Output below
node data_tool.js path "gitlab"
# ["gitlab"]

Constructor Options

  • new Parser({options})
property type description default
path string Path to data file ${program_root}/data.json

Methods

get.file()

Type: async

Params: none

Returns: an object literal of the data file.

parser.get.file().then(function(file){
   // 'file' is the entire data file
})

get.data(string)

Type: async

param type description
1 string search string

Returns: data tree underneath node corresponding to search string, if found, otherwise null.

parser.get.data(str).then(function(data){
   console.log(JSON.stringify(data));
})

get.root(string)

Type: async

param type description
1 string search string

Returns: array of keys (directories) leading to deal, if found, or an empty array.

parser.get.root(str).then(function(nodes){
   console.log(locations);
   // ['gitlab']
})

get.list()

Type: async

Params: none

Returns: array of all deployments in the environment.

parser.get.list().then(function(deployments){
   console.log(location);
   // ['gitlab', 'factorio/clusterio_host', 'factorio/factorio_host', etc.]
})

Running Tests

npm test