Class: Moku6::Generators::CloudEventsGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/moku6/generators/cloud_events_generator.rb

Overview

Emits a CloudEvents (v1.0, structured JSON mode) validation JSON Schema per action. The CloudEvents ‘type` maps to the action and `data` carries the definition’s metadata (design section 13: CloudEvents conversion).

Constant Summary collapse

SPEC_VERSION =

: String

"1.0"

Constants inherited from BaseGenerator

BaseGenerator::AUTOGEN_NOTE

Instance Method Summary collapse

Methods inherited from BaseGenerator

#initialize, #render

Constructor Details

This class inherits a constructor from Moku6::Generators::BaseGenerator

Instance Method Details

#write(dir) ⇒ Object

: (String dir) -> String



16
17
18
19
20
21
22
23
# File 'lib/moku6/generators/cloud_events_generator.rb', line 16

def write(dir)
  FileUtils.mkdir_p(dir)
  @catalog.sorted.each do |e|
    File.write(File.join(dir, "#{e.action}.json"),
      JSON.pretty_generate(schema_for(e)) + "\n")
  end
  dir
end