kumogata 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmU2ZWQyYmY3MzE5MzRjOTg2OTczZjllYWRlYTAyZTg3YmZlM2NkZA==
4
+ YWVlZDU1MjQ3Y2Y3NDk1Nzg5YmRiZTZjN2NkZjAyODY2NWNmY2NjYg==
5
5
  data.tar.gz: !binary |-
6
- NjFlZWIzYWYxMjBjODE1YmE3M2ZiYjYxYzdhNjNlYmZkMTRjNTk4OQ==
6
+ MjBkOWE5MjJhZTRkY2I0MjExMTc0ODY3NGYzY2M5MGRhOTg4ZjQzOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjNmZjViNTc4ZjlmNDlhY2ViYjFjMDNmMmRkY2Q0MGRmNDYyMDkxNjE5ZTlk
10
- NDU2MTQ0MzNkMWI5ZDMzNWE5NzIzYmZjNzc1ODQ2YjExMGFhN2Y4M2YzZjc4
11
- OTIwYWU2YTc5Njc3MWM3Njc3NTY0YzVmNTllYTI4NzMzMDNjZmE=
9
+ NWNlZjUyZGRlNzJmYjc1MGFiYmU2M2U1ZDMwYTQyZGU5MzAwOWNjYTNlYmNi
10
+ MTRmOGIwOTk3OGM2OTIxOTRjYmVmOWUwZWY2MWU4NDVhMDQ3NjlhZWYzZjVh
11
+ MDU2NTM2ZGYwNjEwZGZiNzRiM2NhZjMyYmZhNjlhYmQ5NTM3YTc=
12
12
  data.tar.gz: !binary |-
13
- ZjRjODY4MWI2MTliN2JlNjhiMzc2OWIzYmE4MzE1NGM4ZGU4YTUyMDlmNTI2
14
- YTY3NWNiZGY1YWNhOTE3Y2VkMjA5NmY1MmNmYzY1YmY5NjFkNzgyYjJhNTI1
15
- ZGM5ZTU0MDZmZTc5OWU4OGI5ZGEzNGIzNzY4ZmZjZTc3ZTY4ODE=
13
+ YjEwYzI0Zjc5ZGZlNDA4ZmI5Yzc0ZWVjMGE3Y2FkNmJjZmY0MGMwZGMwOGJj
14
+ MmY2ZDdhNGM3MmQwZTY0ZTFlMDI5NzE4OTJiNjBkZjlmNzY0YTY3N2Y2ZmMx
15
+ YzhkOWQ2ZDFkNzBlNTlmZDNiMzUxNzJiMmJlNWU1OTk4Yzk3MDM=
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403031458)](http://badge.fury.io/rb/kumogata)
6
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403031458)](https://drone.io/github.com/winebarrel/kumogata/latest)
5
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403031512)](http://badge.fury.io/rb/kumogata)
6
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403031512)](https://drone.io/github.com/winebarrel/kumogata/latest)
7
7
 
8
8
  It can define a template in Ruby DSL, such as:
9
9
 
@@ -123,7 +123,7 @@ Ruby templates will be converted as follows by `_join()`:
123
123
  ```ruby
124
124
  UserData do
125
125
  Fn__Base64 _join(<<-EOS)
126
- #!/bin/bash,
126
+ #!/bin/bash
127
127
  /opt/aws/bin/cfn-init -s <%= Ref "AWS::StackId" %> -r myEC2Instance --region <%= Ref "AWS::Region" %>
128
128
  EOS
129
129
  end
@@ -134,11 +134,11 @@ end
134
134
  "Fn::Join": [
135
135
  "",
136
136
  [
137
- "#!/bin/bash,\n /opt/aws/bin/cfn-init -s\n",
137
+ "#!/bin/bash\n/opt/aws/bin/cfn-init -s ",
138
138
  {
139
139
  "Ref": "AWS::StackId"
140
140
  },
141
- "-r myEC2Instance --region\n",
141
+ "-r myEC2Instance --region ",
142
142
  {
143
143
  "Ref": "AWS::Region"
144
144
  },
@@ -153,8 +153,12 @@ class Kumogata::Client
153
153
  :strip => true,
154
154
  }.merge(options)
155
155
 
156
- data = data.strip_lines + "\n" if options[:strip]
156
+ if options[:strip]
157
+ data = data.split("\n").map {|i| i.gsub(/\A\s+/, "") }.join("\n") + "\n"
158
+ end
159
+
157
160
  data = data.encode64 if options[:encode]
161
+
158
162
  return data
159
163
  end
160
164
 
@@ -175,12 +179,22 @@ class Kumogata::Client
175
179
 
176
180
  data = data.flatten.select {|i| not i.nil? }
177
181
 
178
- unless data.last.kind_of?(String) and data.last =~ /\n\Z/
179
- data << "\n"
182
+ if options[:strip]
183
+ data = data.map do |item|
184
+ if item.kind_of?(String)
185
+ item.split("\n").map {|i| i.gsub(/\A\s+/, "") }.join("\n")
186
+ else
187
+ item
188
+ end
189
+ end
180
190
  end
181
191
 
182
- if options[:strip]
183
- data = data.map {|i| i.kind_of?(String) ? i.strip + "\n" : i }
192
+ if data.last.kind_of?(String) and data.last == ""
193
+ data.last << "\n"
194
+ end
195
+
196
+ unless data.last.kind_of?(String) and data.last =~ /\n\Z/
197
+ data << "\n"
184
198
  end
185
199
 
186
200
  return {
@@ -34,8 +34,4 @@ class String
34
34
  def encode64
35
35
  Base64.encode64(self).delete("\n")
36
36
  end
37
-
38
- def strip_lines
39
- self.strip.split("\n").map {|i| i.strip }.join("\n")
40
- end
41
37
  end
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara