Class: Awspec::Generator::Doc::Type::AccountAttribute

Inherits:
Base
  • Object
show all
Defined in:
lib/awspec/generator/doc/type/account_attribute.rb

Instance Method Summary collapse

Methods inherited from Base

#collect_matchers, #sort_num, #type_name

Constructor Details

#initializeAccountAttribute

Returns a new instance of AccountAttribute.



7
8
9
10
11
12
13
14
15
# File 'lib/awspec/generator/doc/type/account_attribute.rb', line 7

def initialize
  Awspec::Stub.load 'account'
  @type_name = 'Account Attribute'
  @type = Awspec::Type::.new
  @ret = Awspec::Type::.new.resource_via_client
  @matchers = []
  @ignore_matchers = []
  @describes = []
end

Instance Method Details

#account_attribute_spec_templateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/awspec/generator/doc/type/account_attribute.rb', line 23

def 
  "<% @ret.members.each do |key| %>\n<%- next if @ret[key].is_a?(String) -%>\ndescribe account_attribute('<%= key %>') do\n<% @ret[key].members.each do |attribute| %>\n<%- if @ret[key][attribute].is_a?(Array) -%>\n  its('<%= attribute %>') { should eq <%= @ret[key][attribute] %> }\n<%- elsif @ret[key][attribute].is_a?(String) -%>\n  its('<%= attribute %>') { should eq '<%= @ret[key][attribute] %>' }\n<%- elsif @ret[key][attribute].is_a?(Struct) -%>\n<% @ret[key][attribute].members.each do |k| %>\n  its('<%= attribute %>.<%= k %>') { should eq <%= @ret[key][attribute][k] %> }\n<% end %>\n<%- else -%>\n  its('<%= attribute %>') { should eq <%= @ret[key][attribute] %> }\n<%- end -%>\n<% end %>\nend\n<%= ' ' %>\n<% end %>\n"
end

#doc_templateObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/awspec/generator/doc/type/account_attribute.rb', line 47

def doc_template
  "## <a name=\"<%= @type_name.gsub(/ /, '_').underscore %>\"><%= @type_name.gsub(/ /, '_').underscore %></a>\n\n<%= @type_name %> resource type.\n<%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>\n\n```ruby\n<%= @account_attribute_spec %>```\n\n<% @matchers.each do |matcher| %>\n### <%= matcher %>\n<%- if @descriptions.include?(matcher) -%><%= @descriptions[matcher] %><%- end -%>\n<% end %>\n<%- if @descriptions.include?('advanced') -%>\n\n### :unlock: Advanced use\n<%= @descriptions['advanced'] %><%- end -%>\n"
end

#generate_docObject

rubocop:disable Layout/LineLength



18
19
20
21
# File 'lib/awspec/generator/doc/type/account_attribute.rb', line 18

def generate_doc
  @account_attribute_spec = ERB.new(, trim_mode: '-').result(binding).gsub(/^\n/, '')
  super
end