Skip to content

Commit

Permalink
chore: rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sasial-dev committed Aug 4, 2023
1 parent 2f420f5 commit 6475a62
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/snapshot/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use std::{

use serde::{Deserialize, Serialize};

use crate::{glob::Glob, path_serializer, project::ProjectNode, snapshot_middleware::ScriptContextType};
use crate::{
glob::Glob, path_serializer, project::ProjectNode, snapshot_middleware::ScriptContextType,
};

/// Rojo-specific metadata that can be associated with an instance or a snapshot
/// of an instance.
Expand Down Expand Up @@ -142,7 +144,6 @@ impl From<ScriptContextType> for InstanceContext {
}
}


impl Default for InstanceContext {
fn default() -> Self {
Self {
Expand Down
48 changes: 32 additions & 16 deletions src/snapshot_middleware/lua.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{path::Path, str, collections::HashMap};
use std::{collections::HashMap, path::Path, str};

use anyhow::Context;
use memofs::{IoResultExt, Vfs};
Expand Down Expand Up @@ -37,7 +37,11 @@ pub fn snapshot_lua(

let is_run_context_enabled = context.script_type == ScriptContextType::RunContext;

let run_context = &rbx_reflection_database::get().enums.get("RunContext").expect("Unable to get RunContext enums!").items;
let run_context = &rbx_reflection_database::get()
.enums
.get("RunContext")
.expect("Unable to get RunContext enums!")
.items;

let (script_type, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
{
Expand Down Expand Up @@ -73,7 +77,10 @@ pub fn snapshot_lua(
properties.insert("Source".to_owned(), contents_str.into());

if let Some(run_context) = run_context {
properties.insert("RunContext".to_owned(), Enum::from_u32(run_context.to_owned()).into());
properties.insert(
"RunContext".to_owned(),
Enum::from_u32(run_context.to_owned()).into(),
);
}

let meta_path = path.with_file_name(format!("{}.meta.json", instance_name));
Expand All @@ -85,7 +92,7 @@ pub fn snapshot_lua(
.metadata(
InstanceMetadata::from(context)
.instigating_source(path)
.relevant_paths(vec![path.to_path_buf(), meta_path.clone()])
.relevant_paths(vec![path.to_path_buf(), meta_path.clone()]),
);

if let Some(meta_contents) = vfs.read(&meta_path).with_not_found()? {
Expand Down Expand Up @@ -149,10 +156,13 @@ mod test {

let mut vfs = Vfs::new(imfs);

let instance_snapshot =
snapshot_lua(&InstanceContext::from(ScriptContextType::Class), &mut vfs, Path::new("/foo.lua"))
.unwrap()
.unwrap();
let instance_snapshot = snapshot_lua(
&InstanceContext::from(ScriptContextType::Class),
&mut vfs,
Path::new("/foo.lua"),
)
.unwrap()
.unwrap();

insta::with_settings!({ sort_maps => true }, {
insta::assert_yaml_snapshot!(instance_snapshot);
Expand Down Expand Up @@ -215,10 +225,13 @@ mod test {

let mut vfs = Vfs::new(imfs);

let instance_snapshot =
snapshot_lua(&InstanceContext::from(ScriptContextType::Class), &mut vfs, Path::new("/root"))
.unwrap()
.unwrap();
let instance_snapshot = snapshot_lua(
&InstanceContext::from(ScriptContextType::Class),
&mut vfs,
Path::new("/root"),
)
.unwrap()
.unwrap();

insta::with_settings!({ sort_maps => true }, {
insta::assert_yaml_snapshot!(instance_snapshot);
Expand All @@ -244,10 +257,13 @@ mod test {

let mut vfs = Vfs::new(imfs);

let instance_snapshot =
snapshot_lua(&InstanceContext::from(ScriptContextType::Class), &mut vfs, Path::new("/foo.lua"))
.unwrap()
.unwrap();
let instance_snapshot = snapshot_lua(
&InstanceContext::from(ScriptContextType::Class),
&mut vfs,
Path::new("/foo.lua"),
)
.unwrap()
.unwrap();

insta::with_settings!({ sort_maps => true }, {
insta::assert_yaml_snapshot!(instance_snapshot);
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot_middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use self::{
util::PathExt,
};

pub use self::{project::snapshot_project_node, lua::ScriptContextType};
pub use self::{lua::ScriptContextType, project::snapshot_project_node};

/// The main entrypoint to the snapshot function. This function can be pointed
/// at any path and will return something if Rojo knows how to deal with it.
Expand Down

0 comments on commit 6475a62

Please sign in to comment.