aws-must 0.0.6 → 0.0.7

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -5
  3. data/bin/aws-must.rb +42 -2
  4. data/demo/1/root.mustache +3 -0
  5. data/demo/2/resources.mustache +7 -3
  6. data/demo/2/root.mustache +41 -5
  7. data/demo/3/resource.mustache +6 -7
  8. data/demo/3/resourceInstance.mustache +6 -7
  9. data/demo/3/resources.mustache +7 -2
  10. data/demo/3/root.mustache +42 -17
  11. data/demo/4/output.mustache +6 -10
  12. data/demo/4/resource.mustache +6 -8
  13. data/demo/4/resourceInstance.mustache +6 -11
  14. data/demo/4/resourceSecurityGroup.mustache +6 -8
  15. data/demo/4/resources.mustache +8 -4
  16. data/demo/4/root.mustache +44 -17
  17. data/demo/5/mappings.mustache +5 -2
  18. data/demo/5/output.mustache +5 -11
  19. data/demo/5/resource.mustache +6 -10
  20. data/demo/5/resourceInstance.mustache +7 -9
  21. data/demo/5/resources.mustache +8 -5
  22. data/demo/5/root.mustache +44 -10
  23. data/demo/6/mappings.mustache +6 -3
  24. data/demo/6/output.mustache +8 -11
  25. data/demo/6/parameter.mustache +7 -11
  26. data/demo/6/resource.mustache +7 -17
  27. data/demo/6/resourceInstance.mustache +8 -16
  28. data/demo/6/resourceSecurityGroup.mustache +7 -8
  29. data/demo/6/resources.mustache +11 -5
  30. data/demo/6/root.mustache +53 -25
  31. data/demo/6/tag.mustache +6 -12
  32. data/demo/7/mappings.mustache +6 -3
  33. data/demo/7/output.mustache +8 -13
  34. data/demo/7/parameter.mustache +7 -11
  35. data/demo/7/resource.mustache +8 -17
  36. data/demo/7/resourceInstance.mustache +8 -16
  37. data/demo/7/resourceInstanceChef.mustache +6 -10
  38. data/demo/7/resourceSecurityGroup.mustache +8 -8
  39. data/demo/7/resources.mustache +10 -5
  40. data/demo/7/root.mustache +51 -25
  41. data/demo/7/tag.mustache +6 -10
  42. data/lib/aws-must/docu.rb +31 -7
  43. data/lib/aws-must/template.rb +23 -0
  44. data/lib/utils/hasher.rb +3 -1
  45. metadata +2 -2
data/lib/aws-must/docu.rb CHANGED
@@ -9,9 +9,12 @@ module AwsMust
9
9
  # ------------------------------------------------------------------
10
10
  # constants
11
11
 
12
- DEFAULT_OPEN_TAG ="++start++"
13
- DEFAULT_CLOSE_TAG ="++close++"
14
- DEFAULT_INCLUDE_TAG =">"
12
+ DEFAULT_OPEN_TAG ="+++start+++"
13
+ DEFAULT_CLOSE_TAG ="+++close+++"
14
+ DEFAULT_FOLD_ON_TAG ="+++fold-on+++"
15
+ DEFAULT_FOLD_OFF_TAG ="+++fold-off+++"
16
+ DEFAULT_INCLUDE_TAG =">"
17
+
15
18
 
16
19
 
17
20
  # ------------------------------------------------------------------
@@ -22,6 +25,10 @@ module AwsMust
22
25
 
23
26
  # instance
24
27
 
28
+ # command line option define lines to output for directive
29
+ attr_accessor :fold_on
30
+ attr_accessor :fold_off
31
+
25
32
  # ------------------------------------------------------------------
26
33
  # Constructor
27
34
  # - template: which knows how to return template files
@@ -33,12 +40,20 @@ module AwsMust
33
40
 
34
41
  @template = template
35
42
 
43
+ # command line option define lines to output for directive
44
+ @fold_on = options[:fold_on] if options[:fold_on]
45
+ @fold_off = options[:fold_off] if options[:fold_off]
46
+
47
+
36
48
  @directives = {
37
49
  :open => DEFAULT_OPEN_TAG,
38
50
  :close => DEFAULT_CLOSE_TAG,
51
+ :fold_on => DEFAULT_FOLD_ON_TAG,
52
+ :fold_off => DEFAULT_FOLD_OFF_TAG,
39
53
  :include => DEFAULT_INCLUDE_TAG,
40
54
  }
