Class: BackboneGenerator::ModelGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/backbone_generator/generators/models/models_generator.rb,
lib/backbone_generator/generators/library/library_generator.rb

Overview

Abstract base class for fetching javascript libaries from the internet

Author:

  • Tawheed Abdul-Raheem

Since:

  • 0.0.3

Class Method Summary collapse

Class Method Details

.create_model(model_name) ⇒ Object

Since:

  • 0.0.3



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/backbone_generator/generators/models/models_generator.rb', line 11

def create_model model_name
    app_name  = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/")
    if BackboneGenerator.option_details[:app_name]
        dir_path = File.join(Dir.getwd, app_name)
    else
        dir_path = File.join(Dir.getwd)
    end
    model_hash = {
        :app_name  => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
        :model_name => model_name.slice(0,1).capitalize + model_name.slice(1..-1),
    }
    template_path = File.expand_path(File.dirname(__FILE__)) + "/template/Model.tt"
    target_path = "/js/models/" + model_hash[:model_name] + ".Model.js"
    if File.exist? dir_path + target_path
        print "error ".red
        puts "Model with the name specified already exists"
    else
        BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, model_hash)
        print "created ".green
        puts  model_hash[:app_name] + target_path
    end
end

.fetch_library(library_name) ⇒ Object

Since:

  • 0.0.3



11
12
13
14
# File 'lib/backbone_generator/generators/library/library_generator.rb', line 11

def fetch_library library_name
    print "NOTICE ".yellow
    puts "Will be implemented in the next Release"
end