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

source

pub fn git_remote_output(&self) -> Result<String>

source

pub fn regex_capture(&self, output: String) -> Result<String>

returns a Result. in the case of error the calling fn will return empty string.

source

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);
source

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);
source§

impl AppObject

source

pub fn new() -> AppObject

Constructor of the object that has all the public methods.
No fields needed for now.

source

pub fn main(&self, link: &str) -> String

Runs all the public methods. It is called by the CLI main fn.

source

pub fn text_to_include(&self, link: &str) -> String

Trait Implementations§

source§

impl TraitCountLines for AppObject

source§

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

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,…

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Any for T
where T: Any + ?Sized,

source§

fn type_id_compat(&self) -> TypeId

TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.