-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(#41): latex.rs, puzzles #47
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8bcbdcd
feat(#41): latex.rs
h1alexbel 9bb4b24
feat(#41): rustfmt
h1alexbel fc971f6
feat(#41): license off
h1alexbel 9cc3f5f
feat(#41): ignore tex
h1alexbel 3a98a88
feat(#41): not intented
h1alexbel c67c5b8
feat(#41): puzzle update
h1alexbel ec9a9b0
feat(#41): multiple
h1alexbel 444c153
feat(#41): expect instaed of #unwrap
h1alexbel 9c67f53
feat(#41): puzzle for extends with
h1alexbel f248929
feat(#41): path is the default one
h1alexbel fac468e
feat(#41): clean for fmt
h1alexbel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: yegor256/[email protected] | ||
with: | ||
ignore: >- | ||
server/resources/report.tex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/target | ||
/out | ||
### Rust template | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
\usepackage{to-be-determined} | ||
\documentclass[12pt]{article} | ||
\begin{document} | ||
|
||
\section*{Fakehub report} | ||
\tbd{History: TBD} | ||
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2024 Aliaksei Bialiauski | ||
// | ||
// 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 NON-INFRINGEMENT. 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. | ||
use std::fs; | ||
use std::path::Path; | ||
|
||
/// Read LaTeX template. | ||
/// @todo #41:60min Add function for appending new content into the template. | ||
/// We need to create new function that will append input into the template, | ||
/// thus it will build a detailed report. | ||
/// # Arguments | ||
/// | ||
/// * `path`: Template path | ||
/// | ||
/// returns: String | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// use crate::server::report::latex::template; | ||
/// let content = template(None); | ||
/// print!("{content}") | ||
/// ``` | ||
pub fn template(path: Option<&str>) -> String { | ||
return fs::read_to_string(Path::new(path.unwrap_or("resources/report.tex"))) | ||
.expect("template should be read from"); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use anyhow::Result; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use tempdir::TempDir; | ||
|
||
use crate::report::latex::template; | ||
|
||
#[test] | ||
fn returns_default_template() -> Result<()> { | ||
l3r8yJ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let content = template(None); | ||
let expected = r"\usepackage{to-be-determined} | ||
\documentclass[12pt]{article} | ||
\begin{document} | ||
|
||
\section*{Fakehub report} | ||
\tbd{History: TBD} | ||
\end{document} | ||
"; | ||
assert_eq!( | ||
content, expected, | ||
"Template content '{content}' does not match with '{expected}'" | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn returns_custom_template() -> Result<()> { | ||
let temp = TempDir::new("temp")?; | ||
let path = &temp.path().join("custom.tex"); | ||
let expected = "$This is custom template!$"; | ||
let bytes = expected.to_string().into_bytes(); | ||
File::create(path).unwrap().write_all(bytes.as_slice())?; | ||
let content = template(path.to_str()); | ||
assert_eq!( | ||
content, expected, | ||
"Template content '{content} does not match with '{expected}'" | ||
); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2024 Aliaksei Bialiauski | ||
// | ||
// 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 NON-INFRINGEMENT. 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. | ||
// @todo #41:45min Create similar to latex.rs functions for XML and TXT formats. | ||
// Let's create similar to latex.rs functions for generating reports in XML and TXT. | ||
// Don't forget to remove this puzzle. | ||
pub mod latex; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel i think in this case path should be required, you can add it to
Args
and set default value if nothing was provided to--report
argument;txt
would be fine for default valueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l3r8yJ yes, this function will be called only if cli parser will find non-empty
--report
option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h1alexbel can you add the puzzle or implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@l3r8yJ it's already added as puzzle in
cli/src/args.rs