Struct lmake_lines_of_code::AppObject
source · pub struct AppObject {}Expand description
An object to implement methods rather than functions.
The methods are always defined in Traits, to be testable/mockable.
Traits don’t have access to fields, only to methods.
Implementations§
source§impl AppObject
impl AppObject
pub fn git_remote_output(&self) -> Result<String>
sourcepub fn regex_capture(&self, output: String) -> Result<String>
pub fn regex_capture(&self, output: String) -> Result<String>
returns a Result. in the case of error the calling fn will return empty string.
sourcepub fn to_string_as_md_table(&self, v: &LinesOfCode) -> String
pub fn to_string_as_md_table(&self, v: &LinesOfCode) -> String
Returns a string with the code for a markdown table with count of lines.
Some websites render a beautiful table, but others render ugly tables. Use badges instead.
§Example
use lmake_lines_of_code::*;
let app = AppObject{};
let v = app.workspace_or_project_count_lines();
let badges = app.to_string_as_md_table(&v);
println!("{}", badges);sourcepub fn to_string_as_shield_badges(&self, v: &LinesOfCode, link: &str) -> String
pub fn to_string_as_shield_badges(&self, v: &LinesOfCode, link: &str) -> String
Returns a string with the markdown code for 4 shield badges.
Every badge has the link to the url given as first CLI argument or automatically finds out the github git remote repository url.
§Example
use lmake_lines_of_code::*;
let app = AppObject{};
let v = app.workspace_or_project_count_lines();
let badges = app.to_string_as_shield_badges(&v,"");
println!("{}", badges);Trait Implementations§
source§impl TraitCountLines for AppObject
impl TraitCountLines for AppObject
source§fn workspace_or_project_count_lines(&self) -> LinesOfCode
fn workspace_or_project_count_lines(&self) -> LinesOfCode
Returns the struct LinesOfCode for 4 types of lines: code, doc comments, comments, test and examples. Automatically detects if this is a workspace or single rust project.
§Example
use lmake_lines_of_code::*;
let app = AppObject{};
let v = app.workspace_or_project_count_lines();
dbg!(&v);source§fn process_git_remote(&self) -> String
fn process_git_remote(&self) -> String
Return the string for link for badges like: https://github.com/LucianoBestia/lmake_lines_of_code/.
Get the output string after $ git remote -v.
Then finds out the link to the repository with regex.
Returns empty string if something goes wrong: no git, no remote,…