Class: JsonSchemaDocs::Generator
- Inherits:
-
Object
- Object
- JsonSchemaDocs::Generator
- Includes:
- Helpers
- Defined in:
- lib/json-schema-docs/generator.rb
Constant Summary
Constants included from Helpers
Helpers::SLUGIFY_PRETTY_REGEXP
Instance Attribute Summary collapse
-
#parsed_schema ⇒ Object
Returns the value of attribute parsed_schema.
Attributes included from Helpers
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(parsed_schema, options) ⇒ Generator
constructor
A new instance of Generator.
Methods included from Helpers
Constructor Details
#initialize(parsed_schema, options) ⇒ Generator
Returns a new instance of Generator.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/json-schema-docs/generator.rb', line 10 def initialize(parsed_schema, ) @parsed_schema = parsed_schema = i(endpoint object).each do |sym| if !File.exist?([:templates][sym]) raise IOError, "`#{sym}` template #{@options[:templates][sym]} was not found" end instance_variable_set("@json_schema_#{sym}_template", ERB.new(File.read([:templates][sym]), nil, '-')) end end |
Instance Attribute Details
#parsed_schema ⇒ Object
Returns the value of attribute parsed_schema.
8 9 10 |
# File 'lib/json-schema-docs/generator.rb', line 8 def parsed_schema @parsed_schema end |
Instance Method Details
#generate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/json-schema-docs/generator.rb', line 22 def generate FileUtils.rm_rf([:output_dir]) if [:delete_output] @parsed_schema.each_pair do |resource, schemata| i(endpoint object).each do |type| contents = render(type, resource, schemata) write_file(type, resource, contents) contents = render(type, resource, schemata) write_file(type, resource, contents) end end end |