Class: EWorld::ApiDocsWriter

Inherits:
BaseWriter show all
Defined in:
lib/writers/api_docs_writer.rb

Constant Summary

Constants inherited from BaseWriter

BaseWriter::CLASS, BaseWriter::CLASS_LOWER, BaseWriter::IMPORTS, BaseWriter::PACKAGE

Class Method Summary collapse

Methods inherited from BaseWriter

get_java_path_for

Class Method Details

.write(api_project, ui_project, controllers) ⇒ Object

Responsible for writing all the spring boot @RestController classes.

Returns:

  • void

Raises:

  • (RuntimeError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/writers/api_docs_writer.rb', line 7

def self.write(api_project, ui_project, controllers)
    raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_API_SIMPLE}, instead got: #{api_project[Blufin::Projects::TYPE]}" unless api_project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_API_SIMPLE
    raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_QUASAR}, instead got: #{ui_project[Blufin::Projects::TYPE]}" unless ui_project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_QUASAR
    @generated          = []
    @overwritten        = []
    @project_path       = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID])
    @project_path_api   = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID], true)
    @project_path_ui    = Blufin::Projects::get_project_path(ui_project[Blufin::Projects::PROJECT_ID], true)
    @transient_data_api = api_project[Blufin::Projects::TRANSIENT_DATA]
    @transient_data_ui  = ui_project[Blufin::Projects::TRANSIENT_DATA]

    # TODO - This needs better data...
    @data = controllers

    target_file = "#{@project_path}/#{Blufin::Strings::remove_surrounding_slashes(@transient_data_ui[Blufin::Projects::CG_QUASAR_ROOT])}/#{Blufin::Strings::remove_surrounding_slashes(@transient_data_ui[Blufin::Projects::CG_QUASAR_API_DOCS_FILE])}"

    # Write the file.
    @overwritten << target_file if Blufin::Files::write_file_if_changed(target_file, Blufin::Arrays::convert_string_to_line_array(JSON.pretty_generate(@data, { indent: '    ' })), write_empty_trailing_line: true)

    return @generated, @overwritten

end