Skip to content

Commit 4e0b343

Browse files
committed
Merge branch 'develop'
2 parents 99af4cc + 7452e3d commit 4e0b343

19 files changed

+495
-84
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dist: trusty
22
sudo: false
33
language: node_js
44
node_js:
5-
- 6.9.2
5+
- 6.9.4
66
addons:
77
apt:
88
sources:
@@ -16,8 +16,8 @@ before_install:
1616
- "./tools/travis/install-geckodriver"
1717
- "./tools/travis/start-xvfb"
1818
- ". ./tools/travis/env.sh"
19-
- export DISPLAY=$ENV_DISPLAY
20-
- export PATH=$PATH:$ENV_LOCAL_BIN_DIR
19+
- export DISPLAY=$DSJS_DISPLAY
20+
- export PATH=$PATH:$DSJS_LOCAL_BIN_DIR
2121
install:
2222
- npm install --global gulp-cli
2323
- npm install

features/server/evaluate-expression/enumerating_die_rolls.feature

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Scenario Outline: Enumerating die rolls
2323
| 1+1 | [] |
2424
| 1d6+1 | [{"sides": 6, "value": 6}] |
2525
| 2d6+1d4 | [{"sides": 6, "value": 6}, {"sides": 6, "value": 6}, {"sides": 4, "value": 4}] |
26+
| d% | [{"sides": 10, "value": 10}, {"sides": 10, "value": 10}] |

features/server/evaluate-expression/evaluating_dice_notation.feature

+26-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,21 @@ Scenario Outline: Evaluating dice rolls
9797
| expression | result text | result value |
9898
| 3d6 | [sum([roll(3, d6) -> [6, 6, 6]]) -> 18] | 18 |
9999
| 1d10 | [sum([roll(1, d10) -> [10]]) -> 10] | 10 |
100-
| 1d% | [sum([roll(1, d100) -> [100]]) -> 100] | 100 |
101100
| sum(roll(2, d8)) | [sum([roll(2, d8) -> [8, 8]]) -> 16] | 16 |
102101

102+
Scenario Outline: Evaluating decimal dice rolls
103+
Given a request with the expression "<expression>"
104+
When the evaluate expression service is invoked
105+
Then the response should indicate success
106+
And the response should contain the expression result text "<result text>"
107+
And the response should contain the expression result value <result value>
108+
Examples:
109+
| expression | result text | result value |
110+
| d% | [decimal([roll(2, d10) -> [10, 10]]) -> 100] | 100 |
111+
| d%0 | [decimal([roll(3, d10) -> [10, 10, 10]]) -> 1000] | 1000 |
112+
| d%00 | [decimal([roll(4, d10) -> [10, 10, 10, 10]]) -> 10000] | 10000 |
113+
| decimal(roll(3, d10)) | [decimal([roll(3, d10) -> [10, 10, 10]]) -> 1000] | 1000 |
114+
103115
Scenario Outline: Evaluating modified dice rolls
104116
Given a request with the expression "<expression>"
105117
When the evaluate expression service is invoked
@@ -134,10 +146,22 @@ Scenario Outline: Evaluating arithmetic expressions with dice rolls and constant
134146
| 4*3d6 | 4 * [sum([roll(3, d6) -> [6, 6, 6]]) -> 18] | 72 |
135147
| 3d6/4 | [sum([roll(3, d6) -> [6, 6, 6]]) -> 18] / 4 | 4.5 |
136148
| 3d6%4 | [sum([roll(3, d6) -> [6, 6, 6]]) -> 18] % 4 | 2 |
137-
| 1d%%3 | [sum([roll(1, d100) -> [100]]) -> 100] % 3 | 1 |
138149
| 2d6-L-1 | [sum([dropLowestRolls([roll(2, d6) -> [6, 6]], 1) -> [6]]) -> 6] - 1 | 5 |
139150
| 1d6+L+1 | [sum([cloneLowestRolls([roll(1, d6) -> [6]], 1) -> [6, 6]]) -> 12] + 1 | 13 |
140151

