Skip to content

Commit

Permalink
refactor: rename mappings to map
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 10, 2021
1 parent 96fb737 commit 0f3d9ad
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _fixtures/transflows/transflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- name: "from_todo_blog_to_quake_calendar_timeline"
from: [ "todo", "blog" ]
to: "<quake-calendar-timeline>"
mappings:
map:
- entry: "todo"
source: ["title", "content", "created_date", "updated_date"]
target: ["title", "content", "start_time", "end_time"]
Expand Down
2 changes: 1 addition & 1 deletion examples/_quake/transflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- name: "from_todo_blog_to_quake_calendar_timeline"
from: [ "todo", "blog" ]
to: "<quake-calendar-timeline>"
mappings:
map:
- entry: "todo"
source: ["title", "content", "created_date", "updated_date"]
target: ["title", "content", "created_date", "updated_date"]
Expand Down
2 changes: 1 addition & 1 deletion quake_core/src/entry/entry_define.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl EntryDefine {
let date = quake_time::date_now();

let mut map = IndexMap::new();
map.insert("title".to_string(), title);
map.insert("title".to_string(), format!("{:}", title));
map.insert("created_date".to_string(), date.clone());
map.insert("updated_date".to_string(), date);

Expand Down
1 change: 1 addition & 0 deletions quake_core/src/transflow/transflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct Flow {
pub name: String,
pub from: Vec<String>,
pub to: String,
#[serde(rename = "map")]
pub mappings: Option<Vec<Mapping>>,
pub filter: String,
}
Expand Down
2 changes: 1 addition & 1 deletion quake_core/src/usecases/entry_usecases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn update_entry_fields(

for (key, value) in update_map {
if key != "content" {
entry_file.update_field(key, value);
entry_file.update_field(key, &format!("{:?}", value));
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ fn config_quake(cmd: &Command) -> Result<QuakeConfig, Box<dyn Error>> {
}

fn load_config(path: &String) -> Result<QuakeConfig, Box<dyn Error>> {
let content = fs::read_to_string(path)?;
let conf: QuakeConfig = serde_yaml::from_str(content.as_str())?;
let content =
fs::read_to_string(path).expect("lost .quake.yaml config, please run `quake init`");
let conf: QuakeConfig = serde_yaml::from_str(content.as_str()).expect("serde .quake.yml error");

Ok(conf)
}
Expand Down

0 comments on commit 0f3d9ad

Please sign in to comment.