rigit 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -14
- data/lib/rigit/prompt.rb +7 -0
- data/lib/rigit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 115d92a220f39a44c6ade5078aa76be9a7dc716361ea2926f85d1ba80c588354
|
4
|
+
data.tar.gz: f1446dd700308179e588082abfe736e9f48101468e687273158aa2285920547c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c90c6ec8a808dea93f11f69c808719d792e1e10ae452aab7d9099b2b441ec1be6c27d68e92c7e194a03d15c1f85de6e400a90893f21699baeb593e7680b894f
|
7
|
+
data.tar.gz: 0f67a31c66197d9a0853582a36f1669a3fc3d032bbf85d809118fc1e330b9531569502071a60377c6c1f3df7178c55e778fa9139cfe3e5d2f9e8bd2b0d8667ee
|
data/README.md
CHANGED
@@ -28,11 +28,11 @@ Table of Contents
|
|
28
28
|
* [Directory Structure](#directory-structure)
|
29
29
|
* [Dynamic Tokens](#dynamic-tokens)
|
30
30
|
* [Config File](#config-file)
|
31
|
-
* [Example
|
31
|
+
* [Example config](#example-config)
|
32
32
|
* [Showing messages before/after scaffolding](#showing-messages-beforeafter-scaffolding)
|
33
33
|
* [Executing commands before/after scaffolding](#executing-commands-beforeafter-scaffolding)
|
34
34
|
* [Scaffolding parameters](#scaffolding-parameters)
|
35
|
-
|
35
|
+
* [Conditional parameters](#conditional-parameters)
|
36
36
|
|
37
37
|
Installation
|
38
38
|
--------------------------------------------------
|
@@ -210,7 +210,7 @@ Place a `config.yml` file at the root of your rig template. A config file
|
|
210
210
|
is optional for rigs that do not have any variables.
|
211
211
|
|
212
212
|
|
213
|
-
#### Example
|
213
|
+
#### Example config
|
214
214
|
|
215
215
|
The below config file example contains all the available options:
|
216
216
|
|
@@ -234,15 +234,16 @@ params:
|
|
234
234
|
type: text
|
235
235
|
default: project
|
236
236
|
|
237
|
-
|
238
|
-
prompt: Include
|
237
|
+
console:
|
238
|
+
prompt: Include interactive console?
|
239
239
|
type: yesno
|
240
240
|
default: yes
|
241
241
|
|
242
|
-
|
242
|
+
console_type:
|
243
243
|
prompt: "Select console:"
|
244
244
|
type: select
|
245
245
|
list: [irb, pry]
|
246
|
+
condition: console=yes
|
246
247
|
```
|
247
248
|
|
248
249
|
#### Showing messages before/after scaffolding
|
@@ -284,15 +285,16 @@ after:
|
|
284
285
|
The `params` option contains a list of parameters required by the rig.
|
285
286
|
|
286
287
|
Each definition in the `params` key should start with the name of the
|
287
|
-
variable (`name`, `
|
288
|
-
the below specifications:
|
288
|
+
variable (`name`, `console` and `console_type` in the above example), and
|
289
|
+
contain the below specifications:
|
289
290
|
|
290
|
-
| Key
|
291
|
-
|
292
|
-
| `prompt`
|
293
|
-
| `type`
|
294
|
-
| `default`
|
295
|
-
| `list`
|
291
|
+
| Key | Purpose |
|
292
|
+
|-------------|----------------------------------------------------------|
|
293
|
+
| `prompt` | The text to display when asking for user input |
|
294
|
+
| `type` | The variable tyoe. Can be `yesno`, `text` or `select` |
|
295
|
+
| `default` | The default value. When using `yesno`, use `yes` or `no` |
|
296
|
+
| `list` | An array of allowed options (only used in `select` type) |
|
297
|
+
| `condition` | Optional `key=value`. See [conditional parameters](#conditional-parameters) below |
|
296
298
|
|
297
299
|
Example:
|
298
300
|
|
@@ -304,6 +306,32 @@ params:
|
|
304
306
|
default: project
|
305
307
|
```
|
306
308
|
|
309
|
+
#### Conditional parameters
|
310
|
+
|
311
|
+
You can configure some of the parameters to prompt the user for input based
|
312
|
+
on his previous input.
|
313
|
+
|
314
|
+
A condition is a simple `key=value` where `key` is a name of a parameter
|
315
|
+
that is previously defined.
|
316
|
+
|
317
|
+
In the below example, the `console_type` parameter will only be requested if
|
318
|
+
the user has responded with `yes` to the `console` question.
|
319
|
+
|
320
|
+
Example:
|
321
|
+
|
322
|
+
```yaml
|
323
|
+
params:
|
324
|
+
console:
|
325
|
+
prompt: Include interactive console?
|
326
|
+
type: yesno
|
327
|
+
default: yes
|
328
|
+
|
329
|
+
console_type:
|
330
|
+
prompt: "Select console:"
|
331
|
+
type: select
|
332
|
+
list: [irb, pry]
|
333
|
+
condition: console=yes
|
334
|
+
```
|
307
335
|
---
|
308
336
|
|
309
337
|
[example-rig]: https://github.com/DannyBen/example-rig
|
data/lib/rigit/prompt.rb
CHANGED
@@ -18,6 +18,7 @@ module Rigit
|
|
18
18
|
def get_input(prefill={})
|
19
19
|
result = {}
|
20
20
|
params.each do |key, spec|
|
21
|
+
next if skip_by_condition? spec, result
|
21
22
|
result[key] = prefill.has_key?(key) ? prefill[key] : ask(spec)
|
22
23
|
end
|
23
24
|
result
|
@@ -41,6 +42,12 @@ module Rigit
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
def skip_by_condition?(spec, filled_values)
|
46
|
+
return unless spec.has_key? :condition
|
47
|
+
key, value = spec.condition.split '='
|
48
|
+
filled_values[key.to_sym] != value
|
49
|
+
end
|
50
|
+
|
44
51
|
def prompt
|
45
52
|
@prompt ||= TTY::Prompt.new
|
46
53
|
end
|
data/lib/rigit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rigit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: super_docopt
|