Skip to content

Commit

Permalink
Prepare v0.0.7, add license, add insta tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elkowar committed Dec 8, 2024
1 parent f7eeb46 commit 67c3e3c
Show file tree
Hide file tree
Showing 18 changed files with 344 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "yolk"
name = "yolk_dots"
authors = ["ElKowar <[email protected]>"]
description = "Templated dotfile management without template files"
version = "0.0.6"
version = "0.0.7"
edition = "2021"
repository = "https://github.com/elkowar/yolk"
homepage = "https://elkowar.github.io/yolk"
license = "MIT OR Apache-2.0"

[package.metadata.wix]
upgrade-guid = "04CA81A1-EF78-4B08-8D76-74A8DB52A323"
Expand Down
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 ElKowar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 changes: 17 additions & 0 deletions dist-workspace.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[workspace]
members = ["cargo:."]

# Config for 'dist'
[dist]
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.26.0-prerelease.3"
# CI backends to support
ci = "github"
# The installers to generate for each app
installers = ["shell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Path that installers should place binaries in
install-path = "CARGO_HOME"
# Whether to install an updater program
install-updater = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: src/templating/parser.rs
expression: "p_text_segment.parse_peek(new_input(\"foo\"))?"
snapshot_kind: text
---
(
"",
(
"",
"foo",
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: src/templating/parser.rs
expression: "p_text_segment.parse_peek(new_input(\"{< bar >}\"))"
snapshot_kind: text
---
Err(
Backtrack(
YolkParseError {
context: None,
span: None,
label: None,
help: None,
kind: None,
},
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: src/templating/parser.rs
expression: "p_text_segment.parse_peek(new_input(\"foo {% bar %} baz\"))?"
snapshot_kind: text
---
(
"{% bar %} baz",
(
"{%",
"foo ",
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
source: src/templating/parser.rs
expression: "p_conditional_element(&mut new_input(indoc::indoc! {\n r#\"\n // {% if a %}\n a\n b\n // {% elif b %}\n // {% elif c %}\n // {% else %}\n c\n // {% end %}\n \"#\n }))"
snapshot_kind: text
---
Ok(
Conditional {
blocks: [
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% if a %}",
right: "\n",
full_line: [0..14]"// {% if a %}\n",
},
expr: [6..11]"a ",
body: [
Plain(
[14..16]"a\n",
),
Plain(
[16..18]"b\n",
),
],
},
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% elif b %}",
right: "\n",
full_line: [18..34]"// {% elif b %}\n",
},
expr: [24..31]"b ",
body: [],
},
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% elif c %}",
right: "\n",
full_line: [34..50]"// {% elif c %}\n",
},
expr: [40..47]"c ",
body: [],
},
],
else_block: Some(
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% else %}",
right: "\n",
full_line: [50..64]"// {% else %}\n",
},
expr: (),
body: [
Plain(
[64..66]"c\n",
),
],
},
),
end: TaggedLine {
left: "// ",
tag: "{% end %}",
right: "\n",
full_line: [66..79]"// {% end %}\n",
},
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: src/templating/parser.rs
expression: "render_error(parse_document(\"{<if>}\").unwrap_err())"
snapshot_kind: text
---
× Failed to parse yolk template file

Error:
× Expected expression.
╭─[file:1:4]
1 │ {<if>}
· ┬
· ╰── here
╰────
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: src/templating/parser.rs
expression: "render_error(parse_document(\"{%f%}\").unwrap_err())"
snapshot_kind: text
---
× Failed to parse yolk template file

Error:
× Expected newline.
╭─[file:1:5]
1 │ {%f%}
· ┬
· ╰── here
╰────
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: src/templating/parser.rs
expression: "render_error(parse_document(\"{#f#}\").unwrap_err())"
snapshot_kind: text
---
× Failed to parse yolk template file

