generator-joomla-spc
Version:
Joomla-spc generator for Yeoman. Creates Joomla 2.5 and 3.0 files
82 lines (66 loc) • 2.55 kB
text/coffeescript
###
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
HelperGenerator = 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 HelperGenerator sub-generator for joomla spc controllers
###
module.exports = HelperGenerator = ((superClass) ->
'var HelperGenerator'
HelperGenerator = (args, options, config) ->
pkg = undefined
ref = undefined
ref1 = undefined
ref2 = undefined
ref3 = undefined
HelperGenerator.__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()
@helperName = @_.slugify(@name)
@helperClassName = @_.classify(@name)
# @log(yosay(chalk.white('You called the helper subgenerator with the argument ' + @name + '.\nNow let\'s create that helper as helpers/' + @helperName + '.php for you...')))
@log 'You called the helper subgenerator with the argument ' + @name + '.\nNow let\'s create that helper as helpers/' + @helperName + '.php for you...'
return
extend HelperGenerator, superClass
HelperGenerator::generateHelper = ->
@template '_helper.php', 'app/admin/helpers/' + @helperName + '.php'
@template '_helper.php', 'app/site/helpers/' + @helperName + '.php'
HelperGenerator
)(yeoman.generators.NamedBase)
return
).call this
# ---
# generated by js2coffee 2.1.0