###
	generator-joomla-spc

	index.coffee

	@author Sean Goresht

	@note uses Codoc
	@see https://github.com/mklabs/yeoman/wiki/generators coffeescript with yeoman
	@see https://github.com/coffeedoc/codo
###

(->
  'use strict'
  # coffeelint: disable=max_line_length
  ModelGenerator = undefined
  path = undefined
  yeoman = undefined

  extend = (child, parent) ->

    Ctor = ->
      @constructor = child
      return

    for key of parent
      if hasProp.call(parent, key)
        child[key] = parent[key]
    Ctor.prototype = parent.prototype
    child.prototype = new Ctor()
    child.__super__ = parent.prototype
    child

  hasProp = {}.hasOwnProperty
  yeoman = require('yeoman-generator')
  yosay = require('yosay')
  chalk = require('chalk')
  path = require('path')

  ###
  	@class ModelGenerator sub-generator for joomla spc controllers
  ###

  module.exports = ModelGenerator = ((superClass) ->
    'var ModelGenerator'

    ModelGenerator = (args, options, config) ->
      pkg = undefined
      ref = undefined
      ref1 = undefined
      ref2 = undefined
      ref3 = undefined
      ModelGenerator.__super__.constructor.call this, args, options, config
      pkg = JSON.parse(@readFileAsString(path.join(process.cwd(), './package.json')))
      @componentName = pkg.componentName
      @description = pkg.description
      @requireManageRights = pkg.requireManageRights
      @authorName = if (ref = pkg.author) != null then ref.name else undefined
      @authorEmail = if (ref1 = pkg.author) != null then ref1.email else undefined
      @authorURL = if (ref2 = pkg.author) != null then ref2.url else undefined
      @license = if (ref3 = pkg.licenses[0]) != null then ref3.type else undefined
      @currentYear = (new Date()).getFullYear()
      @modelName = @_.slugify(@name)
      @modelClassName = @_.classify(@name)
      # @log(yosay(chalk.white('You called the model subgenerator with the argument ' + @name + '.\nNow let\'s create that model as models/' + @modelName + '.php for you...')))

      @log 'You called the model subgenerator with the argument ' + @name + '.\nNow let\'s create that model as models/' + @modelName + '.php for you...'
      return

    extend ModelGenerator, superClass

    ModelGenerator::generateModel = ->
      @template '_model.php', 'app/admin/' + 'models/' + @modelName + '.php'
      @template '_model.php', 'app/site/' + 'models/' + @modelName + '.php'

    ModelGenerator
  )(yeoman.generators.NamedBase)
  return
).call this

# ---
# generated by js2coffee 2.1.0