41
55
 
56
+
42
57
  end
43
58
 
44
59
  # ------------------------------------------------------------------
@@ -60,7 +75,7 @@ module AwsMust
60
75
 
61
76
  if !state_opened then
62
77
 
63
- # waiting for +++open+++
78
+ # waiting for +++open+++ or +++fold_on+++
64
79
 
65
80
  open_found, line = directive_open( line )
66
81
  if open_found then
@@ -74,7 +89,7 @@ module AwsMust
74
89
 
75
90
  else
76
91
 
77
- # seen +++open+++, waiting for +++close+++
92
+ # seen +++open+++ or +++fold_on+++, waiting for +++close+++, +++fold_off+++
78
93
 
79
94
  close_found, line_pre, line = directive_close( line )
80
95
  # puts "close_found=#{close_found}, #{close_found.class}, line=#{line}"
@@ -109,26 +124,34 @@ module AwsMust
109
124
  # return line && line.include?( get_tag(:open) )
110
125
  if line && line.include?( get_tag(:open) ) then
111
126
  # find index pointing _after_ :open tag
112
- index = line.index( get_tag(:open) ) + get_tag(:open).length
127
+ # index = line.index( get_tag(:open) ) + get_tag(:open).length
113
128
  # # return text after directtive
114
129
  # return true, line[ index..-1]
115
130
 
116
131
  # do not output anything for the line
117
132
  return true, nil
118
133
 
134
+ elsif line && line.include?( get_tag(:fold_on) ) then
135
+ # output fold_on text instread
136
+ return true, self.fold_on
119
137
  else
120
138
  return false, nil
121
139
  end
122
140
  end
141
+
123
142
 
124
143
  # return bool, line_pre, line
125
144
  def directive_close( line )
126
145
  #return line && line.include?( get_tag( :close ) )
127
146
  if line && line.include?( get_tag( :close ) ) then
128
- index = line.index( get_tag(:close) )
147
+ # index = line.index( get_tag(:close) )
129
148
  # return true, index == 0 ? nil : line[0..index-1], line[ index+ get_tag(:close).length..-1]
130
149
  # do not output anythin on line for directive
131
150
  return true, nil, nil
151
+
152
+ elsif line && line.include?( get_tag(:fold_off) ) then
153
+ # replace fold-off direcive line with fold_off text
154
+ return true, self.fold_off, nil
132
155
  else
133
156
  return false, nil, line
134
157
  end
@@ -153,6 +176,7 @@ module AwsMust
153
176
 
154
177
  # ------------------------------------------------------------------
155
178
  # get tag value
179
+
156
180
  def get_tag( tag )
157
181
  raise "Unknown tag" unless @directives[tag]
158
182
  return @directives[tag]
@@ -70,9 +70,32 @@ module AwsMust
70
70
  @logger.debug( "#{__FILE__}.#{__method__} name=#{name}" )
71
71
  return @templates[name] if @templates && @templates[name]
72
72
 
73
+ if ! File.exists?( @@template_path ) then
74
+ raise <<-eos
75
+
76
+
77
+ No such directory '#{@@template_path}'.
78
+
79
+ Use opition -t to point to an existing directory.
80
+
81
+ eos
82
+ end
83
+
73
84
  template_path = "#{@@template_path}/#{name}.#{@@template_extension}"
74
85
  @logger.info( "#{__FILE__}.#{__method__} read template_path=#{template_path}" )
75
86
 
87
+ if ! File.exists?( template_path ) then
88
+ raise <<-eos
89
+
90
+ No such file '#{template_path}'.
91
+
92
+ Use opition -t to point to a directory, which contains file '#{name}.#{@@template_extension}'
93
+
94
+
95
+ eos
96
+ end
97
+
98
+
76
99
  File.read( template_path )
77
100
  end
78
101
 
data/lib/utils/hasher.rb CHANGED
@@ -62,10 +62,12 @@ module Utils
62
62
  obj2 = dfs(obj) do |o|
63
63
  o.each do |k,v|
64
64
  if v.is_a? Array
65
- # add :comma -property expect to the last element
65
+ # add _comma = ',', expect to the
66
66
  v.slice(0,v.length-1).each do |elem|
67
67
  elem["_comma"] = "," if elem.is_a? Hash
68
68
  end
69
+ # add _comma = '' to the last element
70
+ v.last["_comma"] = "" if v.last.is_a? Hash
69
71
  end
70
72
  end
71
73
  end # block
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-must
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jarjuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache