awspec 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b3d9d3d91b24d597b96da00e431b0e310cf794f
4
- data.tar.gz: 0785e1cf39d5ca3bf095d1e5754a041b3ba21cfd
3
+ metadata.gz: 735ac3ea11197e0d21958bd387af953a77720760
4
+ data.tar.gz: 177f17845d8acacc5fc45e541dad53f4333109b0
5
5
  SHA512:
6
- metadata.gz: ba53ad476f870e0b357a0b7617138fed4154d81bde051ddca5c839dce279169ec1e10141f76375e962d352f2f0b09dc01d9d415bc637bc27555ff57d92651549
7
- data.tar.gz: 6d7fc1bee49c01b728327b5e2f76ee120107380da0fab1c56f761faa848922dc7317f47304d6b7fce7a418d8a15ae65a6b2aaffdb95d0a68bdadc04f96b8d4ad
6
+ metadata.gz: e8506223f8805c9daa7001cc9d5c2ffeb57fca18c02df41e4af06bfe88b305c8f7ea66bb7f20058c272e0749507297cff3ef7b0fb7612958a16dcc0f37587c88
7
+ data.tar.gz: 69f5c5c2289aab357c3479f0a08b4f48721dea1eb3c41f136d503c7d866cb2ef240beaf8eba68badc5467c21090cbf6aacec3cb172c9f32f3ccb6ceb3c45b49e
data/README.md CHANGED
@@ -100,8 +100,10 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
100
100
 
101
101
  [Resource Types more infomation here](doc/resource_types.md)
102
102
 
103
- ### Next..
103
+ ### Next..?
104
104
 
105
+ - [ ] ElastiCache
106
+ - [ ] CloudWatch
105
107
  - ...
106
108
 
107
109
  ## Contributing
data/awspec.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency 'rspec-its'
24
24
  spec.add_runtime_dependency 'aws-sdk', '~> 2'
25
25
  spec.add_runtime_dependency 'thor'
26
+ spec.add_runtime_dependency 'activesupport'
26
27
  spec.add_development_dependency 'bundler', '~> 1.9'
27
28
  spec.add_development_dependency 'rake', '~> 10.0'
28
29
  spec.add_development_dependency 'rubocop'
data/lib/awspec.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'rspec'
3
3
  require 'rspec/its'
4
4
  require 'time'
5
+ require 'active_support/inflector'
5
6
  require 'awspec/version'
6
7
  require 'awspec/cli'
7
8
  require 'awspec/stub'
@@ -12,7 +12,7 @@ module Awspec
12
12
  define_method type do |*args|
13
13
  load_secrets
14
14
  vpc_id = args.first
15
- eval "puts Awspec::Generator::Spec::#{type.to_camel_case}.new.generate_by_vpc_id(vpc_id)"
15
+ eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_by_vpc_id(vpc_id)"
16
16
  end
17
17
  end
18
18
 
data/lib/awspec/ext.rb CHANGED
@@ -1,2 +1 @@
1
- require 'awspec/ext/string'
2
1
  require 'awspec/ext/struct'
@@ -17,7 +17,7 @@ EOF
17
17
  doc = ERB.new(header, nil, '-').result(binding)
18
18
 
19
19
  types.map do |type|
20
- doc += eval "Awspec::Generator::Doc::Type::#{type.to_camel_case}.new.generate_doc"
20
+ doc += eval "Awspec::Generator::Doc::Type::#{type.camelize}.new.generate_doc"
21
21
  end
22
22
  doc
23
23
  end
@@ -3,7 +3,7 @@ module Awspec::Generator
3
3
  module Type
4
4
  class Base
5
5
  def initialize
6
- Awspec::Stub.load type_name.to_snake_case
6
+ Awspec::Stub.load type_name.underscore
7
7
  @type_name = type_name
8
8
  end
9
9
 
@@ -26,7 +26,7 @@ module Awspec::Generator
26
26
  end
27
27
 
28
28
  @descriptions = {}
29
- merge_file = File.dirname(__FILE__) + '/../../../../../doc/_resource_types/' + type_name.to_snake_case + '.md'
29
+ merge_file = File.dirname(__FILE__) + '/../../../../../doc/_resource_types/' + type_name.underscore + '.md'
30
30
  if File.exist?(merge_file)
31
31
  matcher = nil
32
32
  File.foreach(merge_file) do |line|
@@ -56,7 +56,7 @@ module Awspec::Generator
56
56
 
57
57
  def doc_template
58
58
  template = <<-'EOF'
59
- ## <a name="<%= @type_name.to_snake_case %>"><%= @type_name.to_snake_case %></a>
59
+ ## <a name="<%= @type_name.underscore %>"><%= @type_name.underscore %></a>
60
60
 
61
61
  <%= @type_name %> resource type.
62
62
  <%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>
@@ -11,11 +11,11 @@ module Awspec::Generator
11
11
  end
12
12
 
13
13
  def self.generate_type
14
- path = 'lib/awspec/type/' + @type.to_snake_case + '.rb'
14
+ path = 'lib/awspec/type/' + @type.underscore + '.rb'
15
15
  full_path = @root_path + path
16
16
  content = <<-"EOF"
17
17
  module Awspec::Type
18
- class #{@type.to_camel_case} < Base
18
+ class #{@type.camelize} < Base
19
19
  def initialize(id)
20
20
  super
21
21
  # @id = # @FIXME
@@ -27,7 +27,7 @@ EOF
27
27
  end
28
28
 
29
29
  def self.generate_stub
30
- path = 'lib/awspec/stub/' + @type.to_snake_case + '.rb'
30
+ path = 'lib/awspec/stub/' + @type.underscore + '.rb'
31
31
  full_path = @root_path + path
32
32
  content = <<-"EOF"
33
33
  # Aws.config[:ec2] = {
@@ -38,13 +38,13 @@ EOF
38
38
  end
39
39
 
40
40
  def self.generate_type_spec
41
- path = 'spec/type/' + @type.to_snake_case + '_spec.rb'
41
+ path = 'spec/type/' + @type.underscore + '_spec.rb'
42
42
  full_path = @root_path + path
43
43
  content = <<-"EOF"
44
44
  require 'spec_helper'
45
- Awspec::Stub.load '#{@type.to_snake_case}'
45
+ Awspec::Stub.load '#{@type.underscore}'
46
46
 
47
- describe #{@type.to_snake_case}('my-#{@type.to_snake_case.tr('_', '-')}') do
47
+ describe #{@type.underscore}('my-#{@type.underscore.tr('_', '-')}') do
48
48
  it { should exist }
49
49
  end
50
50
  EOF
@@ -52,17 +52,17 @@ EOF
52
52
  end
53
53
 
54
54
  def self.generate_generator_doc
55
- path = 'lib/awspec/generator/doc/type/' + @type.to_snake_case + '.rb'
55
+ path = 'lib/awspec/generator/doc/type/' + @type.underscore + '.rb'
56
56
  full_path = @root_path + path
57
57
  content = <<-"EOF"
58
58
  module Awspec::Generator
59
59
  module Doc
60
60
  module Type
61
- class #{@type.to_camel_case} < Base
61
+ class #{@type.camelize} < Base
62
62
  def initialize
63
63
  super
64
- @type_name = '#{@type.to_camel_case}'
65
- @type = Awspec::Type::#{@type.to_camel_case}.new('my-#{@type.to_snake_case.tr('_', '-')}')
64
+ @type_name = '#{@type.camelize}'
65
+ @type = Awspec::Type::#{@type.camelize}.new('my-#{@type.underscore.tr('_', '-')}')
66
66
  @ret = @type.resource
67
67
  @matchers = []
68
68
  @ignore_matchers = []
@@ -79,9 +79,9 @@ EOF
79
79
  def self.put_message
80
80
  content = <<-"EOF"
81
81
 
82
- Genarate #{@type.to_camel_case} template files.
82
+ Genarate #{@type.camelize} template files.
83
83
 
