rigit 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c64487a87ae7122b0d47a53d3843b374beb6d3ae12ccf0cf171d83d0f68075e8
4
- data.tar.gz: ca486b20b6ba0ba9af18c1d10c3254b352a2598226995d6decdb785f86ff7ae5
3
+ metadata.gz: 115d92a220f39a44c6ade5078aa76be9a7dc716361ea2926f85d1ba80c588354
4
+ data.tar.gz: f1446dd700308179e588082abfe736e9f48101468e687273158aa2285920547c
5
5
  SHA512:
6
- metadata.gz: f3bff17c87022e3742de0fddc5e9616e63f5fc1c443751104db0c292fba7c3f4ff86b2c4793a8795c544a0660178144c0fa18ce96cfe95ac7f6fffef790874da
7
- data.tar.gz: a976e1b1ae23a1c207964957725e05d2d00622f0b2d4407858d1d8e8fec92c048d3401b96001fec503da3f46fc238a4a052415f854f8becd294d2f8430b050b1
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 Config](#example-config)
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 Config
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
- spec:
238
- prompt: Include RSpec files?
237
+ console:
238
+ prompt: Include interactive console?
239
239
  type: yesno
240
240
  default: yes
241
241
 
242
- console:
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`, `spec` and `console` in the above example), and contain
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 | Purpose |
291
- |-----------|----------------------------------------------------------|
292
- | `prompt` | The text to display when asking for user input |
293
- | `type` | The variable tyoe. Can be `yesno`, `text` or `select` |
294
- | `default` | The default value. When using `yesno`, use `yes` or `no` |
295
- | `list` | An array of allowed options (only used in `select` type) |
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Rigit
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-09 00:00:00.000000000 Z
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: super_docopt