build-cloud 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11460ad753382b58275400b8ab414640e7fecde6
4
- data.tar.gz: 15aa9df500e9794122e4f4fa00b041740b3e4cab
3
+ metadata.gz: fd4a20e8b7908bb629714238bea43885797a144d
4
+ data.tar.gz: f135d4406e2aa8f7e3577b420ad094371c493623
5
5
  SHA512:
6
- metadata.gz: 062ddc2ccd009d56c7ef25da14662318c958727f6fb47f1b009a2e288609c693bf799661506138a51da35b2eee45cc2040606fa940daf7b24bc318476c3b0f0b
7
- data.tar.gz: e19393aa5abe4a85021e67e105a5c8c86801df37af398043d58e4c5bca4a205fc31c6c7182bdd49cb54092dce14f7076f77b26b1a304a27349eed3913b41024d
6
+ metadata.gz: 049623b921bbe636b52a4db50db8b4d1a3f16ea7ead93afe6b987ecf5d5fb5ef017c1eec9e2b54e372acb30aa07f61daca7f64fe475c255ee7976d56978e5e7e
7
+ data.tar.gz: 66fb3c83ea5eec6490805e900fe59a2bda165d36c5d67c2304e2e08c974b214a9930486e1e7343c8f3ccd8148010d0bc2cf687ce130090703d7d1140b81a4072
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 The Scale Factory
1
+ Copyright (c) 2014, 2015 The Scale Factory Ltd
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -22,6 +22,8 @@ See the command line help for `build-cloud`.
22
22
 
23
23
  ## Changelog
24
24
 
25
+ 2015-10-12 - version 0.0.14 - now allows defaults in interpolated variables, if the variable doesn't exist. Format is `%{variablename||default}` eg. `%{node_instance_type||t2.large}`
26
+
25
27
  2015-09-02 - version 0.0.13 - use the same environment variables as AWS SDKs for credentials
26
28
 
27
29
  2015-08-24 - version 0.0.12 - adds support for tagging network interfaces, permits multiple config files to be passed on the commandline, fixes a bug with S3 buckets named to contain dots.
data/build-cloud.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "build-cloud"
7
- spec.version = "0.0.13"
7
+ spec.version = "0.0.14"
8
8
  spec.authors = ["The Scale Factory"]
9
9
  spec.email = ["info@scalefactory.com"]
10
10
  spec.summary = %q{Tools for building resources in AWS}
data/lib/build-cloud.rb CHANGED
@@ -207,6 +207,9 @@ class BuildCloud
207
207
  # Work through the given config replacing all strings matching
208
208
  # %{..x..} by looking up ..x.. in the existing @config hash and
209
209
  # substituting the template with the value
210
+ #
211
+ # If ..x.. is of the form variable||default, if the given key is
212
+ # not defined anywhere, the default will be used.
210
213
 
211
214
  case h
212
215
  when Hash
@@ -219,17 +222,15 @@ class BuildCloud
219
222
  h.map { |v| recursive_interpolate_config(v) }
220
223
  when String
221
224
 
222
- while h =~ /%\{(.+?)\}/
223
- var = $1
224
- val = ""
225
+ while /%\{(?<var>[^\|\}]*)(?:\|{2}(?<default>[^\}]*))?\}/ =~ h
225
226
 
226
- if @config.has_key?(var.to_sym)
227
- val = @config[var.to_sym]
228
- else
229
- raise "Attempt to interpolate with non-existant key '#{var}'"
230
- end
227
+ # $& is the whole matched expression above, $MATCH when using English
228
+ exp = $&
229
+
230
+ val = @config.fetch(var.to_sym, default)
231
+ raise "Attempt to interpolate with non-existant key '#{var}' with no default value set" if val.nil?
231
232
 
232
- h.gsub!(/%\{#{var}\}/, val)
233
+ h.gsub!(exp, val)
233
234
 
234
235
  end
235
236
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Scale Factory
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler