Sha256: c8e78d7b27b6b627c9364c304d5f38760ba344be28fd9f04f9f4d929c2068608

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

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 check_name
        Polyn::Cli::Naming.validate_event_type!(event_type)
      end

      def file_name
        @file_name ||= "#{event_type}.json"
      end

      def schema_id
        Polyn::Cli::Naming.dot_to_colon(event_type)
      end

      def create
        say "Creating new schema for #{event_type}"
        template "generators/schema.json", File.join(options.dir, "events/#{event_type}.json")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polyn-cli-0.1.1 lib/polyn/cli/schema_generator.rb
polyn-cli-0.1.0 lib/polyn/cli/schema_generator.rb