From 94aaa51bb70ddae7671f4cbd1540693c9a5f7263 Mon Sep 17 00:00:00 2001 From: ErikWDev Date: Wed, 28 Jul 2021 13:46:23 +0200 Subject: [PATCH] Remove Trailing Whitespace + Fast Testcase --- .gitignore | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- nimassets.nimble | 5 +++-- src/nimassets.nim | 4 ++-- tests/test.nim | 13 ++++++++++--- tests/testassets/asset2.txt | 1 + 7 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 tests/testassets/asset2.txt diff --git a/.gitignore b/.gitignore index 13c9e0b..cbad888 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ build -tests/assetfile.nim +tests/assetfile*.nim diff --git a/CHANGELOG.md b/CHANGELOG.md index c5adeea..1315144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2021-07-28 + +### Changed + +- Minor formatting. Removed trailing whitespace from generated assetfile. + +### Added + +- New testcase for the fast version of the bundler + ## [0.2.0] - 2021-07-20 ### Added diff --git a/README.md b/README.md index 6f17250..d74b035 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ nimassets `Nim Assets` is heavily inspired by [go-bindata](https://github.com/jt ## Usage ```bash -nimassets 0.2.0 (Bundle your assets into nim file) +nimassets 0.2.1 (Bundle your assets into nim file) -h | --help : show help -v | --version : show version -o | --output : output filename diff --git a/nimassets.nimble b/nimassets.nimble index 089d96e..1210b73 100644 --- a/nimassets.nimble +++ b/nimassets.nimble @@ -1,6 +1,6 @@ # Package -version = "0.2.0" +version = "0.2.1" author = "xmonader" description = "bundle your assets to a nim" license = "MIT" @@ -30,4 +30,5 @@ task buildTemplatesFast, "bundle templates in templatesdir fast": before test: build() - exec "./build/nimassets -d:tests/testassets -o:tests/assetfile.nim" \ No newline at end of file + exec "./build/nimassets -d:tests/testassets -o:tests/assetfile.nim" + exec "./build/nimassets --fast -d:tests/testassets -o:tests/assetfile_fast.nim" \ No newline at end of file diff --git a/src/nimassets.nim b/src/nimassets.nim index 00c2132..aefe2b9 100644 --- a/src/nimassets.nim +++ b/src/nimassets.nim @@ -14,7 +14,7 @@ const buildCommit* = staticExec("git rev-parse HEAD") ## \ # const latestTag* = staticExec("git describe --abbrev=0 --tags") ## \ ## `latestTag` latest tag on this branch -const versionString* = &"0.2.0 ({buildBranchName}/{buildCommit})" +const versionString* = &"0.2.1 ({buildBranchName}/{buildCommit})" const assetsFileHeader = """ import tables, base64 @@ -29,7 +29,7 @@ proc getAsset*(path: string): string = proc handleFile(path: string): string {.thread.} = var val, valString: string val = readFile(path).encode() - valString = " \"\"\"" & val & "\"\"\" " + valString = "\"\"\"" & val & "\"\"\"" result = &"""assets["{path}"] = {valString}""" & "\n\n" proc generateDirAssetsSimple*(dir: string): string = diff --git a/tests/test.nim b/tests/test.nim index 7142799..297e8ef 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -1,7 +1,14 @@ import unittest, - assetfile # will be generated by the 'nimble test' task + assetfile, # will be generated by the 'nimble test' task + assetfile_fast # will be generated by the 'nimble test' task suite "Nimassets Tests": - test "Can Obtain Asset": - check getAsset("tests/testassets/asset1.txt") == readFile("tests/testassets/asset1.txt") + test "Can Obtain Assets (normal)": + check assetfile.getAsset("tests/testassets/asset1.txt") == readFile("tests/testassets/asset1.txt") + check assetfile.getAsset("tests/testassets/asset2.txt") == readFile("tests/testassets/asset2.txt") + + test "Can Obtain Assets (fast)": + check assetfile_fast.getAsset("tests/testassets/asset1.txt") == readFile("tests/testassets/asset1.txt") + check assetfile_fast.getAsset("tests/testassets/asset2.txt") == readFile("tests/testassets/asset2.txt") + diff --git a/tests/testassets/asset2.txt b/tests/testassets/asset2.txt new file mode 100644 index 0000000..3ffe139 --- /dev/null +++ b/tests/testassets/asset2.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet. \ No newline at end of file