Fix scripts and tests

* Fix the reformat script to work with recent changes
* Fix the convert-nei-dump script to remove leading and trailing '_'
* Fix various broken tests
This commit is contained in:
Andrew Miner
2015-01-21 15:05:19 -08:00
parent 3edba072d0
commit e612cedf8d
10 changed files with 46 additions and 31 deletions
@@ -5,6 +5,8 @@ Copyright (c) 2015 by Redwood Labs
All rights reserved.
###
StringBuilder = require '../../models/string_builder'
########################################################################################################################
module.exports = class CommandParserVersionBase
@@ -39,8 +41,8 @@ module.exports = class CommandParserVersionBase
return @_model
unparse: ->
builder = new StringBuilder context:@model
@_unparseModel builder, model
builder = new StringBuilder context:@_model
@_unparseModel builder, @_model
return builder.toString()
# Subclass Methods #############################################################################
@@ -180,26 +180,26 @@ module.exports = class ModVersionParserV1 extends CommandParserVersionBase
# Un-parsing Methods ###########################################################################
_unparseModVersion: (builder, modVersion)->
itemList = _.values modVersion.items
itemList.sort (a, b)-> a.compareTo b
itemList = []
modVersion.eachItem (item)-> itemList.push item
builder
.line 'schema: ', 2
.line 'name: ', modVersion.name
.line 'version: ', modVersion.version
.onlyIf modVersion.description?, => builder.line 'description: ', modVersion.description
.line 'schema: ', 1
.line()
.onlyIf itemList.length > 0, =>
builder.loop itemList, delimiter:'\n', onEach:(b, i)=> @_unparseItem(b, i)
.outdent()
_unparseItem: (builder, item)->
recipes = []
item.eachRecipe (recipe)-> recipes.push recipe
builder
.line 'item: ', item.name
.indent()
.onlyIf item.isGatherable, => builder.line 'gatherable: yes'
.onlyIf item.recipes.length > 0, =>
builder.loop item.recipes, delimiter:'', onEach:(b, r)=> @_unparseRecipe(b, r)
.onlyIf recipes.length > 0, =>
builder.loop recipes, delimiter:'', onEach:(b, r)=> @_unparseRecipe(b, r)
.outdent()
_unparseRecipe: (builder, recipe)->
@@ -32,7 +32,6 @@ module.exports = class VersionedParserBase
unparse: (schema=null)->
schema ?= @_currentSchema
if not modVersion? then throw new Error 'modVersion is required'
parser = @_parsers["#{schema}"]
if not parser? then throw new Error "version #{schema} is not supported"