Permalink
Browse files

Support for aliases

  • Loading branch information...
1 parent 23ce7e1 commit 25d4903cbfbbb034c57893bbd9aae2f46676900f @fabianishere committed Oct 13, 2012
@@ -6,29 +6,7 @@
###
class Configuration
@NAME: "Kaffee"
- @VERSION: "0.3.2"
-
- ###
- Merges two objects into one.
-
- @since 0.3.0
- @param o Original object.
- @param a The object to merge it with.
- @return The result.
- ###
- @merge = (o, a) ->
- r = []
- for key, value of o
- r[key] = value
- return r if typeof o != 'object' || typeof a != 'object'
- for key, value of a
- if typeof o[key] == 'object'
- r[key] = @merge(o[key], value)
- else if typeof o[key] == 'array'
- r[key] = o[key].concat value
- else
- r[key] = value
- r
+ @VERSION: "0.3.3"
###
Default filename of the project configuration file.
@@ -74,22 +52,8 @@ class Configuration
parent: ""
###
- Childs of this project.
+ Child projects of this project.
###
modules: []
- ###
- Currently available archtypes.
- ###
- @ARCHTYPES:
- "default": @SUPER_PROJECT_CONFIG
- "kaffee-coffeemaker": @merge(@SUPER_PROJECT_CONFIG, {
- kaffee:
- plugins:
- "kaffee-coffeemaker" : {}
- lifecycles:
- "compile" : ["kaffee-coffeemaker:compile"]
- "test" : ["kaffee-coffeemaker:test"]
- })
-
module.exports = Configuration;
@@ -21,16 +21,16 @@ class ExecutionRequest
###
addGoal: (goal) ->
return if not goal
- this.goals.push goal if typeof goal is 'string'
- this.goals.concat goal if typeof goal is 'array'
+ @goals.push goal if typeof goal is 'string'
+ @goals.concat goal if typeof goal is 'array'
###
Returns the goals of this {@link ExecutionRequest}.
@since 0.2.1
@return The goals of this {@link ExecutionRequest}.
###
- getGoals: -> this.goals
+ getGoals: -> @goals
###
Sets the force field of this {@link ExecutionRequest}.
@@ -46,5 +46,5 @@ class ExecutionRequest
@since 0.2.1
@return <code>true</code> if Kaffee is forced, <code>false</code> otherwise.
###
- isForced: -> this.force
+ isForced: -> @force
module.exports = ExecutionRequest
@@ -13,24 +13,24 @@ class Result
@param parent The parent {@link Result} of this {@link Result}.
###
constructor: (@project) ->
- this.childs = []
- this.logs = []
+ @childs = []
+ @logs = []
###
Returns the {@link LogEvent}s of this {@link Result} instance.
@since 0.3.0
@return The {@link LogEvent}s of this {@link Result} instance.
###
- getLogs: -> this.logs
+ getLogs: -> @logs
###
Returns the {@link Project} of this {@link ProjectResult} instance.
@since 0.2.1
@return The {@link Project} of this {@link ProjectResult} instance.
###
- getProject: -> this.project
+ getProject: -> @project
###
Adds a child {@link Result} to this {@link Result} instance.
@@ -39,17 +39,17 @@ class Result
@param child The {@link Result} to add.
###
addChild: (child) ->
- return this.childs if not child
- return this.childs.push child if child instanceof Result
- return this.childs = this.childs.concat child
+ return @childs if not child
+ return @childs.push child if child instanceof Result
+ return @childs = @childs.concat child
###
Returns the child {@link Result}s of this {@link Result} instance.
@since 0.2.1
@return The child {@link Result}s of this {@link Result} instance.
###
- getChilds: -> this.childs
+ getChilds: -> @childs
###
Sets the result message of this {@link Result} instance.
@@ -65,6 +65,6 @@ class Result
@since 0.2.1
@return The result message of this {@link Result} instance.
###
- getMessage: -> this.message
+ getMessage: -> @message
module.exports = Result
@@ -14,47 +14,47 @@ class Goal
@param name The name of this {@link Goal}.
@param call The function of this {@link Goal}.
###
- constructor: (@plugin, @name, @call) -> this.event = new EventManager "goal-#{ name }", plugin.getEventManager(), this
+ constructor: (@plugin, @name, @call) -> @event = new EventManager "goal-#{ name }", plugin.getEventManager(), this
###
Returns the {@link Project} of this {@link Goal}.
@since 0.3.0
@return The {@link Project} of this {@link Goal}.
###
- getProject: -> this.getPlugin().getProject()
+ getProject: -> @getPlugin().getProject()
###
Returns the name of this {@link Goal}.
@since 0.2.1
@return The name of this {@link Goal}.
###
- getName: -> this.name
+ getName: -> @name
###
Returns the {@link Plugin} of this {@link Goal}.
@since 0.2.1
@return The {@link Plugin} of this {@link Goal}.
###
- getPlugin: -> this.plugin
+ getPlugin: -> @plugin
###
Returns the {@link EventManager} of this {@link Goal}.
@since 0.3.0
@return The {@link EventManager} of this {@link Goal}.
###
- getEventManager: -> this.event
+ getEventManager: -> @event
###
Returns the logging object of this {@link Goal}.
@since 0.3.1
@return The logging object of this {@link Goal}.
###
- getLogger: -> this.getEventManager().getLogger()
+ getLogger: -> @getEventManager().getLogger()
###
The {@link #dependsOn} methods should be called if
@@ -68,7 +68,7 @@ class Goal
dependsOn: (name, request) ->
return unless name
return name.attain? request
- this.getPlugin().getProject().attainGoal name, request
+ @getPlugin().getProject().attainGoal name, request
###
Attains this {@link Goal}.
@@ -78,17 +78,18 @@ class Goal
@return The result.
###
attain: (request) ->
- result = new Result this.getProject()
- this.event.fire "attain", this
- this.event.on "*log", (log) -> result.getLogs().push log
- this.logger = this.getLogger()
+ result = new Result @getProject()
+ @event.fire "attain", this
+ @event.on "*log", (log) -> result.getLogs().push log
+ @logger = @getLogger()
try
- throw new Error "Invalid Goal" unless this.call
- result.setMessage this.call.call(this, request)
+ throw new Error "Invalid Goal" unless @call
+ result.setMessage @call.call(this, request)
catch e
- this.getLogger().error e
- this.logger = undefined
- this.event.fire "attained", this, result
+ @getLogger().error e
+ result.time = Date.now()
+ @logger = undefined
+ @event.fire "attained", this, result
result
module.exports = Goal
@@ -33,8 +33,8 @@ class Plugin
try
# Modify path.
module.paths = process.mainModule.paths.concat module.paths, [Path.join @project.getConfiguration().getWorkspace().getPath(), "node_modules"]
- obj = require @name
- throw "Plugin " + @name + " is invalid." if typeof obj != 'function'
+ obj = require @getModule()
+ throw "Module #{ @getModule() } isn't a valid module." if typeof obj isnt 'function'
obj.call this, @configuration
catch e
@event.getLogger().error e
@@ -43,6 +43,21 @@ class Plugin
@event.fire "leave", this
true
+ ###
+ Returns the name of the module of this {@link Plugin}.
+
+ @since 0.3.3
+ @return The name of the module of this {@link Plugin}.
+ ###
+ getModule: -> @configuration.module or @name
+
+ ###
+ Returns the aliases of this {@link Plugin}.
+
+ @since 0.3.3
+ @return The aliases of this {@link Plugin}.
+ ###
+ getAliases: -> @configuration.alias or []
###
Returns the name of this {@link Plugin}.
@@ -102,12 +117,37 @@ class Plugin
getGoal: (name) -> return goal for goal in @goals when goal.getName() is name
###
- Determines if this {@link Project} has a {@link Plugin}.
+ Determines if this {@link Plugin} has a {@link Goal}.
@since 0.2.1
@param name The name of the {@link Goal}.
+ @return <code>true</code> if this {@link Plugin} has this {@link Goal}, <code>false</code> otherwise.
###
hasGoal: (name) -> !!@getGoal name
+
+ ###
+ Determines if this {@link Plugin} has defined an archtype.
+
+ @since 0.3.3
+ @return <code>true</code> if this {@link Plugin} has defined an archtype, <code>false</code> otherwise.
+ ###
+ hasArchtype: -> !!@archtype
+
+ ###
+ Returns the archtype of this {@link Plugin}.
+
+ @since 0.3.3
+ @return The archtype of this {@link Plugin} if it has one.
+ ###
+ getArchtype: -> @archtype
+
+ ###
+ Defines an archtype.
+
+ @since 0.3.3
+ @param archtype The archtype to define.
+ ###
+ archtype: (archtype) -> @archtype = archtype if typeof archtype is 'object'
###
Registers a goal.
Oops, something went wrong.

0 comments on commit 25d4903

Please sign in to comment.