Sha256: 532156d9c151e8e84d38436ca9f7c47ff23079ee8c1d6328d93da40260ed0de4

Contents?: true

Size: 1.96 KB

Versions: 14

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

module Awspec::Generator
  module Doc
    module Type
      class AccountAttribute < Base
        def initialize
          Awspec::Stub.load 'account'
          @type_name = 'Account Attribute'
          @type = Awspec::Type::Account.new
          @ret = Awspec::Type::Account.new.resource_via_client
          @matchers = []
          @ignore_matchers = []
          @describes = []
        end

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

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

        def doc_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_attribute_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
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
awspec-1.32.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.31.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.30.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.29.3 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.29.2 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.29.1 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.29.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.28.2 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.28.1 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.28.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.27.1 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.27.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.26.0 lib/awspec/generator/doc/type/account_attribute.rb
awspec-1.25.2 lib/awspec/generator/doc/type/account_attribute.rb