84
- * !! AND add '#{@type.to_snake_case}' to Awspec::Helper::Type::TYPES in awspec/lib/helper/type.rb *
84
+ * !! AND add '#{@type.underscore}' to Awspec::Helper::Type::TYPES in awspec/lib/helper/type.rb *
85
85
 
86
86
  EOF
87
87
  end
@@ -1,60 +1,22 @@
1
1
  module Awspec::Helper
2
2
  module Finder
3
3
  module Iam
4
- def find_iam_user(id)
5
- selected = []
6
- res = @iam_client.list_users
7
-
8
- loop do
9
- selected += res.users.select do |u|
10
- u.user_name == id || u.user_id == id || u.arn == id
11
- end
12
- (res.next_page? && res = res.next_page) || break
13
- end
14
-
15
- selected.first if selected.count == 1
16
- end
17
-
18
- def find_iam_group(id)
19
- selected = []
20
- res = @iam_client.list_groups
21
-
22
- loop do
23
- selected += res.groups.select do |g|
24
- g.group_name == id || g.group_id == id || g.arn == id
25
- end
26
- (res.next_page? && res = res.next_page) || break
27
- end
28
-
29
- selected.first if selected.count == 1
30
- end
31
-
32
- def find_iam_role(id)
33
- selected = []
34
- res = @iam_client.list_roles
35
-
36
- loop do
37
- selected += res.roles.select do |r|
38
- r.role_name == id || r.role_id == id || r.arn == id
4
+ # find_iam_user, find_iam_group find_iam_role find_iam_policy
5
+ role_types = %w(user group role policy)
6
+ role_types.each do |type|
7
+ define_method 'find_iam_' + type do |*args|
8
+ id = args.first
9
+ selected = []
10
+ res = @iam_client.method('list_' + type.pluralize).call
11
+ loop do
12
+ selected += res[type.pluralize].select do |u|
13
+ u[type + '_name'] == id || u[type + '_id'] == id || u.arn == id
14
+ end
15
+ (res.next_page? && res = res.next_page) || break
39
16
  end
40
- (res.next_page? && res = res.next_page) || break
41
- end
42
-
43
- selected.first if selected.count == 1
44
- end
45
-
46
- def find_iam_policy(id)
47
- selected = []
48
- res = @iam_client.list_policies
49
17
 
50
- loop do
51
- selected += res.policies.select do |p|
52
- p.policy_name == id || p.policy_id == id || p.arn == id
53
- end
54
- (res.next_page? && res = res.next_page) || break
18
+ selected.first if selected.count == 1
55
19
  end
56
-
57
- selected.first if selected.count == 1
58
20
  end
59
21
 
60
22
  def select_iam_group_by_user_name(user_name)
@@ -12,7 +12,7 @@ module Awspec
12
12
  require "awspec/type/#{type}"
13
13
  define_method type do |*args|
14
14
  name = args.first
15
- eval "Awspec::Type::#{type.to_camel_case}.new(name)"
15
+ eval "Awspec::Type::#{type.camelize}.new(name)"
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.10.1'
2
+ VERSION = '0.10.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.10.1
4
+ version: 0.10.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-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +166,6 @@ files:
152
166
  - lib/awspec/cli.rb
153
167
  - lib/awspec/command/generate.rb
154
168
  - lib/awspec/ext.rb
155
- - lib/awspec/ext/string.rb
156
169
  - lib/awspec/ext/struct.rb
157
170
  - lib/awspec/generator.rb
158
171
  - lib/awspec/generator/doc/type.rb
@@ -1,14 +0,0 @@
1
- class String
2
- def to_snake_case
3
- self.gsub(/::/, '/')
4
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
5
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
6
- .tr('-', '_')
7
- .downcase
8
- end
9
-
10
- def to_camel_case
11
- return self if self !~ /_/ && self =~ /[A-Z]+.*/
12
- split('_').map { |e| e.capitalize }.join
13
- end
14
- end