Class: Hexx::Validators::Generator

Inherits:
Generator
  • Object
show all
Defined in:
lib/hexx/validators/generator.rb

Overview

Scaffolder for a custom validator creates:

  • scope class definition in ‘app/validators`;

  • scope specification in ‘spec/tests/validators`.

Class Method Summary collapse

Class Method Details

.add_declarationObject



64
65
66
# File 'lib/hexx/validators/generator.rb', line 64

def add_declaration
  template "validator.erb", "app/#{ validator.path }.rb"
end

.add_specificationObject



59
60
61
# File 'lib/hexx/validators/generator.rb', line 59

def add_specification
  template "spec.erb", "spec/tests/#{ validator.path }_spec.rb"
end

.add_supportObject



54
55
56
# File 'lib/hexx/validators/generator.rb', line 54

def add_support
  directory "support", "spec/support", skip: true
end

.source_rootString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Root folder for the generator’s templates and description.

Returns:

  • (String)

    The absolute path to folder.



23
24
25
# File 'lib/hexx/validators/generator.rb', line 23

def self.source_root
  ::File.expand_path "../generator", __FILE__
end

.start(arguments) ⇒ undefined

Runs the scaffolder with a list of arguments from CLI.

Parameters:

  • arguments (Array<String>)

    The list of arguments from CLI.

Returns:

  • (undefined)


# File 'lib/hexx/validators/generator.rb', line 14