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.



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.



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.



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.



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.



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.



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.



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