Class: AboutYml::TemplateGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/about_yml/template_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTemplateGenerator

Returns a new instance of TemplateGenerator.



10
11
12
13
14
# File 'lib/about_yml/template_generator.rb', line 10

def initialize
  @schema = ::AboutYml::AboutFile.schema
  @properties = schema['properties']
  @required = schema['required']
end

Instance Attribute Details

#propertiesObject (readonly)

Returns the value of attribute properties.



9
10
11
# File 'lib/about_yml/template_generator.rb', line 9

def properties
  @properties
end

#requiredObject (readonly)

Returns the value of attribute required.



9
10
11
# File 'lib/about_yml/template_generator.rb', line 9

def required
  @required
end

#schemaObject (readonly)

Returns the value of attribute schema.



9
10
11
# File 'lib/about_yml/template_generator.rb', line 9

def schema
  @schema
end

Instance Method Details

#definition_properties(item_ref) ⇒ Object



21
22
23
# File 'lib/about_yml/template_generator.rb', line 21

def definition_properties(item_ref)
  schema['definitions'][item_ref.split('/').last]['properties']
end

#generateObject



16
17
18
19
# File 'lib/about_yml/template_generator.rb', line 16

def generate
  props = properties.map { |name, defn| generate_item name, defn }
  "---\n# #{schema['description']}\n#\n#{props.join "\n\n"}"
end