diff --git a/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt b/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt index 138e5ce..87c2d36 100644 --- a/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt +++ b/src/main/kotlin/info/mking/k2zpl/builder/Extensions.kt @@ -2,39 +2,9 @@ package info.mking.k2zpl.builder -import info.mking.k2zpl.command.ZplCommand -import info.mking.k2zpl.command.options.ZplFont import info.mking.k2zpl.command.options.ZplYesNo -/** - * Shortcut for addCommand - */ -fun ZplBuilder.command(command: ZplCommand) { - addCommand(command) -} - -/** - * Shortcut for addCommand for string - */ -fun ZplBuilder.command(command: String) { - addCommand(command) -} - -/** - * Shortcut for addField - */ -fun ZplBuilder.field(x: Int = 0, y: Int = 0, data: String) { - addField(x, y, data) -} - -/** - * Shortcut for addField with font attributes - */ -fun ZplBuilder.field(x: Int, y: Int, font: ZplFont, fontHeight: Int, fontWidth: Int, data: String) { - addField(x, y, font, fontHeight, fontWidth, data) -} - -internal fun Boolean.toZplYesNo(): ZplYesNo = when(this) { +internal fun Boolean.toZplYesNo(): ZplYesNo = when (this) { true -> ZplYesNo.YES else -> ZplYesNo.NO } \ No newline at end of file diff --git a/src/main/kotlin/info/mking/k2zpl/builder/ZplBuilder.kt b/src/main/kotlin/info/mking/k2zpl/builder/ZplBuilder.kt index a733790..5cc43b1 100644 --- a/src/main/kotlin/info/mking/k2zpl/builder/ZplBuilder.kt +++ b/src/main/kotlin/info/mking/k2zpl/builder/ZplBuilder.kt @@ -30,12 +30,12 @@ class ZplBuilder { _zplDpiSetting = value } - fun addCommand(command: ZplCommand) { + fun command(command: ZplCommand) { commands.add(command) } - fun addCommand(commandString: String) { - addCommand(CustomCommand(commandString)) + fun command(commandString: String) { + command(CustomCommand(commandString)) } fun build() = buildString { @@ -91,7 +91,7 @@ class ZplBuilder { /** * Adds a field with specified font and size. */ - fun addField(x: Int, y: Int, font: ZplFont, fontHeight: Int, fontWidth: Int, data: String) { + fun field(x: Int, y: Int, font: ZplFont, fontHeight: Int, fontWidth: Int, data: String) { fieldOrigin(x, y) font(font, defaultFont.orientation, fontHeight, fontWidth) fieldData(data) @@ -101,7 +101,7 @@ class ZplBuilder { /** * Adds a field with the default font. */ - fun addField(x: Int = 0, y: Int = 0, data: String) { + fun field(x: Int = 0, y: Int = 0, data: String) { fieldOrigin(x, y) font(defaultFont.font, defaultFont.orientation, defaultFont.height, defaultFont.width) fieldData(data) diff --git a/src/main/kotlin/info/mking/k2zpl/command/BarCode.kt b/src/main/kotlin/info/mking/k2zpl/command/BarCode.kt index 969863b..5ec3e7c 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/BarCode.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/BarCode.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.builder.toZplYesNo import info.mking.k2zpl.command.options.ZplBarcodeType import info.mking.k2zpl.command.options.ZplFieldOrientation diff --git a/src/main/kotlin/info/mking/k2zpl/command/EndFormat.kt b/src/main/kotlin/info/mking/k2zpl/command/EndFormat.kt index 64fe768..04d9f39 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/EndFormat.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/EndFormat.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data object EndFormat : ZplCommand { override val command: CharSequence = "^XZ" diff --git a/src/main/kotlin/info/mking/k2zpl/command/FieldBlock.kt b/src/main/kotlin/info/mking/k2zpl/command/FieldBlock.kt index 077c882..a4bb8fd 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/FieldBlock.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/FieldBlock.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.command.options.ZplTextAlignment internal data class FieldBlock( diff --git a/src/main/kotlin/info/mking/k2zpl/command/FieldData.kt b/src/main/kotlin/info/mking/k2zpl/command/FieldData.kt index 7f8c38e..5f747db 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/FieldData.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/FieldData.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data class FieldData(val data: String) : ZplCommand { override val command: CharSequence = "^FD" diff --git a/src/main/kotlin/info/mking/k2zpl/command/FieldOrigin.kt b/src/main/kotlin/info/mking/k2zpl/command/FieldOrigin.kt index f8cd4a5..ec94eab 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/FieldOrigin.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/FieldOrigin.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.command.options.ZplJustification internal data class FieldOrigin( diff --git a/src/main/kotlin/info/mking/k2zpl/command/FieldSeparator.kt b/src/main/kotlin/info/mking/k2zpl/command/FieldSeparator.kt index 4c6171d..6016434 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/FieldSeparator.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/FieldSeparator.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data object FieldSeparator : ZplCommand { override val command: CharSequence = "^FS" diff --git a/src/main/kotlin/info/mking/k2zpl/command/Font.kt b/src/main/kotlin/info/mking/k2zpl/command/Font.kt index 9cf6afa..d64e5d8 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/Font.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/Font.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.command.options.ZplFieldOrientation import info.mking.k2zpl.command.options.ZplFont diff --git a/src/main/kotlin/info/mking/k2zpl/command/GraphicBox.kt b/src/main/kotlin/info/mking/k2zpl/command/GraphicBox.kt index d4ad176..a420780 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/GraphicBox.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/GraphicBox.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.command.options.ZplLineColor internal data class GraphicBox( diff --git a/src/main/kotlin/info/mking/k2zpl/command/GraphicField.kt b/src/main/kotlin/info/mking/k2zpl/command/GraphicField.kt index f46779e..059e282 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/GraphicField.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/GraphicField.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.command.options.ZplCompressionType internal data class GraphicField( diff --git a/src/main/kotlin/info/mking/k2zpl/command/LabelHome.kt b/src/main/kotlin/info/mking/k2zpl/command/LabelHome.kt index 3d5a2ae..e0d5f12 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/LabelHome.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/LabelHome.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data class LabelHome(val x: Int, val y: Int) : ZplCommand { override val command: CharSequence = "^LH" diff --git a/src/main/kotlin/info/mking/k2zpl/command/LabelLength.kt b/src/main/kotlin/info/mking/k2zpl/command/LabelLength.kt index 46f1808..ed54aa6 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/LabelLength.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/LabelLength.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data class LabelLength(val length: Int) : ZplCommand { init { diff --git a/src/main/kotlin/info/mking/k2zpl/command/MediaMode.kt b/src/main/kotlin/info/mking/k2zpl/command/MediaMode.kt index 521db11..baabdc0 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/MediaMode.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/MediaMode.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command import info.mking.k2zpl.builder.toZplYesNo import info.mking.k2zpl.command.options.ZplMediaMode import info.mking.k2zpl.command.options.ZplYesNo @@ -12,7 +11,7 @@ internal data class MediaMode( ) : ZplCommand { override val command: CharSequence = "^MM" override val parameters: LinkedHashMap = - linkedMapOf("m" to mediaMode.value, "p" to prePeelSelect) + linkedMapOf("m" to mediaMode, "p" to prePeelSelect) } /** diff --git a/src/main/kotlin/info/mking/k2zpl/command/PrintWidth.kt b/src/main/kotlin/info/mking/k2zpl/command/PrintWidth.kt index 15e83a5..166f6e6 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/PrintWidth.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/PrintWidth.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data class PrintWidth(val width: Int) : ZplCommand { init { diff --git a/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt b/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt index 886b211..8eab425 100644 --- a/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt +++ b/src/main/kotlin/info/mking/k2zpl/command/StartFormat.kt @@ -1,7 +1,6 @@ package info.mking.k2zpl.command import info.mking.k2zpl.builder.ZplBuilder -import info.mking.k2zpl.builder.command internal data object StartFormat : ZplCommand { override val command: CharSequence = "^XA" diff --git a/src/main/kotlin/info/mking/k2zpl/command/options/ZplPrintSpeed.kt b/src/main/kotlin/info/mking/k2zpl/command/options/ZplPrintSpeed.kt deleted file mode 100644 index 91ce6c1..0000000 --- a/src/main/kotlin/info/mking/k2zpl/command/options/ZplPrintSpeed.kt +++ /dev/null @@ -1,15 +0,0 @@ -@file:Suppress("UNUSED") - -package info.mking.k2zpl.command.options - -enum class ZplPrintSpeed(val code: Int) { - SPEED_2(2), - SPEED_3(3), - SPEED_4(4), - SPEED_5(5), - SPEED_6(6), - SPEED_7(7), - SPEED_8(8), - SPEED_9(9), - SPEED_10(10) -} \ No newline at end of file diff --git a/src/test/kotlin/info/mking/k2zpl/builder/ZplBuilderTest.kt b/src/test/kotlin/info/mking/k2zpl/builder/ZplBuilderTest.kt index b54979f..1bfdb68 100644 --- a/src/test/kotlin/info/mking/k2zpl/builder/ZplBuilderTest.kt +++ b/src/test/kotlin/info/mking/k2zpl/builder/ZplBuilderTest.kt @@ -24,12 +24,12 @@ class ZplBuilderTest : DescribeSpec({ describe("addCommand") { it("should call build on the passed command") { - subject.addCommand(mockZplCommand) + subject.command(mockZplCommand) subject.build() verify { mockZplCommand.build(ofType()) } } it("should used the pass string command") { - subject.addCommand("another-command") + subject.command("another-command") subject.build() shouldBe "another-command\n" } }