Class: Puer::Generators::Model

Inherits:
Jam
  • Object
show all
Includes:
CLIColorize
Defined in:
lib/puer/generators/model.rb

Instance Method Summary collapse

Methods inherited from Jam

attr_rw, banner, #create_jam, #in_app_root?, init_generator, parseTemplate, source_root

Instance Method Details

#create_modelObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/puer/generators/model.rb', line 30

def create_model
  if in_app_root?
    valid_constant?(options[:model] || name)
    @model_name = (options[:model] || name).gsub(/\W/, "_").downcase
    @class_name = (options[:model] || name).gsub(/\W/, "_").capitalize
    @developer = "#{`whoami`.strip}"
    @created_on = Date.today.to_s
    self.destination_root = options[:root]
    self.behavior = :revoke if options[:destroy]
    
    puts colorize( "Puer Version: #{Puer::Version::STRING}", { :foreground => :red, :background => :white, :config => :underline } )
    puts          
    eval(File.read(__FILE__) =~ /^__END__\n/ && $' || '')

    say (<<-TEXT).gsub(/ {10}/,'')

=================================================================
Your [#{@model_name.capitalize}] Model has been generated.
Build and Run
=================================================================

  TEXT
  else 
    puts
    puts '-'*70
    puts "You are not in a titanium project folder"
    puts '-'*70
    puts
  end
end