152+
Scenario Outline: Evaluating arithmetic expressions with decimal dice rolls and constants
153+
Given a request with the expression "<expression>"
154+
When the evaluate expression service is invoked
155+
Then the response should indicate success
156+
And the response should contain the expression result text "<result text>"
157+
And the response should contain the expression result value <result value>
158+
Examples:
159+
| expression | result text | result value |
160+
| d%+4 | [decimal([roll(2, d10) -> [10, 10]]) -> 100] + 4 | 104 |
161+
| d%0-4 | [decimal([roll(3, d10) -> [10, 10, 10]]) -> 1000] - 4 | 996 |
162+
| 4*d% | 4 * [decimal([roll(2, d10) -> [10, 10]]) -> 100] | 400 |
163+
| d%%3 | [decimal([roll(2, d10) -> [10, 10]]) -> 100] % 3 | 1 |
164+
141165
Scenario Outline: Rounding fractional values
142166
Given a request with the expression "<expression>"
143167
When the evaluate expression service is invoked

gulpfile.js

+34-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const childProcess = require('child_process')
1414
const del = require('del')
1515
const fs = require('fs')
1616
const gulp = require('gulp')
17+
const replace = require('gulp-replace')
1718
const runSequence = require('run-sequence')
19+
const streamToPromise = require('stream-to-promise')
1820

1921
const BUILD_OUTPUT_DIR = 'build'
2022
const FEATURES_DIR = 'features'
@@ -40,6 +42,20 @@ function exec (command, callback) {
4042
})
4143
}
4244

45+
function getGitInfo () {
46+
const git = require('git-rev')
47+
return Promise.all([
48+
promisifyWithoutError(git.branch),
49+
promisifyWithoutError(git.short)
50+
])
51+
.then((results) => {
52+
return {
53+
branch: results[0],
54+
commit: results[1]
55+
}
56+
})
57+
}
58+
4359
function getLocalVersionQualifier (gitInfo) {
4460
return `local-${gitInfo.branch}-${gitInfo.commit}`
4561
}
@@ -56,17 +72,28 @@ function getVersionQualifier (gitInfo) {
5672
return getLocalVersionQualifier(gitInfo)
5773
}
5874

75+
function injectCopyright () {
76+
const buildDate = new Date()
77+
return replace('{{COPYRIGHT_YEAR}}', buildDate.getUTCFullYear())
78+
}
79+
5980
function injectVersion (gitInfo) {
6081
const packageInfo = require('./package.json')
61-
const replace = require('gulp-replace')
6282
const versionQualifier = getVersionQualifier(gitInfo)
6383
return replace('{{VERSION}}', `${packageInfo.version}-${versionQualifier}`)
6484
}
6585

86+
function promisifyWithoutError (func) {
87+
return new Promise((resolve, reject) => {
88+
func((result) => {
89+
resolve(result)
90+
})
91+
})
92+
}
93+
6694
function runCucumber (path) {
6795
const cucumber = require('gulp-cucumber')
6896
const glob = require('glob')
69-
const streamToPromise = require('stream-to-promise')
7097

7198
let promise = Promise.resolve()
7299

@@ -144,26 +171,20 @@ gulp.task('compile:client:html', () => {
144171
.pipe(gulp.dest(COMPILE_OUTPUT_DIR))
145172
})
146173

147-
gulp.task('compile:client:js', (done) => {
174+
gulp.task('compile:client:js', () => {
148175
const browserify = require('browserify')
149-
const git = require('git-rev')
150176
const source = require('vinyl-source-stream')
151-
152-
const gitInfo = {}
153-
git.branch((branch) => {
154-
gitInfo.branch = branch
155-
git.short((commit) => {
156-
gitInfo.commit = commit
177+
return getGitInfo()
178+
.then((gitInfo) => streamToPromise(
157179
browserify([`${CLIENT_SRC_DIR}/index.js`])
158180
.transform('browserify-css')
159181
.transform('brfs')
160182
.bundle()
161183
.pipe(source('bundle.js'))
162184
.pipe(injectVersion(gitInfo))
185+
.pipe(injectCopyright())
163186
.pipe(gulp.dest(`${COMPILE_OUTPUT_DIR}/${CLIENT_SRC_DIR}`))
164-
done()
165-
})
166-
})
187+
))
167188
})
168189

169190
gulp.task('compile:client', ['compile:client:html', 'compile:client:js'])

npm-shrinkwrap.json

+64-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)