Class: Awspec::Generator::Doc::Type::Account

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

Instance Method Summary collapse

Methods inherited from Base

#collect_matchers, #sort_num, #type_name

Constructor Details

#initializeAccount

Returns a new instance of Account.



5
6
7
8
9
10
11
12
13
# File 'lib/awspec/generator/doc/type/account.rb', line 5

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

Instance Method Details

#account_spec_templateObject



20
21
22
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.rb', line 20

def 
  template = <<-'EOF'
describe account do
<% @ret.members.each do |key| %>
<%- if @ret[key].is_a?(String) -%>
  its(:<%= key %>) { should eq '<%= @ret[key] %>' }
<%- else -%>
<% @ret[key].members.each do |attribute| %>
<%- if @ret[key][attribute].is_a?(Array) -%>
  its('<%= key %>.<%= attribute %>') { should eq <%= @ret[key][attribute] %> }
<%- elsif @ret[key][attribute].is_a?(String) -%>
  its('<%= key %>.<%= attribute %>') { should eq '<%= @ret[key][attribute] %>' }
<%- elsif @ret[key][attribute].is_a?(Struct) -%>
<% @ret[key][attribute].members.each do |k| %>
  its('<%= key %>.<%= attribute %>.<%= k %>') { should eq <%= @ret[key][attribute][k] %> }
<% end %>
<%- else -%>
  its('<%= key %>.<%= attribute %>') { should eq <%= @ret[key][attribute] %> }
<%- end -%>
<% end %>
<% end %>
<%- end -%>
end
EOF
  template
end

#doc_templateObject



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

def doc_template
  template = <<-'EOF'
## <a name="<%= @type_name.gsub(/ /, '_').underscore %>"><%= @type_name.gsub(/ /, '_').underscore %></a>

<%= @type_name %> resource type.
<%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>

```ruby
<%= @account_spec %>```

<% @matchers.each do |matcher| %>
### <%= matcher %>
<%- if @descriptions.include?(matcher) -%><%= @descriptions[matcher] %><%- end -%>
<% end %>
<%- if @descriptions.include?('advanced') -%>

### :unlock: Advanced use
<%= @descriptions['advanced'] %><%- end -%>
EOF
  template
end

#generate_docObject



15
16
17
18
# File 'lib/awspec/generator/doc/type/account.rb', line 15

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