Compare commits
7 Commits
v0.0.2
...
171ec8fe4b
Author | SHA1 | Date | |
---|---|---|---|
171ec8fe4b | |||
b7d5f4fcb1 | |||
e79f83f800 | |||
8416067007 | |||
1723bf75b8 | |||
8d68479194 | |||
4ae38ec2c9 |
48
.github/workflows/docs.yaml
vendored
Normal file
48
.github/workflows/docs.yaml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
name: Docs
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup V
|
||||
run: |
|
||||
wget -qO /tmp/v.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip
|
||||
unzip -q /tmp/v.zip -d /tmp
|
||||
echo /tmp/v >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build docs
|
||||
run: |
|
||||
v doc -f html -m .
|
||||
pushd _docs
|
||||
ln -vs embedfs.html index.html
|
||||
ls -alFh
|
||||
popd
|
||||
|
||||
- name: Upload static files as artifact
|
||||
id: deployment
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: _docs/
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
24
.github/workflows/test.yaml
vendored
Normal file
24
.github/workflows/test.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup V
|
||||
run: |
|
||||
wget -qO /tmp/v.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip
|
||||
unzip -q /tmp/v.zip -d /tmp
|
||||
echo /tmp/v >> "$GITHUB_PATH"
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
v -stats test .
|
20
Makefile
20
Makefile
@ -1,20 +0,0 @@
|
||||
SRC_DIR ?= src
|
||||
DOC_DIR ?= doc
|
||||
TESTS_DIR ?= .
|
||||
|
||||
all: test
|
||||
|
||||
test:
|
||||
v test $(TESTS_DIR)
|
||||
|
||||
doc:
|
||||
v doc -f html -m ./$(SRC_DIR) -o $(DOC_DIR)
|
||||
|
||||
serve: clean doc
|
||||
v -e "import net.http.file; file.serve(folder: '$(DOC_DIR)')"
|
||||
|
||||
clean:
|
||||
rm -r $(DOC_DIR) || true
|
||||
|
||||
cli:
|
||||
v cmd/mkembedfs -o mkembedfs
|
@ -7,7 +7,7 @@ import net.http.mime
|
||||
pub struct CodeGenerator {
|
||||
pub:
|
||||
// Path to file or directory to embed
|
||||
path string
|
||||
path string @[required]
|
||||
// Path prefix if you want to add extra prefix for file paths
|
||||
prefix string
|
||||
// Glob patterns to match files the must be ignored when generating the code
|
@ -1,7 +1,6 @@
|
||||
module main
|
||||
|
||||
fn main() {
|
||||
println(embedfs)
|
||||
$if bare_map ? {
|
||||
json_file := embedfs['assets/example.json'] or { EmbedFile{} }
|
||||
println(json_file.data.to_string().trim_space())
|
||||
|
@ -1,12 +1 @@
|
||||
EmbedFileSystem{
|
||||
files: {'assets/example.json': EmbedFile{
|
||||
data: embed_file.EmbedFileData{ len: 22, path: "assets/example.json", apath: "", uncompressed: 846284 }
|
||||
meta: EmbedFileMetadata{
|
||||
key: 'assets/example.json'
|
||||
name: 'example.json'
|
||||
ext: 'json'
|
||||
mimetype: 'application/json'
|
||||
}
|
||||
}}
|
||||
}
|
||||
{"some": "JSON data"}
|
||||
|
@ -20,7 +20,7 @@ fn test_mymod() {
|
||||
|
||||
fn test_mymod_bare_map() {
|
||||
oldpwd := os.getwd()
|
||||
expected_out := os.read_file('tests/mymod_test_bare_map.out')!
|
||||
expected_out := os.read_file('tests/mymod_test.out')!
|
||||
os.chdir('tests/mymod')!
|
||||
gen := embedfs.CodeGenerator{
|
||||
path: 'assets'
|
||||
|
@ -1,10 +0,0 @@
|
||||
{'assets/example.json': EmbedFile{
|
||||
data: embed_file.EmbedFileData{ len: 22, path: "assets/example.json", apath: "", uncompressed: 845da4 }
|
||||
meta: EmbedFileMetadata{
|
||||
key: 'assets/example.json'
|
||||
name: 'example.json'
|
||||
ext: 'json'
|
||||
mimetype: 'application/json'
|
||||
}
|
||||
}}
|
||||
{"some": "JSON data"}
|
Reference in New Issue
Block a user