mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Remove maplit dependency and stop using a macro for hashmaps (#982)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use std::{collections::BTreeMap, path::Path};
|
||||
|
||||
use anyhow::Context;
|
||||
use maplit::hashmap;
|
||||
use memofs::{IoResultExt, Vfs};
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -31,9 +30,7 @@ pub fn snapshot_csv(
|
||||
let mut snapshot = InstanceSnapshot::new()
|
||||
.name(name)
|
||||
.class_name("LocalizationTable")
|
||||
.properties(hashmap! {
|
||||
"Contents".to_owned() => table_contents.into(),
|
||||
})
|
||||
.properties([("Contents".to_owned(), table_contents.into())])
|
||||
.metadata(
|
||||
InstanceMetadata::new()
|
||||
.instigating_source(path)
|
||||
|
||||
@@ -108,7 +108,6 @@ pub fn snapshot_dir_no_meta(
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use maplit::hashmap;
|
||||
use memofs::{InMemoryFs, VfsSnapshot};
|
||||
|
||||
#[test]
|
||||
@@ -132,9 +131,7 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"Child" => VfsSnapshot::empty_dir(),
|
||||
}),
|
||||
VfsSnapshot::dir([("Child", VfsSnapshot::empty_dir())]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Context;
|
||||
use maplit::hashmap;
|
||||
use memofs::{IoResultExt, Vfs};
|
||||
|
||||
use crate::{
|
||||
@@ -24,9 +23,7 @@ pub fn snapshot_json(
|
||||
|
||||
let as_lua = json_to_lua(value).to_string();
|
||||
|
||||
let properties = hashmap! {
|
||||
"Source".to_owned() => as_lua.into(),
|
||||
};
|
||||
let properties = [("Source".to_owned(), as_lua.into())];
|
||||
|
||||
let meta_path = path.with_file_name(format!("{}.meta.json", name));
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ pub fn snapshot_lua_init(
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use maplit::hashmap;
|
||||
use memofs::{InMemoryFs, VfsSnapshot};
|
||||
|
||||
#[test]
|
||||
@@ -263,9 +262,7 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/root",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"init.lua" => VfsSnapshot::file("Hello!"),
|
||||
}),
|
||||
VfsSnapshot::dir([("init.lua", VfsSnapshot::file("Hello!"))]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -340,7 +340,6 @@ fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Cow<'stati
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use maplit::hashmap;
|
||||
use memofs::{InMemoryFs, VfsSnapshot};
|
||||
|
||||
#[ignore = "Functionality moved to root snapshot middleware"]
|
||||
@@ -351,16 +350,19 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "indirect-project",
|
||||
"tree": {
|
||||
"$className": "Folder"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
)]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -385,16 +387,19 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"hello.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([(
|
||||
"hello.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "direct-project",
|
||||
"tree": {
|
||||
"$className": "Model"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
)]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -533,17 +538,22 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([
|
||||
(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "path-project",
|
||||
"tree": {
|
||||
"$path": "other.txt"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
"other.txt" => VfsSnapshot::file("Hello, world!"),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
),
|
||||
("other.txt", VfsSnapshot::file("Hello, world!")),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -568,24 +578,34 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([
|
||||
(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "path-project",
|
||||
"tree": {
|
||||
"$path": "other.project.json"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
"other.project.json" => VfsSnapshot::file(r#"
|
||||
"#,
|
||||
),
|
||||
),
|
||||
(
|
||||
"other.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "other-project",
|
||||
"tree": {
|
||||
"$className": "Model"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -610,16 +630,24 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([
|
||||
(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "path-child-project",
|
||||
"tree": {
|
||||
"$path": "other.project.json"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
"other.project.json" => VfsSnapshot::file(r#"
|
||||
"#,
|
||||
),
|
||||
),
|
||||
(
|
||||
"other.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "other-project",
|
||||
"tree": {
|
||||
@@ -630,8 +658,10 @@ mod test {
|
||||
}
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -659,8 +689,11 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([
|
||||
(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "path-property-override",
|
||||
"tree": {
|
||||
@@ -670,8 +703,13 @@ mod test {
|
||||
}
|
||||
}
|
||||
}
|
||||
"#),
|
||||
"other.project.json" => VfsSnapshot::file(r#"
|
||||
"#,
|
||||
),
|
||||
),
|
||||
(
|
||||
"other.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"name": "other-project",
|
||||
"tree": {
|
||||
@@ -681,8 +719,10 @@ mod test {
|
||||
}
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -707,15 +747,18 @@ mod test {
|
||||
let mut imfs = InMemoryFs::new();
|
||||
imfs.load_snapshot(
|
||||
"/foo",
|
||||
VfsSnapshot::dir(hashmap! {
|
||||
"default.project.json" => VfsSnapshot::file(r#"
|
||||
VfsSnapshot::dir([(
|
||||
"default.project.json",
|
||||
VfsSnapshot::file(
|
||||
r#"
|
||||
{
|
||||
"tree": {
|
||||
"$className": "Model"
|
||||
}
|
||||
}
|
||||
"#),
|
||||
}),
|
||||
"#,
|
||||
),
|
||||
)]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Context;
|
||||
use maplit::hashmap;
|
||||
use memofs::{IoResultExt, Vfs};
|
||||
|
||||
use crate::{
|
||||
@@ -24,9 +23,7 @@ pub fn snapshot_toml(
|
||||
|
||||
let as_lua = toml_to_lua(value).to_string();
|
||||
|
||||
let properties = hashmap! {
|
||||
"Source".to_owned() => as_lua.into(),
|
||||
};
|
||||
let properties = [("Source".to_owned(), as_lua.into())];
|
||||
|
||||
let meta_path = path.with_file_name(format!("{}.meta.json", name));
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{path::Path, str};
|
||||
|
||||
use maplit::hashmap;
|
||||
use memofs::{IoResultExt, Vfs};
|
||||
|
||||
use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot};
|
||||
@@ -16,9 +15,7 @@ pub fn snapshot_txt(
|
||||
let contents = vfs.read_to_string(path)?;
|
||||
let contents_str = contents.as_str();
|
||||
|
||||
let properties = hashmap! {
|
||||
"Value".to_owned() => contents_str.into(),
|
||||
};
|
||||
let properties = [("Value".to_owned(), contents_str.into())];
|
||||
|
||||
let meta_path = path.with_file_name(format!("{}.meta.json", name));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user