Skip to content

Commit

Permalink
feat(projects): list projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephigenia committed Mar 26, 2018
1 parent 41b114d commit 0a32f3a
Show file tree
Hide file tree
Showing 9 changed files with 472 additions and 27 deletions.
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- insert issue number if this PR fixes one or multiple issues -->

- Fixes #

# Purpose

<!-- describe the purpose of the pull request. Include background information if necessary. -->

# Description of Change

<!-- Add a more detailed description on how and why this PR solves the issue or why the new feature should be added -->

# Todos

<!-- add a list of open things to clear up before the PR should be merged -->
118 changes: 118 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@
},
"main": "source/mite.js",
"scripts": {
"changelog": "conventional-changelog -s -i CHANGELOG.md -p angular -r 0",
"changelog:preview": "conventional-changelog --output-unreleased -p angular",
"changelog": "conventional-changelog -s -i CHANGELOG.md -p angular -r 0",
"commitmsg": "conventional-changelog-lint -e",
"lint": "eslint source/**/*.js",
"postversion": "git push && git push --tags",
"preversion": "npm test",
"start": "node $npm_package_main",
"test": "npm run lint",
"tdd": "npm run test -- --watch",
"test": "mocha --check-leaks --throw-deprecation --use_strict source/**/*test.js --exit",
"update": "npm-check --update",
"version": "npm run changelog && git add CHANGELOG.md",
"version:recommend": "conventional-recommended-bump --preset angular"
"version:recommend": "conventional-recommended-bump --preset angular",
"version": "npm run changelog && git add CHANGELOG.md"
},
"dependencies": {
"async": "^2.5.0",
Expand All @@ -67,11 +68,13 @@
"table": "^4.0.2"
},
"devDependencies": {
"chai": "^4.1.2",
"conventional-changelog-cli": "^1.3.13",
"conventional-changelog-lint": "^2.1.1",
"conventional-recommended-bump": "^2.0.4",
"eslint": "^4.17.0",
"husky": "^0.14.3",
"mocha": "^5.0.5",
"npm-check": "^5.5.2"
}
}
66 changes: 66 additions & 0 deletions source/lib/formater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';

const BUDGET_TYPE = {
MINUTES_PER_MONTH: 'minutes_per_month',
MINUTES: 'minutes',
CENTS: 'cents',
CENTS_PER_MONTH: 'cents_per_month',
};

const DEFAULT_CURRENCY = '€';

module.exports = {
BUDGET_TYPE: BUDGET_TYPE,

minutesToWorkDays(minutes) {
return this.number(minutes / 8 / 60, 2);
},

minutesToDuration(minutes) {
if (typeof minutes !== 'number') {
throw new TypeError('Expected minutes to be a of type Number');
} else if (isNaN(minutes)) {
throw new Error('Expected minutes to be a valid Number not NaN');
} else if (!isFinite(minutes)) {
throw new Error('Expecte minutes not to be a finite value.');
}
let hours = Math.floor(minutes / 60)
let remainingMinutes = Math.round(minutes - hours * 60);
if (String(remainingMinutes).length === 1) {
return hours + ':0' + remainingMinutes
}
return hours + ':' + remainingMinutes;
},

number(value, precision) {
if (typeof value !== 'number') {
throw new TypeError('Expected value to be a of type Number');
} else if (isNaN(value)) {
throw new Error('Expected value to be a valid Number not NaN');
} else if (!isFinite(value)) {
throw new Error('Expecte value not to be a finite value.');
}
precision = precision || 2;
return String(value.toFixed(precision));
},

price(value, precision) {
precision = precision || 2;
return String(value.toFixed(precision));
},

budget(type, value) {
switch(type) {
case BUDGET_TYPE.MINUTES_PER_MONTH:
return this.minutesToDuration(value) + ' h/m';
case BUDGET_TYPE.MINUTES:
return this.minutesToDuration(value) + ' h';
case BUDGET_TYPE.CENTS:
return this.price(value / 100) + ' ' + DEFAULT_CURRENCY;
case BUDGET_TYPE.CENTS_PER_MONTH:
return this.price(value / 100) + ' ' + DEFAULT_CURRENCY + '/m';
default:
throw new Error('Unknown budget format type: "' + type + '"');
}
}
}
Loading

0 comments on commit 0a32f3a

Please sign in to comment.