Several large refactorings

* Refactor location of all data files to include a subdirectory
  for the mod version
* Update the BaseModel class to allow models to load themselves from
  any text file (whether JSON or CG)
* Refactor ModPack & ModVersion to move the laoding functionality in
  one into the other (and use the new stuff in BaseModel)
* Move the parser versions into a new subdirectory which allows for
  future additional parsers
This commit is contained in:
Andrew Miner
2015-01-16 20:26:54 -08:00
parent c14997ef90
commit 5f57622cf3
954 changed files with 284 additions and 1239 deletions
+28
View File
@@ -0,0 +1,28 @@
###
Crafting Guide - mod.coffee
Copyright (c) 2015 by Redwood Labs
All rights reserved.
###
BaseModel = require './base_model'
########################################################################################################################
module.exports = class Mod extends BaseModel
constructor: (attributes={}, options={})->
if not attributes.name? then throw new Error 'attributes.name is required'
attributes.id = attributes.slug = _.slugify attributes.name
super attributes, options
# Backbone.View Overrides ######################################################################
parse: (response)->
sync: (method, model, options={})->
if method isnt 'read' then throw new Error "Mod data can only be read, not #{method}d"
super method, model, options
url: ->
return "/data/#{@slug}/mod.cg"