Module: Trailblazer::Generator::Macro
- Defined in:
- lib/trailblazer/generator/macro.rb
Constant Summary collapse
- REGEXP =
/^[A-Z][A-Za-z]{1,}(::[A-Z][A-Za-z]{1,})?/
- ERROR_INVALID_CLASS_NAME =
Plase, keep error codes sorted alphabetically
1
Class Method Summary collapse
Class Method Details
.Failure ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/trailblazer/generator/macro.rb', line 28 def self.Failure() step = ->(input, ) do puts "Error: " + ['failure_message'] ['error_code'] ? exit(['error_code']) : exit(1) end [ step, name: "failure" ] end |
.Output ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/trailblazer/generator/macro.rb', line 20 def self.Output() step = ->(input, ) do Trailblazer::Generator::Output.new(path: ['path'], content: ['content']).save end [ step, name: "output" ] end |
.ValidateClassName ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/trailblazer/generator/macro.rb', line 6 def self.ValidateClassName() step = ->(input, ) do if ["params"][:name].match REGEXP true else ['failure_message'] = 'You provided an invalid class name' ['error_code'] = ERROR_INVALID_CLASS_NAME false end end [ step, name: "validate_class_name" ] end |