opto 1.8.6 → 1.8.7

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
  SHA1:
3
- metadata.gz: 01345db739496fa79db40b212d800c23a0d41c0a
4
- data.tar.gz: 0d30d38ef8edbc747e99d1b7fcbef72668ad4bda
3
+ metadata.gz: 8c5fb44e578d4ada0e75f570389edaaffb7240bf
4
+ data.tar.gz: 861c45894eb143c6e3077bf0cd7700564f489d01
5
5
  SHA512:
6
- metadata.gz: 3853fbd5ece07bdf907c700ee0e9f2a23687c5204a425cc7b35edf21f0841e13552561800be0571d20de62f608b4667562960e27526036aa80414113096e956b
7
- data.tar.gz: a01ddce3fc41cf44daea222bc7af26ed762bb6fb35537ca1247e96c4fae1a035d567d4996ba31378cfbd70b8bd6620589bfed57b1cf167483437b439cde8dd2f
6
+ metadata.gz: 183a776b2f65a61c20b84e2c216667bc6e7fc074dd7356e4e26619850dcd60a8a437faf1882ce1fcf02e4b088224f2d89b9904818b12b1b2e64bba38882ff290
7
+ data.tar.gz: 2411c527cb2e1b1028fe42a9768a7c112fb945f75f3f41811ada9241185212c7bc6f0bfde403f55b82ec0278d0cdf3353ccb2e7e419659a2457c5ec7c773abda
data/README.md CHANGED
@@ -501,6 +501,24 @@ Ignores hint completely.
501
501
 
502
502
  Output is a 'random' UUID generated by `SecureRandom.uuid`, such as `78b6decf-e312-45a1-ac8c-d562270036ba`
503
503
 
504
+ ### variable
505
+ Hint is a name of another variable. Reads the value of another variable.
506
+
507
+ Example:
508
+
509
+ ```yaml
510
+ db_host_a:
511
+ type: string
512
+ value: db.host.example.com
513
+
514
+ db_host_b:
515
+ type: string
516
+ from:
517
+ variable: db_host_a
518
+
519
+ # group.value_of('db_host_b') => 'db.host.example.com'
520
+ ```
521
+
504
522
  ### evaluate
505
523
  Hint is a calculation. Uses values of other options to perform simple calculations.
506
524
 
@@ -521,6 +539,7 @@ fruits:
521
539
  evaluate: ${apples} + ${bananas}
522
540
 
523
541
  # group.value_of('fruits') => 3
542
+ ```
524
543
 
525
544
  ### interpolate
526
545
  Hint is a template. Uses values from other options to build a string.
@@ -0,0 +1,19 @@
1
+ module Opto
2
+ module Resolvers
3
+ # Find a value of another variable.
4
+ #
5
+ # Hint should be a name of another variable
6
+ class Variable < Opto::Resolver
7
+
8
+ def resolve
9
+ raise ArgumentError, "Variable name not set" if hint.nil?
10
+ if option.group.nil? || option.group.option(hint).nil?
11
+ raise RuntimeError, "Variable #{hint} not declared"
12
+ end
13
+ option.value_of(hint)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
@@ -1,3 +1,3 @@
1
1
  module Opto
2
- VERSION = "1.8.6"
2
+ VERSION = "1.8.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.6
4
+ version: 1.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kimmo Lehto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-08 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,6 +82,7 @@ files:
82
82
  - lib/opto/resolvers/random_number.rb
83
83
  - lib/opto/resolvers/random_string.rb
84
84
  - lib/opto/resolvers/random_uuid.rb
85
+ - lib/opto/resolvers/variable.rb
85
86
  - lib/opto/setter.rb
86
87
  - lib/opto/setters/environment_variable.rb
87
88
  - lib/opto/type.rb
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  version: '0'
114
115
  requirements: []
115
116
  rubyforge_project:
116
- rubygems_version: 2.4.5
117
+ rubygems_version: 2.6.13
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Option validator / resolver