Skip to content

Commit

Permalink
Remove Trailing Whitespace + Fast Testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
EriKWDev committed Jul 28, 2021
1 parent 8e2b661 commit 94aaa51
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build
tests/assetfile.nim
tests/assetfile*.nim
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions nimassets.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.2.0"
version = "0.2.1"
author = "xmonader"
description = "bundle your assets to a nim"
license = "MIT"
Expand Down Expand Up @@ -30,4 +30,5 @@ task buildTemplatesFast, "bundle templates in templatesdir fast":

before test:
build()
exec "./build/nimassets -d:tests/testassets -o:tests/assetfile.nim"
exec "./build/nimassets -d:tests/testassets -o:tests/assetfile.nim"
exec "./build/nimassets --fast -d:tests/testassets -o:tests/assetfile_fast.nim"
4 changes: 2 additions & 2 deletions src/nimassets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down
13 changes: 10 additions & 3 deletions tests/test.nim
Original file line number Diff line number Diff line change
@@ -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")

1 change: 1 addition & 0 deletions tests/testassets/asset2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lorem ipsum dolor sit amet.

0 comments on commit 94aaa51

Please sign in to comment.