Skip to content

Commit

Permalink
impl extends res Link #9
Browse files Browse the repository at this point in the history
  • Loading branch information
zuowenjian committed Apr 24, 2018
1 parent c598fba commit e1088f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
8 changes: 8 additions & 0 deletions core/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ impl std::convert::From<std::io::Error> for Error
}

}

#[macro_export]
macro_rules! ERR{
($args:expr) => ({ return Error::Runtime(String::from($args)) });
($fmt:expr, $($args:tt)*) => ({
return Err(Error::Runtime(format!($fmt,$($args)*)))
});
}
2 changes: 1 addition & 1 deletion core/src/res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ where T: ResDesp + InvokeStart + InvokeStop + InvokeHook + Interceptor
#[macro_export]
macro_rules! res_info {
{ $res:expr } => {
info!("res {}: {:?}", $res.name(),$res.info()) ;
print!("res {}: {:?}", $res.name(),$res.info()) ;
};
}
#[macro_export]
Expand Down
41 changes: 22 additions & 19 deletions extends/src/unix/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ use rg_core::res::* ;
use rg_core::creator::* ;
use std::path::Path ;

//
///!R.link
// src : ""
// dst : ""
//
//
#[derive(Debug)]
pub struct Link
{
Expand All @@ -22,35 +28,30 @@ impl Loader<Link> for Link
}
fn key() -> String { String::from("Link") }
}



impl InvokeHook for Link{}
impl InvokeStop for Link{

}


impl ResDesp for Link
{
fn res_info(&self) -> String {
format!("{:?}",self)
format!(
r#"!R.link
src: "{}"
dst: "{}"
"#,self.src,self.dst)
}
fn res_name(&self) -> String {
Link::key()
}
}


#[macro_export]
macro_rules! ERR{
($args:expr) => ({ return Error::Runtime(String::from($args)) });
($fmt:expr, $($args:tt)*) => ({
return Err(Error::Runtime(format!($fmt,$($args)*)))
});

impl InvokeHook for Link{}
impl InvokeStop for Link{

}




impl InvokeStart for Link
{
fn res_conf(&self,_context : &mut Context) ->BoolR
Expand Down Expand Up @@ -108,7 +109,7 @@ mod tests
use super::* ;
//use rg_core::res::* ;
use rg_core::model::* ;
use rg_core::parser::* ;
//use rg_core::parser::* ;
use rg_core::creator::* ;
use pretty_env_logger ;
#[test]
Expand All @@ -118,8 +119,10 @@ mod tests
debug!("hello") ;
let mut god = ResFatory::new() ;
res_regist(&mut god);
let data = map!("dst" =>"${HOME}/devspace/rigger-nx/extends/meterial/run_ngx.yaml","src" => "${HOME}/devspace/rigger-nx/extends/meterial/run_tpl.yaml") ;
let obj = god.create(&Link::key(),&data ).unwrap();
let data = map!(
"dst" =>"${HOME}/devspace/rigger-nx/extends/meterial/run_ngx.yaml",
"src" => "${HOME}/devspace/rigger-nx/extends/meterial/run_tpl.yaml") ;
let obj = god.create(&Link::key(),&data ).unwrap();
res_check(&obj);
}
}

0 comments on commit e1088f8

Please sign in to comment.