Convert codebase to using ItemSlug

* Flesh out the formerly incomplete ItemSlug class
* Convert all uses of text item slugs to use ItemSlug
* Move the ItemSlug class under models where it properly belongs
* Avoid the use of `slug` as a local variable or item attribute
  wherever possible to avoid confusion between various kinds of slugs
* Merge the InventoryParser class into the Inventory class as it is
  unlikely to need to support multiple versions
* Simplify the ModPack/Mod/ModVersion interfaces by replacing the use
  of various "helper" methods with equivalent use of more generic
  methods
* Update the various methods of ModPack/Mod/ModVersion to be able to
  work with qualified or unqualified ItemSlugs
* Remove the unused BaseCollection class
* Add tests for ItemSlug and update all other tests to reflect
  all the other changes
This commit is contained in:
Andrew Miner
2015-02-18 10:30:53 -08:00
parent 100ce1bc70
commit e88821d449
33 changed files with 624 additions and 535 deletions
+5 -5
View File
@@ -87,13 +87,13 @@ module.exports = class Mod extends BaseModel
return unless @_activeModVersion?
@_activeModVersion.findItemByName name
findName: (slug)->
findName: (itemSlug)->
return unless @_activeModVersion?
@_activeModVersion.findName slug
@_activeModVersion.findName itemSlug
findRecipes: (slug, result=[])->
findRecipes: (itemSlug, result=[])->
return result unless @_activeModVersion?
@_activeModVersion.findRecipes slug, result
@_activeModVersion.findRecipes itemSlug, result
# Property Methods #############################################################################
@@ -123,6 +123,7 @@ module.exports = class Mod extends BaseModel
for modVersion in @_modVersions
return modVersion if modVersion.version is version
return null
getActiveVersion: ->
@@ -150,7 +151,6 @@ module.exports = class Mod extends BaseModel
@trigger Event.change + ':activeVersion', this, @_activeVersion
@trigger Event.change, this
# Backbone.View Overrides ######################################################################
parse: (text)->