Sha256: a2bb9adc20ef5c8e8837069a34d2edc04700290c529e95b7b90f313c3393c3d8

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

# Namespace for all the classess
# @since 0.0.3
module BackboneGenerator

    # Abstract base class for generating
    # routes A.K.A copying template
    # @author Tawheed Abdul-Raheem
    class RouteGenerator

        class << self
            def create_route route_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
                template_path = File.expand_path(File.dirname(__FILE__)) + "/template/Routes.tt"
                target_path = "/js/routes/" + route_name + ".Route.js"
                route_hash = {
                    :app_name  => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
                    :route_name => route_name.slice(0,1).capitalize + route_name.slice(1..-1),
                }

                if File.exists? dir_path + target_path
                    print "error ".red
                    puts "Route with the name specified already exists"
                else
                    BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, route_hash)
                    print "created ".green
                    puts  route_hash[:app_name] + target_path
                end
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backbone_generator-0.0.4 lib/backbone_generator/generators/route/route_generator.rb