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

#attribute(name, *fields) ⇒ void

This method returns an undefined value.

Generates a new attribute definition class.

Parameters:

  • name (String)

    the class name for the attribute

  • fields (Array<String>)

    optional attribute options



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

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

#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



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

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



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

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



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

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



80
81
82
83
84
# File 'lib/castkit/cli/generate.rb', line 80

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



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

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



105
106
107
108
109
# File 'lib/castkit/cli/generate.rb', line 105

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