Error:
× Expected newline.
╭─[file:1:5]
1 │ {#f#}
· ┬
· ╰── here
╰────
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: src/templating/parser.rs
expression: "render_error(parse_document(\"{%f%}\\n{%else%}\\n{%end%}\").unwrap_err())"
snapshot_kind: text
---
× Failed to parse yolk template file

Error:
× Expected valid element.
╭─[file:2:3]
1 │ {%f%}
2 │ {%else%}
· ───┬───
· ╰── here
3 │ {%end%}
╰────
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: src/templating/parser.rs
expression: "p_inline_element.parse(new_input(\"foo /* {< test >} */\"))?"
snapshot_kind: text
---
Inline {
line: TaggedLine {
left: "foo /* ",
tag: "{< test >}",
right: " */",
full_line: [0..20]"foo /* {< test >} */",
},
expr: [10..15]"test ",
is_if: false,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
source: src/templating/parser.rs
expression: "p_multiline_element(&mut new_input(\"/* {% test %} */\\nfoo\\n/* {% end %} */\"))?"
snapshot_kind: text
---
MultiLine {
block: Block {
tagged_line: TaggedLine {
left: "/* ",
tag: "{% test %}",
right: " */\n",
full_line: [0..17]"/* {% test %} */\n",
},
expr: [6..11]"test ",
body: [
Plain(
[17..21]"foo\n",
),
],
},
end: TaggedLine {
left: "/* ",
tag: "{% end %}",
right: " */",
full_line: [21..36]"/* {% end %} */",
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
source: src/templating/parser.rs
expression: "p_conditional_element(&mut new_input(indoc::indoc! {\n r#\"\n // {% if foo %}\n // {% if foo %}\n // {% end %}\n // {% end %}\n \"#\n }))"
snapshot_kind: text
---
Ok(
Conditional {
blocks: [
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% if foo %}",
right: "\n",
full_line: [0..16]"// {% if foo %}\n",
},
expr: [6..13]"foo ",
body: [
Conditional {
blocks: [
Block {
tagged_line: TaggedLine {
left: "// ",
tag: "{% if foo %}",
right: "\n",
full_line: [16..32]"// {% if foo %}\n",
},
expr: [22..29]"foo ",
body: [],
},
],
else_block: None,
end: TaggedLine {
left: "// ",
tag: "{% end %}",
right: "\n",
full_line: [32..45]"// {% end %}\n",
},
},
],
},
],
else_block: None,
end: TaggedLine {
left: "// ",
tag: "{% end %}",
right: "\n",
full_line: [45..58]"// {% end %}\n",
},
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: src/templating/parser.rs
expression: "p_nextline_element(&mut new_input(\"/* {# x #} */\\nfoo\"))?"
snapshot_kind: text
---
NextLine {
tagged_line: TaggedLine {
left: "/* ",
tag: "{# x #}",
right: " */\n",
full_line: [0..14]"/* {# x #} */\n",
},
expr: [6..8]"x ",
next_line: [14..17]"foo",
is_if: false,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/templating/parser.rs
expression: "parse_document(&mut new_input(indoc::indoc! {\n r#\"\n # {# replace(`'.*'`, `'{data.value}'`) #}\n value = 'foo'\n \"#\n }))"
snapshot_kind: text
---
Ok(
[
NextLine {
tagged_line: TaggedLine {
left: "# ",
tag: "{# replace(`'.*'`, `'{data.value}'`) #}",
right: "\n",
full_line: [0..42]"# {# replace(`'.*'`, `'{data.value}'`) #}\n",
},
expr: [5..39]"replace(`'.*'`, `'{data.value}'`) ",
next_line: [42..55]"value = 'foo'",
is_if: false,
},
Plain(
[55..56]"\n",
),
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: src/templating/parser.rs
expression: "p_tag_line(\"{%\", \"end\", \"%}\", false).parse(new_input(\"a{% end %}b\"))"
snapshot_kind: text
---
Ok(
(
TaggedLine {
left: "a",
tag: "{% end %}",
right: "b",
full_line: [0..11]"a{% end %}b",
},
[4..7]"end",
),
)

0 comments on commit 67c3e3c

Please sign in to comment.