Comparing version 0.5.0 to 0.6.4
"use strict"; | ||
// This is an example file to show how to use the library | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,5 +7,3 @@ // We are goin to make a report on an algorithm that takes three indiviuals with their ages, and a salary table. We are going to determine how much money each of them makes, and how much they make together. | ||
const __1 = require(".."); | ||
const path_1 = __importDefault(require("path")); | ||
const fileNameWithoutExt = path_1.default.basename(__filename, path_1.default.extname(__filename)); | ||
const mdPath = path_1.default.join('src/example', `${fileNameWithoutExt}.md`); | ||
const mdPath = 'src/example/simple.md'; | ||
// We need to instantiate a DocuPorter object with the path to the markdown file where we want to write the report | ||
@@ -15,0 +10,0 @@ const rep = new __1.DocuPorter(mdPath); |
@@ -6,2 +6,3 @@ export declare class DocuPorter { | ||
private conditions; | ||
private ticket; | ||
constructor(fileName: string); | ||
@@ -31,2 +32,3 @@ reset(): void; | ||
unMute(): void; | ||
private isNoisy; | ||
setValue(key: string, value: string): void; | ||
@@ -40,2 +42,6 @@ setValues(values: Record<string, string>): void; | ||
clearConditions(): void; | ||
addTicket(ticket: string): void; | ||
useTicket(ticket: string): void; | ||
finishTicket(ticket: string): void; | ||
private anyTicketOngoing; | ||
} |
@@ -29,2 +29,8 @@ "use strict"; | ||
const fs = __importStar(require("fs")); | ||
var TicketState; | ||
(function (TicketState) { | ||
TicketState[TicketState["New"] = 0] = "New"; | ||
TicketState[TicketState["InProgress"] = 1] = "InProgress"; | ||
TicketState[TicketState["Used"] = 2] = "Used"; | ||
})(TicketState || (TicketState = {})); | ||
class DocuPorter { | ||
@@ -35,2 +41,3 @@ constructor(fileName) { | ||
this.conditions = new Map(); | ||
this.ticket = new Map(); | ||
this.text = this.appendText; | ||
@@ -53,3 +60,3 @@ this.json = this.appendJson; | ||
append(text) { | ||
if (this.valuesMatch() && !this.muted) { | ||
if (this.isNoisy()) { | ||
fs.appendFileSync(this.filePath, `\n${text}`); | ||
@@ -89,3 +96,3 @@ } | ||
log(...args) { | ||
if (this.valuesMatch() && !this.muted) { | ||
if (this.isNoisy()) { | ||
console.log(...args); | ||
@@ -100,2 +107,5 @@ } | ||
} | ||
isNoisy() { | ||
return this.anyTicketOngoing() || (this.valuesMatch() && !this.muted); | ||
} | ||
setValue(key, value) { | ||
@@ -125,3 +135,15 @@ this.values.set(key, value); | ||
} | ||
addTicket(ticket) { | ||
this.ticket.set(ticket, TicketState.New); | ||
} | ||
useTicket(ticket) { | ||
this.ticket.set(ticket, TicketState.InProgress); | ||
} | ||
finishTicket(ticket) { | ||
this.ticket.set(ticket, TicketState.Used); | ||
} | ||
anyTicketOngoing() { | ||
return Array.from(this.ticket.values()).some(state => state === TicketState.InProgress); | ||
} | ||
} | ||
exports.DocuPorter = DocuPorter; |
{ | ||
"name": "docuporter", | ||
"version": "0.5.0", | ||
"version": "0.6.4", | ||
"description": "Understand a file by documenting it in a markdown file", | ||
@@ -13,3 +13,4 @@ "main": "dist/index.js", | ||
"build": "tsc", | ||
"example:simple": "ts-node src/example/simple.ts" | ||
"example:simple": "ts-node src/example/simple.ts", | ||
"ci": "npm install && npm run build" | ||
}, | ||
@@ -16,0 +17,0 @@ "author": "FrBosquet", |
11571
6
269