awspec 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/doc/_resource_types/rds_db_parameter_group.md +8 -0
  4. data/doc/resource_types.md +32 -25
  5. data/lib/awspec.rb +2 -0
  6. data/lib/awspec/bin/toolbox +5 -0
  7. data/lib/awspec/generator.rb +5 -1
  8. data/lib/awspec/generator/doc/type.rb +26 -0
  9. data/lib/awspec/generator/doc/type/auto_scaling_group.rb +16 -0
  10. data/lib/awspec/generator/doc/type/base.rb +89 -0
  11. data/lib/awspec/generator/doc/type/ebs.rb +17 -0
  12. data/lib/awspec/generator/doc/type/ec2.rb +17 -0
  13. data/lib/awspec/generator/doc/type/elb.rb +20 -0
  14. data/lib/awspec/generator/doc/type/rds.rb +17 -0
  15. data/lib/awspec/generator/doc/type/rds_db_parameter_group.rb +16 -0
  16. data/lib/awspec/generator/doc/type/route53_hosted_zone.rb +16 -0
  17. data/lib/awspec/generator/doc/type/route_table.rb +16 -0
  18. data/lib/awspec/generator/doc/type/s3.rb +16 -0
  19. data/lib/awspec/generator/doc/type/security_group.rb +16 -0
  20. data/lib/awspec/generator/doc/type/subnet.rb +16 -0
  21. data/lib/awspec/generator/doc/type/vpc.rb +17 -0
  22. data/lib/awspec/generator/template.rb +100 -0
  23. data/lib/awspec/stub.rb +7 -0
  24. data/lib/awspec/stub/auto_scaling_group.rb +87 -0
  25. data/lib/awspec/stub/ebs.rb +66 -0
  26. data/lib/awspec/stub/ec2.rb +117 -0
  27. data/lib/awspec/stub/elb.rb +129 -0
  28. data/lib/awspec/stub/rds.rb +93 -0
  29. data/lib/awspec/stub/rds_db_parameter_group.rb +16 -0
  30. data/lib/awspec/stub/route53_hosted_zone.rb +83 -0
  31. data/lib/awspec/stub/route_table.rb +60 -0
  32. data/lib/awspec/stub/s3.rb +14 -0
  33. data/lib/awspec/stub/security_group.rb +66 -0
  34. data/lib/awspec/stub/subnet.rb +33 -0
  35. data/lib/awspec/stub/vpc.rb +69 -0
  36. data/lib/awspec/toolbox.rb +13 -0
  37. data/lib/awspec/version.rb +1 -1
  38. metadata +33 -16
  39. data/lib/awspec/docgen.rb +0 -23
  40. data/lib/awspec/generator/doc/auto_scaling_group.rb +0 -15
  41. data/lib/awspec/generator/doc/base.rb +0 -74
  42. data/lib/awspec/generator/doc/ebs.rb +0 -15
  43. data/lib/awspec/generator/doc/ec2.rb +0 -15
  44. data/lib/awspec/generator/doc/elb.rb +0 -18
  45. data/lib/awspec/generator/doc/rds.rb +0 -15
  46. data/lib/awspec/generator/doc/rds_db_parameter_group.rb +0 -15
  47. data/lib/awspec/generator/doc/route53_hosted_zone.rb +0 -15
  48. data/lib/awspec/generator/doc/route_table.rb +0 -15
  49. data/lib/awspec/generator/doc/s3.rb +0 -15
  50. data/lib/awspec/generator/doc/security_group.rb +0 -15
  51. data/lib/awspec/generator/doc/subnet.rb +0 -15
  52. data/lib/awspec/generator/doc/vpc.rb +0 -15
