kumogata 0.2.18 → 0.2.19

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
- M2RiMjE5OGYxYmZkY2NiZDBkNzBjMGE0ZTdkN2UwMzE5OWRhZjJjMQ==
4
+ OTIzZjQ1YzM3MGFkNzQ0YmRiMjYyMDFlMjVmYjEwMjgzNTliZDU2Mg==
5
5
  data.tar.gz: !binary |-
6
- MmE4MGE2NTQwMGQ5MTAxZDZkYzEwMjVmNWU3NjA1MzUxODhiMjFhNg==
6
+ ZTA2ZjU5YTc1YTRjMjE4ZGY0NWUzNzM1ZTBhNjljMDBjNmY4NzhlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODlkMTM4MTdmMDJiMTBlMjY3MzM5MDEzZDY4MzBjYzE2M2FmY2MxM2M3ZjI0
10
- OTM4ODdhZDZkOWQ1NWU1NmFiZGQzODFhZGMyYjViMTRmMDJmYzQ4OTQ2MjIz
11
- M2VjNzUwZTAyOGU5YzQzYTM2YjI0M2Q0NWFhYzQyNTMwNjk0YzM=
9
+ ZmU2OWY3YzBjM2QwYjE1ZjQ0OGE3ZGE0ZmYwOGQ2MDdhNzIxOWM5MGE3YjMx
10
+ YjgwYjRhMmY0Y2MzMWI4OTFiMmFmMmQxZjRmNzQxNmFmNTZjNGEwZDllZmNh
11
+ MDU3ZWVmMmYyZDkzOTEzYzEzZDk4OGJjOTQxOWZjMTVhYmRlOGU=
12
12
  data.tar.gz: !binary |-
13
- ZDFmODJiOTYyNmE0MTg4ZDkxMzllZWMyYjg2NGE5ZDFiNWM3MmU1NzIxMjcy
14
- NDdjMTk5MWI3ZTdkYWM1ZThjZTI3M2IwYzFkMzdjNDM5ZTcxNmE5ZTVmNDgx
15
- NTA4YTAyZGFjZmZmZDk1YjBhOTc5YmE3NWU1ZTc5ZmU1NTIyNTY=
13
+ ZjFmZmRjMmY5ODE0MzRhOWQxMmE5MDE4N2ExZmI0YmEwMTllZjA1YWE5ODNk
14
+ N2MyN2NlNzQwYzI4MWZiZTVjZmM3MTVlZTFkMGQ1MDlkYTkzODVjNzczNDhm
15
+ MzAwY2IxYjU1MzJjMDU2OTRmYmY3ZGI0ODA1NDY5MzBhYjc1MjU=
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403072326)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403072326)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403072353)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403072353)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
data/lib/kumogata.rb CHANGED
@@ -24,3 +24,4 @@ require 'kumogata/ext/coderay_ext'
24
24
  require 'kumogata/ext/json_ext'
25
25
  require 'kumogata/ext/string_ext'
26
26
  require 'kumogata/logger'
27
+ require 'kumogata/utils'
@@ -202,7 +202,16 @@ class Kumogata::Client
202
202
  end
203
203
 
204
204
  def create_stack(template, stack_name)
205
- stack_name = stack_name || 'kumogata-' + UUIDTools::UUID.timestamp_create
205
+ unless stack_name
206
+ user_host = Kumogata::Utils.get_user_host
207
+
208
+ stack_name = ['kumogata']
209
+ stack_name << user_host if user_host
210
+ stack_name << UUIDTools::UUID.timestamp_create
211
+
212
+ stack_name = stack_name.join('-')
213
+ stack_name.gsub!(/[^-a-zA-Z0-9]+/, '-')
214
+ end
206
215
 
207
216
  Kumogata.logger.info("Creating stack: #{stack_name}".cyan)
208
217
  stack = @cloud_formation.stacks.create(stack_name, template.to_json, build_create_options)
@@ -408,7 +417,7 @@ class Kumogata::Client
408
417
  :stack_name,
409
418
  :timestamp,
410
419
  ].each do |k|
411
- event_hash[camelize(k)] = event.send(k)
420
+ event_hash[Kumogata::Utils.camelize(k)] = event.send(k)
412
421
  end
413
422
 
414
423
  event_hash
@@ -437,7 +446,7 @@ class Kumogata::Client
437
446
  :resource_status_reason,
438
447
  :last_updated_timestamp
439
448
  ].each do |k|
440
- summary_hash[camelize(k)] = summary[k]
449
+ summary_hash[Kumogata::Utils.camelize(k)] = summary[k]
441
450
  end
442
451
 
443
452
  summary_hash
@@ -465,12 +474,6 @@ Stack Resource Summaries:
465
474
  end
466
475
  end
467
476
 
468
- def camelize(str)
469
- str.to_s.split(/[-_]/).map {|i|
470
- i[0, 1].upcase + i[1..-1].downcase
471
- }.join
472
- end
473
-
474
477
  def validate_stack_name(stack_name)
475
478
  return unless stack_name
476
479
 
@@ -0,0 +1,16 @@
1
+ class Kumogata::Utils
2
+ class << self
3
+ def camelize(str)
4
+ str.to_s.split(/[-_]/).map {|i|
5
+ i[0, 1].upcase + i[1..-1].downcase
6
+ }.join
7
+ end
8
+
9
+ def get_user_host
10
+ user = `whoami`.strip rescue ''
11
+ host = `hostname`.strip rescue ''
12
+ user_host = [user, host].select {|i| not i.empty? }.join('-')
13
+ user_host.empty? ? nil : user_host
14
+ end
15
+ end # of class methods
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.18'
2
+ VERSION = '0.2.19'
3
3
  end
@@ -48,9 +48,9 @@ end
48
48
 
49
49
  stacks = make_double('stacks') do |obj|
50
50
  obj.should_receive(:create)
51
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {}) { stack }
51
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {}) { stack }
52
52
  obj.should_receive(:[])
53
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
53
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
54
54
  end
55
55
 
56
56
  cf.should_receive(:stacks).twice { stacks }
@@ -114,9 +114,9 @@ end
114
114
 
115
115
  stacks = make_double('stacks') do |obj|
116
116
  obj.should_receive(:create)
117
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large"}}) { stack }
117
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large"}}) { stack }
118
118
  obj.should_receive(:[])
119
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
119
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
120
120
  end
121
121
 
122
122
  cf.should_receive(:stacks).twice { stacks }
@@ -261,9 +261,9 @@ end
261
261
 
262
262
  stacks = make_double('stacks') do |obj|
263
263
  obj.should_receive(:create)
264
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large"}}) { stack }
264
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', json, {:parameters=>{"InstanceType"=>"m1.large"}}) { stack }
265
265
  obj.should_receive(:[])
266
- .with('kumogata-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
266
+ .with('kumogata-user-host-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') { stack }
267
267
  end
268
268
 
269
269
  cf.should_receive(:stacks).twice { stacks }
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,12 @@ class UUIDTools::UUID
6
6
  def self.timestamp_create; 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'; end
7
7
  end
8
8
 
9
+ class Kumogata::Utils
10
+ def self.get_user_host
11
+ 'user-host'
12
+ end
13
+ end
14
+
9
15
  def tempfile(content, template_ext)
10
16
  basename = "#{File.basename __FILE__}.#{$$}"
11
17
  basename = [basename, template_ext]
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.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -202,6 +202,7 @@ files:
202
202
  - lib/kumogata/ext/json_ext.rb
203
203
  - lib/kumogata/ext/string_ext.rb
204
204
  - lib/kumogata/logger.rb
205
+ - lib/kumogata/utils.rb
205
206
  - lib/kumogata/version.rb
206
207
  - packer/CentOS-6.4-x86_64-with_Updates-Asia_Pacific.json
207
208
  - packer/Ubuntu-12.04.4-LTS-x86_64-ebs-Asia_Pacific.json