Class: Castkit::CLI::Generate

Inherits:
Thor
  • Object
show all
Defined in:
lib/castkit/cli/generate.rb

Overview

Thor CLI class for generating Castkit components.

Provides ‘castkit generate` commands for each major Castkit component, including types, data objects, contracts, validators, serializers, and plugins.

All generators support the ‘–no-spec` flag to skip spec file creation.

Instance Method Summary collapse

Instance Method Details

#contract(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new contract class.

Parameters:

  • name (String)

    the class name for the contract

  • fields (Array<String>)

    optional attribute definitions



27
28
29
30
31
# File 'lib/castkit/cli/generate.rb', line 27

def contract(name, *fields)
  args = [Castkit::Inflector.pascalize(name), fields]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::Contract.start(args)
end

#dataobject(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new DataObject class.

Parameters:

  • name (String)

    the class name for the data object

  • fields (Array<String>)

    optional attribute definitions



40
41
42
43
44
# File 'lib/castkit/cli/generate.rb', line 40

def dataobject(name, *fields)
  args = [Castkit::Inflector.pascalize(name), fields]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::DataObject.start(args)
end

#plugin(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new plugin module.

Parameters:

  • name (String)

    the module name for the plugin

  • fields (Array<String>)

    optional stub fields



53
54
55
56
57
# File 'lib/castkit/cli/generate.rb', line 53

def plugin(name, *fields)
  args = [Castkit::Inflector.pascalize(name), fields]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::Plugin.start(args)
end

#serializer(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new custom serializer class.

Parameters:

  • name (String)

    the class name for the serializer

  • fields (Array<String>)

    optional stub fields



66
67
68
69
70
# File 'lib/castkit/cli/generate.rb', line 66

def serializer(name, *fields)
  args = [Castkit::Inflector.pascalize(name), fields]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::Serializer.start(args)
end

#type(name) ⇒ void

This method returns an undefined value.

Generates a new custom type.

Parameters:

  • name (String)

    the class name for the type



78
79
80
81
82
# File 'lib/castkit/cli/generate.rb', line 78

def type(name)
  args = [Castkit::Inflector.pascalize(name)]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::Type.start(args)
end

#validator(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new validator class.

Parameters:

  • name (String)

    the class name for the validator

  • fields (Array<String>)

    optional stub fields



91
92
93
94
95
# File 'lib/castkit/cli/generate.rb', line 91

def validator(name, *fields)
  args = [Castkit::Inflector.pascalize(name), fields]
  args << "--no-spec" unless options[:spec]
  Castkit::Generators::Validator.start(args)
end