@@ -0,0 +1,33 @@
1
+ Aws.config[:ec2] = {
2
+ stub_responses: {
3
+ describe_vpcs: {
4
+ vpcs: [
5
+ {
6
+ vpc_id: 'vpc-ab123cde',
7
+ tags: [
8
+ {
9
+ key: 'Name',
10
+ value: 'my-vpc'
11
+ }
12
+ ]
13
+ }
14
+ ]
15
+ },
16
+ describe_subnets: {
17
+ subnets: [
18
+ {
19
+ state: 'available',
20
+ vpc_id: 'vpc-ab123cde',
21
+ subnet_id: 'subnet-1234a567',
22
+ cidr_block: '10.0.1.0/24',
23
+ tags: [
24
+ {
25
+ key: 'Name',
26
+ value: 'my-subnet'
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,69 @@
1
+ Aws.config[:ec2] = {
2
+ stub_responses: {
3
+ describe_vpcs: {
4
+ vpcs: [
5
+ {
6
+ vpc_id: 'vpc-ab123cde',
7
+ state: 'available',
8
+ cidr_block: '10.0.0.0/16',
9
+ tags: [
10
+ {
11
+ key: 'Name',
12
+ value: 'my-vpc'
13
+ }
14
+ ]
15
+ }
16
+ ]
17
+ },
18
+ describe_route_tables: {
19
+ route_tables: [
20
+ {
21
+ route_table_id: 'rtb-a12bcd34',
22
+ vpc_id: 'vpc-ab123cde',
23
+ routes: [
24
+ {
25
+ destination_cidr_block: '10.0.0.0/16',
26
+ destination_prefix_list_id: nil,
27
+ gateway_id: 'local',
28
+ instance_id: nil,
29
+ instance_owner_id: nil,
30
+ network_interface_id: nil,
31
+ vpc_peering_connection_id: nil,
32
+ state: 'active'
33
+ },
34
+ {
35
+ destination_cidr_block: '0.0.0.0/0',
36
+ destination_prefix_list_id: nil,
37
+ gateway_id: 'igw-1ab2345c',
38
+ instance_id: nil,
39
+ instance_owner_id: nil,
40
+ network_interface_id: nil,
41
+ vpc_peering_connection_id: nil,
42
+ state: 'active'
43
+ }
44
+ ],
45
+ tags: [
46
+ {
47
+ key: 'Name',
48
+ value: 'my-route-table'
49
+ }
50
+ ]
51
+ }
52
+ ]
53
+ },
54
+ describe_network_acls: {
55
+ network_acls: [
56
+ {
57
+ network_acl_id: 'acl-1abc2d3e',
58
+ vpc_id: 'vpc-ab123cde',
59
+ tags: [
60
+ {
61
+ key: 'Name',
62
+ value: 'my-network-acl'
63
+ }
64
+ ]
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,13 @@
1
+ module Awspec
2
+ class Toolbox < Thor
3
+ desc 'docgen', 'Generate type template files'
4
+ def docgen
5
+ puts Awspec::Generator::Doc::Type.generate_doc
6
+ end
7
+
8
+ desc 'template [resource_type_name]', 'Generate resource_type template files'
9
+ def template(type)
10
+ puts Awspec::Generator::Template.generate(type)
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -142,35 +142,38 @@ files:
142
142
  - bin/awspec
143
143
  - doc/_resource_types/ec2.md
144
144
  - doc/_resource_types/elb.md
145
+ - doc/_resource_types/rds_db_parameter_group.md
145
146
  - doc/_resource_types/security_group.md
146
147
  - doc/resource_types.md
147
148
  - lib/awspec.rb
149
+ - lib/awspec/bin/toolbox
148
150
  - lib/awspec/cli.rb
149
151
  - lib/awspec/command/generate.rb
150
- - lib/awspec/docgen.rb
151
152
  - lib/awspec/ext.rb
152
153
  - lib/awspec/ext/string.rb
153
154
  - lib/awspec/ext/struct.rb
154
155
  - lib/awspec/generator.rb
155
- - lib/awspec/generator/doc/auto_scaling_group.rb
156
- - lib/awspec/generator/doc/base.rb
157
- - lib/awspec/generator/doc/ebs.rb
158
- - lib/awspec/generator/doc/ec2.rb
159
- - lib/awspec/generator/doc/elb.rb
160
- - lib/awspec/generator/doc/rds.rb
161
- - lib/awspec/generator/doc/rds_db_parameter_group.rb
162
- - lib/awspec/generator/doc/route53_hosted_zone.rb
163
- - lib/awspec/generator/doc/route_table.rb
164
- - lib/awspec/generator/doc/s3.rb
165
- - lib/awspec/generator/doc/security_group.rb
166
- - lib/awspec/generator/doc/subnet.rb
167
- - lib/awspec/generator/doc/vpc.rb
156
+ - lib/awspec/generator/doc/type.rb
157
+ - lib/awspec/generator/doc/type/auto_scaling_group.rb
158
+ - lib/awspec/generator/doc/type/base.rb
159
+ - lib/awspec/generator/doc/type/ebs.rb
160
+ - lib/awspec/generator/doc/type/ec2.rb
161
+ - lib/awspec/generator/doc/type/elb.rb
162
+ - lib/awspec/generator/doc/type/rds.rb
163
+ - lib/awspec/generator/doc/type/rds_db_parameter_group.rb
164
+ - lib/awspec/generator/doc/type/route53_hosted_zone.rb
165
+ - lib/awspec/generator/doc/type/route_table.rb
166
+ - lib/awspec/generator/doc/type/s3.rb
167
+ - lib/awspec/generator/doc/type/security_group.rb
168
+ - lib/awspec/generator/doc/type/subnet.rb
169
+ - lib/awspec/generator/doc/type/vpc.rb
168
170
  - lib/awspec/generator/spec/ec2.rb
169
171
  - lib/awspec/generator/spec/elb.rb
170
172
  - lib/awspec/generator/spec/rds.rb
171
173
  - lib/awspec/generator/spec/route53_hosted_zone.rb
172
174
  - lib/awspec/generator/spec/security_group.rb
173
175
  - lib/awspec/generator/spec/vpc.rb
176
+ - lib/awspec/generator/template.rb
174
177
  - lib/awspec/helper.rb
175
178
  - lib/awspec/helper/finder.rb
176
179
  - lib/awspec/helper/finder/auto_scaling.rb
@@ -191,6 +194,20 @@ files:
191
194
  - lib/awspec/matcher/have_record_set.rb
192
195
  - lib/awspec/matcher/have_route.rb
193
196
  - lib/awspec/setup.rb
197
+ - lib/awspec/stub.rb
198
+ - lib/awspec/stub/auto_scaling_group.rb
199
+ - lib/awspec/stub/ebs.rb
200
+ - lib/awspec/stub/ec2.rb
201
+ - lib/awspec/stub/elb.rb
202
+ - lib/awspec/stub/rds.rb
203
+ - lib/awspec/stub/rds_db_parameter_group.rb
204
+ - lib/awspec/stub/route53_hosted_zone.rb
205
+ - lib/awspec/stub/route_table.rb
206
+ - lib/awspec/stub/s3.rb
207
+ - lib/awspec/stub/security_group.rb
208
+ - lib/awspec/stub/subnet.rb
209
+ - lib/awspec/stub/vpc.rb
210
+ - lib/awspec/toolbox.rb
194
211
  - lib/awspec/type/auto_scaling_group.rb
195
212
  - lib/awspec/type/base.rb
196
213
  - lib/awspec/type/ebs.rb
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'awspec'
4
-
5
- Aws.config[:stub_responses] = true
6
-
7
- types = Awspec::Helper::Type::TYPES
8
- types.delete('base')
9
-
10
- links = types.map do |type|
11
- '[' + type + '](#' + type + ')'
12
- end
13
- header = <<-'EOF'
14
- # Resource Types
15
-
16
- <%= links.join("\n| ") %>
17
-
18
- EOF
19
- puts ERB.new(header, nil, '-').result(binding)
20
-
21
- types.map do |type|
22
- puts eval "Awspec::Generator::Doc::#{type.to_camel_case}.new.generate_doc"
23
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class AutoScalingGroup < Base
4
- def initialize
5
- @type_name = 'AutoScalingGroup'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::AutoScalingGroup.new('my-auto-scaling-group')
8
- @ret = @type.group
9
- @matchers = []
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end
@@ -1,74 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Base
4
- def generate_doc
5
- @matchers += collect_matchers - @ignore_matchers
6
- @matchers.sort! do |a, b|
7
- sort_num(a) <=> sort_num(b)
8
- end
9
- @describes += @ret.members.select do |describe|
10
- next true unless @ret[describe].is_a?(Array) || @ret[describe].is_a?(Hash) || @ret[describe].is_a?(Struct)
11
- end if @ret.respond_to?(:members)
12
- its = @describes.map do |describe|
13
- 'its(:' + describe.to_s + ')'
14
- end
15
-
16
- @descriptions = {}
17
- merge_file = File.dirname(__FILE__) + '/../../../../doc/_resource_types/' + @type_name.to_snake_case + '.md'
18
- if File.exist?(merge_file)
19
- matcher = nil
20
- File.foreach(merge_file) do |line|
21
- if /\A### (.+)\Z/ =~ line
22
- matcher = Regexp.last_match[1]
23
- next
24
- end
25
- @descriptions[matcher] = '' unless @descriptions[matcher]
26
- @descriptions[matcher] += line
27
- end
28
- end
29
- ERB.new(doc_template, nil, '-').result(binding)
30
- end
31
-
32
- def collect_matchers
33
- methods = @type.methods - Awspec::Helper::Finder.instance_methods - Object.methods
34
- methods.select! do |method|
35
- method.to_s.include?('?')
36
- end
37
- methods.map! do |method|
38
- next 'exist' if 'exists?' == method.to_s
39
- next 'have_' + Regexp.last_match[1] if /\Ahas_(.+)\?\z/ =~ method.to_s
40
- next 'be_' + Regexp.last_match[1] if /\A(.+)\?\z/ =~ method.to_s
41
- method.to_s
42
- end
43
- end
44
-
45
- def doc_template
46
- template = <<-'EOF'
47
- ## <a name="<%= @type_name.to_snake_case %>"><%= @type_name.to_snake_case %></a>
48
-
49
- <%= @type_name %> resource type.
50
- <% @matchers.each do |matcher| %>
51
- ### <%= matcher %>
52
- <%- if @descriptions.include?(matcher) -%><%= @descriptions[matcher] %><%- end -%>
53
- <% end %>
54
- <%- unless its.empty? -%>#### <%= its.join(', ') %><%- end -%>
55
-
56
- EOF
57
- template
58
- end
59
-
60
- def sort_num(str)
61
- case str
62
- when 'exist'
63
- 0
64
- when /\Abe_/
65
- 1
66
- when /\Ahave_/
67
- 2
68
- else
69
- 3
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Ebs < Base
4
- def initialize
5
- @type_name = 'EBS'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::Ebs.new('my-ebs')
8
- @ret = @type.volume
9
- @matchers = []
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Ec2 < Base
4
- def initialize
5
- @type_name = 'EC2'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::Ec2.new('my-ec2')
8
- @ret = @type.instance
9
- @matchers = %w(belong_to_vpc belong_to_subnet)
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Elb < Base
4
- def initialize
5
- @type_name = 'ELB'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::Elb.new('my-elb')
8
- @ret = @type.lb
9
- @matchers = %w(belong_to_vpc belong_to_subnet)
10
- @ignore_matchers = []
11
- @describes = %w(
12
- health_check_target health_check_interval health_check_timeout
13
- health_check_unhealthy_threshold health_check_healthy_threshold
14
- )
15
- end
16
- end
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Rds < Base
4
- def initialize
5
- @type_name = 'RDS'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::Rds.new('my-rds')
8
- @ret = @type.instance
9
- @matchers = %w(belong_to_vpc belong_to_subnet belong_to_db_subnet_group)
10
- @ignore_matchers = []
11
- @describes = %w(vpc_id)
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class RdsDbParameterGroup < Base
4
- def initialize
5
- @type_name = 'RdsDbParameterGroup'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::RdsDbParameterGroup.new('my-rds-db-parameter-group')
8
- @ret = @type.parameters
9
- @matchers = []
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class Route53HostedZone < Base
4
- def initialize
5
- @type_name = 'Route53HostedZone'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::Route53HostedZone.new('example.com.')
8
- @ret = @type.hosted_zone
9
- @matchers = []
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Awspec::Generator
2
- module Doc
3
- class RouteTable < Base
4
- def initialize
5
- @type_name = 'RouteTable'
6
- require File.dirname(__FILE__) + '/../../../../spec/stub/' + @type_name.to_snake_case
7
- @type = Awspec::Type::RouteTable.new('my-route-table')
8
- @ret = @type.route_table
9
- @matchers = []
10
- @ignore_matchers = []
11
- @describes = []
12
- end
13
- end
14
- end
15
- end