kumogata 0.2.5 → 0.2.6

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: ef04284bfd6f09d16a95a4aff75186ab8c785223
4
- data.tar.gz: 53a9ede92d15f96d5f0a4b75bdcf5046b247e5e3
3
+ metadata.gz: b31c25198207adf1d56654843c7529fbd62f2ff6
4
+ data.tar.gz: 7510a7e9a89a775a3869ab3d850f6ecaeb35a0e8
5
5
  SHA512:
6
- metadata.gz: 385f8496d9e99b318dd9d0ff72317590c746694a5143d4a5e91863251dccfe3adecde91e94301356dd880a74115420ec49d0535a4330a9733109ad0cb3d0db8b
7
- data.tar.gz: 3cb5fbc3e5b197f070d02fd7d0f920394ae3d4330eefb5fc2a90105b070e381ef7e4efe5429dbb7fd4e11d7dc02283462cc8fbba21ae4f71150a6e8406e35fae
6
+ metadata.gz: a1bc043a32b8d8ab4d9439e56190d3ecbac5246c67a0f5c95996d585d8365d6b0553e265f517f94428241888fa441ec09eed28bc3be4caef07516a96dbca5cff
7
+ data.tar.gz: 4fef527beb218337ff205adf84aa5ff149b3b2c41d3d13ef6e4b961210a1c510c362b37a9f062ce299f35c9cee388e2a074b6986e4c06f77ca9d9ea0bcbf9a01
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?201403051952)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403051952)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403061015)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403061015)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
@@ -163,13 +163,13 @@ end
163
163
  }
164
164
  ```
165
165
 
166
- ### Split of configuration
166
+ ### Split a template file
167
167
 
168
168
  * template.rb
169
169
 
170
170
  ```ruby
171
171
  Resources do
172
- require 'template2'
172
+ _include 'template2'
173
173
  end
174
174
  ```
175
175
 
@@ -149,26 +149,14 @@ class Kumogata::Client
149
149
 
150
150
  def define_template_func(scope, path_or_url)
151
151
  scope.instance_eval(<<-EOS)
152
- def require(file)
152
+ def _include(file)
153
153
  path = file.dup
154
154
 
155
155
  unless path =~ %r|\\A/| or path =~ %r|\\A\\w+://|
156
156
  path = File.expand_path(File.join(File.dirname(#{path_or_url.inspect}), path))
157
157
  end
158
158
 
159
- begin
160
- if File.exist?(path + '.rb')
161
- open(path + '.rb') {|f| instance_eval(f.read) }
162
- else
163
- open(path) {|f| instance_eval(f.read) }
164
- end
165
- rescue => e
166
- begin
167
- Kernel.require(file)
168
- rescue
169
- raise e
170
- end
171
- end
159
+ open(path) {|f| instance_eval(f.read) }
172
160
  end
173
161
 
174
162
  def _path(path, value = nil, &block)
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -532,7 +532,7 @@ end
532
532
  tempfile(part_of_template, '.rb') do |f|
533
533
  template = <<-EOS
534
534
  Resources do
535
- require #{f.path.inspect}
535
+ _include #{f.path.inspect}
536
536
  end
537
537
 
538
538
  Outputs do
@@ -568,6 +568,56 @@ end
568
568
  }
569
569
  }
570
570
  }
571
+ }
572
+ EOS
573
+ end
574
+
575
+ it 'convert Ruby template to JSON template with require' do
576
+ template = <<-EOS
577
+ require 'fileutils'
578
+
579
+ Resources do
580
+ myEC2Instance do
581
+ Type "AWS::EC2::Instance"
582
+ Properties do
583
+ ImageId "ami-XXXXXXXX"
584
+ InstanceType "t1.micro"
585
+ end
586
+ end
587
+ end
588
+
589
+ Outputs do
590
+ AZ do
591
+ Value do
592
+ Fn__GetAtt "myEC2Instance", "AvailabilityZone"
593
+ end
594
+ end
595
+ end
596
+ EOS
597
+
598
+ json_template = run_client(:convert, :template => template)
599
+
600
+ expect(json_template).to eq((<<-EOS).chomp)
601
+ {
602
+ "Resources": {
603
+ "myEC2Instance": {
604
+ "Type": "AWS::EC2::Instance",
605
+ "Properties": {
606
+ "ImageId": "ami-XXXXXXXX",
607
+ "InstanceType": "t1.micro"
608
+ }
609
+ }
610
+ },
611
+ "Outputs": {
612
+ "AZ": {
613
+ "Value": {
614
+ "Fn::GetAtt": [
615
+ "myEC2Instance",
616
+ "AvailabilityZone"
617
+ ]
618
+ }
619
+ }
620
+ }
571
621
  }
572
622
  EOS
573
623
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-05 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk