Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
elmerbulthuis committed Feb 20, 2024
1 parent 2d6643a commit 2d88c33
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 17 deletions.
16 changes: 13 additions & 3 deletions packages/cargo/jns42-generator/src/documents/draft_04/document.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use serde_json::Value;
use url::Url;

#[allow(dead_code)]
pub struct Document {
//
antecedent_url: Option<Url>,
document_node_url: Url,
document_node: Value,
}

impl Document {
pub fn new() -> Self {
Self {}
pub fn new(given_url: Url, antecedent_url: Option<Url>, document_node: Value) -> Self {
Self {
antecedent_url,
document_node,
document_node_url: given_url,
}
}
}

Expand Down
16 changes: 13 additions & 3 deletions packages/cargo/jns42-generator/src/documents/draft_06/document.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use serde_json::Value;
use url::Url;

#[allow(dead_code)]
pub struct Document {
//
antecedent_url: Option<Url>,
document_node_url: Url,
document_node: Value,
}

impl Document {
pub fn new() -> Self {
Self {}
pub fn new(given_url: Url, antecedent_url: Option<Url>, document_node: Value) -> Self {
Self {
antecedent_url,
document_node,
document_node_url: given_url,
}
}
}

Expand Down
16 changes: 13 additions & 3 deletions packages/cargo/jns42-generator/src/documents/draft_07/document.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use serde_json::Value;
use url::Url;

#[allow(dead_code)]
pub struct Document {
//
antecedent_url: Option<Url>,
document_node_url: Url,
document_node: Value,
}

impl Document {
pub fn new() -> Self {
Self {}
pub fn new(given_url: Url, antecedent_url: Option<Url>, document_node: Value) -> Self {
Self {
antecedent_url,
document_node,
document_node_url: given_url,
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use serde_json::Value;
use url::Url;

#[allow(dead_code)]
pub struct Document {
//
antecedent_url: Option<Url>,
document_node_url: Url,
document_node: Value,
}

impl Document {
pub fn new() -> Self {
Self {}
pub fn new(given_url: Url, antecedent_url: Option<Url>, document_node: Value) -> Self {
Self {
antecedent_url,
document_node,
document_node_url: given_url,
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::documents::document_context::DocumentContext;
use serde_json::Value;
use url::Url;

#[allow(dead_code)]
pub struct Document {
antecedent_url: Option<Url>,
document_node_url: Url,
Expand Down
32 changes: 28 additions & 4 deletions packages/cargo/jns42-generator/src/programs/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,43 @@ pub async fn run_command(options: CommandOptions) -> Result<(), Box<dyn Error>>
);
context.register_factory(
&MetaSchemaId::Draft201909,
Box::new(|initializer| Rc::new(draft_2019_09::document::Document::new())),
Box::new(|initializer| {
Rc::new(draft_2019_09::document::Document::new(
initializer.given_url.clone(),
initializer.antecedent_url.cloned(),
initializer.document_node.clone(),
))
}),
);
context.register_factory(
&MetaSchemaId::Draft07,
Box::new(|initializer| Rc::new(draft_07::document::Document::new())),
Box::new(|initializer| {
Rc::new(draft_07::document::Document::new(
initializer.given_url.clone(),
initializer.antecedent_url.cloned(),
initializer.document_node.clone(),
))
}),
);
context.register_factory(
&MetaSchemaId::Draft06,
Box::new(|initializer| Rc::new(draft_06::document::Document::new())),
Box::new(|initializer| {
Rc::new(draft_06::document::Document::new(
initializer.given_url.clone(),
initializer.antecedent_url.cloned(),
initializer.document_node.clone(),
))
}),
);
context.register_factory(
&MetaSchemaId::Draft04,
Box::new(|initializer| Rc::new(draft_04::document::Document::new())),
Box::new(|initializer| {
Rc::new(draft_04::document::Document::new(
initializer.given_url.clone(),
initializer.antecedent_url.cloned(),
initializer.document_node.clone(),
))
}),
);

context
Expand Down

0 comments on commit 2d88c33

Please sign in to comment.