cfndsl 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/cfndsl/JSONable.rb +28 -12
  2. metadata +2 -2
@@ -44,9 +44,14 @@ module CfnDsl
44
44
  ##
45
45
  # Usage
46
46
  # FnFormat( "This is a %0. It is 100%% %1","test", "effective")
47
- #
48
- # This will generate a call to Fn::Join that when evaluated will produce
49
- # the string "This is a test. It is 100% effective."
47
+ # or
48
+ # FnFormat( "This is a %{test}. It is 100%% %{effective},
49
+ # :test=>"test",
50
+ # :effective=>"effective")
51
+ #
52
+ # These will each generate a call to Fn::Join that when
53
+ # evaluated will produce the string "This is a test. It is 100%
54
+ # effective."
50
55
  #
51
56
  # Think of this as %0,%1, etc in the format string being replaced by the
52
57
  # corresponding arguments given after the format string. '%%' is replaced
@@ -55,15 +60,26 @@ module CfnDsl
55
60
  # The actual Fn::Join call corresponding to the above FnFormat call would be
56
61
  # {"Fn::Join": ["",["This is a ","test",". It is 100","%"," ","effective"]]}
57
62
  array = [];
58
- string.scan( /(.*?)(%(%|\d+)|\z)/m ) do |x,y|
59
- array.push $1 if $1 && $1 != ""
60
- if( $3 == '%' ) then
61
- array.push '%'
62
- elsif( $3 ) then
63
- array.push arguments[ $3.to_i ]
64
- end
65
- end
66
-
63
+ if(arguments.length == 1 && arguments[0].instance_of?(Hash) ) then
64
+ hash = arguments[0]
65
+ string.scan( /(.*?)(%(%|\{(\w+)\})|\z)/m ) do |x,y|
66
+ array.push $1 if $1 && $1 != ""
67
+ if( $3 == '%' ) then
68
+ array.push '%'
69
+ elsif( $3 ) then
70
+ array.push hash[ $4 ]
71
+ end
72
+ end
73
+ else
74
+ string.scan( /(.*?)(%(%|\d+)|\z)/m ) do |x,y|
75
+ array.push $1 if $1 && $1 != ""
76
+ if( $3 == '%' ) then
77
+ array.push '%'
78
+ elsif( $3 ) then
79
+ array.push arguments[ $3.to_i ]
80
+ end
81
+ end
82
+ end
67
83
  Fn.new("Join", ["", array])
68
84
  end
69
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 1.8.11
57
+ rubygems_version: 1.8.23
58
58
  signing_key:
59
59
  specification_version: 3
60
60
  summary: AWS Cloudformation DSL