Sha256: c2b595db5e1f35eebbc93a6d8f5735468dffd3be718d5ff833298a91964a3dea
Contents?: true
Size: 1.03 KB
Versions: 8
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Polyn class Cli ## # Generates a new JSON Schema file for an event class SchemaGenerator < Thor::Group include Thor::Actions desc "Generates a new JSON Schema file for an event" argument :event_type, required: true class_option :dir, default: Dir.getwd source_root File.join(File.expand_path(__dir__), "../templates") def type @type ||= event_type.split("/").last end def subdir @subdir ||= begin split = event_type.split("/") - [type] split.join("/") end end def check_name Polyn::Cli::Naming.validate_event_type!(type) end def file_name @file_name ||= File.join(subdir, "#{type}.json") end def schema_id Polyn::Cli::Naming.dot_to_colon(type) end def create say "Creating new schema for #{file_name}" template "generators/schema.json", File.join(options.dir, "events/#{file_name}") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems