/
DynamicValue.js
45 lines (38 loc) · 1.23 KB
/
DynamicValue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import RandExp from 'randexp'
import {
registerDynamicValueClass,
InputField
} from './__mocks__/Shims'
@registerDynamicValueClass
export default class RandomStringDV {
// TODO update static information with correct ones
// Organisation
static organisation = 'luckymarmot'
static repository = 'Paw-StringGeneratorDynamicValue'
// DynamicValue
static identifier = 'com.luckymarmot.PawExtensions.StringGeneratorDynamicValue'
static title = 'Regex Randomizer'
static help = 'https://github.com/luckymarmot/Paw-StringGeneratorDynamicValue'
static inputs = [
new InputField('regex', 'Regex', 'String', { persisted: true }),
new InputField(
'ignoreCase',
'Ignore case (i)',
'Checkbox',
{ defaultValue: false, persisted: true }
),
new InputField(
'multiline',
'Multiline (m)',
'Checkbox',
{ defaultValue: false, persisted: true }
)
]
// args: context, requests, options
evaluate(context) {
let modifier = ''
modifier += this.ignoreCase ? 'i' : ''
modifier += this.multiline ? 'm' : ''
return new RandExp(this.regex, modifier).gen()
}
}