Преглед изворни кода

Align with next lot of changes to Invercargill API

Billy Barrow пре 1 месец
родитељ
комит
c4fc58b818

+ 3 - 1
src/lib/Configuration.vala

@@ -10,7 +10,9 @@ namespace Usm {
         public static PropertyMapper<Configuration> get_mapper() {
             return PropertyMapper.build_for<Configuration>(cfg => {
                 cfg.map<bool>("is_managed", o => o.is_managed, (o, v) => o.is_managed = v);
-                cfg.map_properties_with<ManagedConfiguration>("managed", o => o.managed_config, (o, v) => o.managed_config = v, ManagedConfiguration.get_mapper(), false);
+                cfg.map_properties_with<ManagedConfiguration>("managed", o => o.managed_config, (o, v) => o.managed_config = v, ManagedConfiguration.get_mapper())
+                    .undefined_when(o => o.managed_config == null)
+                    .when_undefined(o => o.managed_config = null);
                 cfg.set_constructor(() => new Configuration());
             });
         }

+ 6 - 4
src/lib/Dependencies.vala

@@ -9,10 +9,12 @@ namespace Usm {
 
         public static PropertyMapper<Dependencies> get_mapper() {
             return PropertyMapper.build_for<Dependencies>(cfg => {
-                cfg.map_many<string>("runtime", o => o.runtime.select<string>(i => i.to_string()), (o, v) => o.runtime = v.try_select<ResourceRef>(i => new ResourceRef(i)).to_set());
-                cfg.map_many<string>("build", o => o.build.select<string>(i => i.to_string()), (o, v) => o.build = v.try_select<ResourceRef>(i => new ResourceRef(i)).to_set());
-                cfg.map_many<string>("manage", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.try_select<ResourceRef>(i => new ResourceRef(i)).to_set());
-                cfg.map_many<string>("acquire", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.try_select<ResourceRef>(i => new ResourceRef(i)).to_set(), false);
+                cfg.map_many<string>("runtime", o => o.runtime.select<string>(i => i.to_string()), (o, v) => o.runtime = v.attempt_select<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("build", o => o.build.select<string>(i => i.to_string()), (o, v) => o.build = v.attempt_select<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("manage", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.attempt_select<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("acquire", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.attempt_select<ResourceRef>(i => new ResourceRef(i)).to_set())
+                    .undefined_when(o => o.acquire == null)
+                    .when_undefined(o => o.acquire = null);
                 cfg.set_constructor(() => new Dependencies());
             });
         }

+ 15 - 5
src/lib/Exectuables.vala

@@ -12,11 +12,21 @@ namespace Usm {
         public static PropertyMapper<Executables> get_mapper() {
             return PropertyMapper.build_for<Executables>(cfg => {
                 cfg.map<string>("build", o => o.build, (o, v) => o.build = v);
-                cfg.map<string?>("rebuild", o => o.rebuild, (o, v) => o.rebuild = v, false);
-                cfg.map<string?>("acquire", o => o.acquire, (o, v) => o.acquire = v, false);
-                cfg.map<string?>("install", o => o.install, (o, v) => o.install = v, false);
-                cfg.map<string?>("post_install", o => o.post_install, (o, v) => o.post_install = v, false);
-                cfg.map<string?>("remove", o => o.remove, (o, v) => o.remove = v, false);
+                cfg.map<string?>("rebuild", o => o.rebuild, (o, v) => o.rebuild = v)
+                    .undefined_when(o => o.rebuild == null)
+                    .when_undefined(o => o.rebuild = null);
+                cfg.map<string?>("acquire", o => o.acquire, (o, v) => o.acquire = v)
+                    .undefined_when(o => o.acquire == null)
+                    .when_undefined(o => o.acquire = null);
+                cfg.map<string?>("install", o => o.install, (o, v) => o.install = v)
+                    .undefined_when(o => o.install == null)
+                    .when_undefined(o => o.install = null);
+                cfg.map<string?>("post_install", o => o.post_install, (o, v) => o.post_install = v)
+                    .undefined_when(o => o.post_install == null)
+                    .when_undefined(o => o.post_install = null);
+                cfg.map<string?>("remove", o => o.remove, (o, v) => o.remove = v)
+                    .undefined_when(o => o.remove == null)
+                    .when_undefined(o => o.remove = null);
                 cfg.set_constructor(() => new Executables());
             });
         }

+ 9 - 3
src/lib/File.vala

@@ -16,9 +16,15 @@ namespace Usm {
                 cfg.map<string>("path", o => o.path, (o, v) => o.path = v);
                 cfg.map<string>("pathBase", o => o.path_base.to_string(), (o, v) => o.path_base = ManifestFilePathBase.from_string(v));
                 cfg.map<string>("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v));
-                cfg.map<string>("dest", o => o.destination, (o, v) => o.destination = v, false);
-                cfg.map_many<string>("keepOn", o => o.keep_on.select<string>(i => i.to_string()), (o, v) => o.keep_on = v.try_select<RemoveType>(i => RemoveType.from_string(i)).to_vector(), false);
-                cfg.map_many<string>("skipFor", o => o.skip_for.select<string>(i => i.to_string()), (o, v) => o.skip_for = v.try_select<InstallType>(i => InstallType.from_string(i)).to_vector(), false);
+                cfg.map<string>("dest", o => o.destination, (o, v) => o.destination = v)
+                    .undefined_when(o => o.destination == null)
+                    .when_undefined(o => o.destination = null);
+                cfg.map_many<string>("keepOn", o => o.keep_on.select<string>(i => i.to_string()), (o, v) => o.keep_on = v.attempt_select<RemoveType>(i => RemoveType.from_string(i)).to_vector())
+                    .undefined_when(o => o.keep_on == null)
+                    .when_undefined(o => o.keep_on = null);
+                cfg.map_many<string>("skipFor", o => o.skip_for.select<string>(i => i.to_string()), (o, v) => o.skip_for = v.attempt_select<InstallType>(i => InstallType.from_string(i)).to_vector())
+                    .undefined_when(o => o.skip_for == null)
+                    .when_undefined(o => o.skip_for = null);
                 cfg.set_constructor(() => new ManifestFile());
             });
         }

+ 19 - 7
src/lib/Manifest.vala

@@ -43,14 +43,26 @@ namespace Usm {
                 cfg.map<Properties>("provides", o => o.map_from_provides_dict(), (o, v) => o.build_provides_dict(v));
                 cfg.map_properties_with<Dependencies>("depends", o => o.dependencies, (o, v) => o.dependencies = v, Dependencies.get_mapper());
                 cfg.map_properties_with<Executables>("execs", o => o.executables, (o, v) => o.executables = v, Executables.get_mapper());
-                cfg.map_many<string>("flags", o => o.flags.select<string>(f => f.to_string()), (o, v) => o.flags = v.try_select<ManifestFlag>(f => ManifestFlag.from_string(f)).to_set());
-                cfg.map<string>("md", o => o.markdown_path, (o, v) => o.markdown_path = v, false);
-                cfg.map<string>("url", o => o.url, (o, v) => o.url = v, false);
-                cfg.map_many<string>("screenshots", o => o.screenshot_paths, (o, v) => o.screenshot_paths = v.to_vector(), false);
-                cfg.map<string>("icon", o => o.icon_path, (o, v) => o.icon_path = v, false);
-                cfg.map<string>("metainfo", o => o.metainfo_path, (o, v) => o.metainfo_path = v, false);
+                cfg.map_many<string>("flags", o => o.flags.select<string>(f => f.to_string()), (o, v) => o.flags = v.attempt_select<ManifestFlag>(f => ManifestFlag.from_string(f)).to_set());
+                cfg.map<string>("md", o => o.markdown_path, (o, v) => o.markdown_path = v)
+                    .undefined_when(o => o.markdown_path == null)
+                    .when_undefined(o => o.markdown_path = null);
+                cfg.map<string>("url", o => o.url, (o, v) => o.url = v)
+                    .undefined_when(o => o.url == null)
+                    .when_undefined(o => o.url = null);
+                cfg.map_many<string>("screenshots", o => o.screenshot_paths, (o, v) => o.screenshot_paths = v.to_vector())
+                    .undefined_when(o => o.screenshot_paths == null)
+                    .when_undefined(o => o.screenshot_paths = null);
+                cfg.map<string>("icon", o => o.icon_path, (o, v) => o.icon_path = v)
+                    .undefined_when(o => o.icon_path == null)
+                    .when_undefined(o => o.icon_path = null);
+                cfg.map<string>("metainfo", o => o.metainfo_path, (o, v) => o.metainfo_path = v)
+                    .undefined_when(o => o.metainfo_path == null)
+                    .when_undefined(o => o.metainfo_path = null);
                 //  cfg.map_with<Git>("git", o => o.git, (o, v) => o.git = v, Git.get_mapper(), false);
-                cfg.map<Properties>("extras", o => o.extra_properties, (o, v) => o.extra_properties = v, false);
+                cfg.map<Properties>("extras", o => o.extra_properties, (o, v) => o.extra_properties = v)
+                    .undefined_when(o => o.extra_properties == null)
+                    .when_undefined(o => o.extra_properties = null);
                 cfg.set_constructor(() => new Manifest());
             });
         }

+ 3 - 1
src/lib/Repository/Repository.vala

@@ -14,7 +14,9 @@ namespace Usm {
             return PropertyMapper.build_for<Repository>(cfg => {
                 cfg.map<string>("name", o => o.name, (o, v) => o.name = v);
                 cfg.map<string>("summary", o => o.summary, (o, v) => o.summary = v);
-                cfg.map<string>("url", o => o.url, (o, v) => o.url = v, false);
+                cfg.map<string>("url", o => o.url, (o, v) => o.url = v)
+                    .undefined_when(o => o.url == null)
+                    .when_undefined(o => o.url = null);
                 cfg.map<string>("key", o => o.key.to_base64(), (o, v) => o.key = new BinaryData.from_base64(v));
                 cfg.map<int>("cache_expiration", o => o.cache_expiration, (o, v) => o.cache_expiration = v);
                 cfg.set_constructor(() => new Repository());

+ 1 - 1
src/lib/Repository/RepositoryListing.vala

@@ -29,7 +29,7 @@ namespace Usm {
                     signatures = json
                         .get_array("signatures")
                         .as_objects()
-                        .try_select<RepositoryListingSignature>(j => mapper.materialise(j))
+                        .attempt_select<RepositoryListingSignature>(j => mapper.materialise(j))
                         .to_vector();
 
                     var buffer = new uint8[ChecksumType.SHA512.get_length()];

+ 1 - 1
src/lib/State/State.vala

@@ -35,7 +35,7 @@ namespace Usm {
 
         public Enumerable<Repository> get_repositories() throws Error {
             return directory(Path.build_filename(config_path, "repos.d"))
-                .try_select<Repository>(d => new Repository.from_file(Path.build_filename(config_path, "repos.d", d)))
+                .attempt_select<Repository>(d => new Repository.from_file(Path.build_filename(config_path, "repos.d", d)))
                 .to_series();
         }
 

+ 9 - 3
src/lib/Tag/Tag.vala

@@ -76,9 +76,15 @@ namespace Usm {
         private Tag.empty() {}
         private static PropertyMapper<Tag> get_mapper() {
             return PropertyMapper.build_for<Tag>(cfg => {
-                cfg.map<string>("owner", o => o.owner, (o, v) => o.owner = v, true);
-                cfg.map<string>("version", o => o.version, (o, v) => o.version = v, true);
-                cfg.map<Properties>("data", o => o.data, (o, v) => o.data = v, false);
+                cfg.map<string>("owner", o => o.owner, (o, v) => o.owner = v)
+                    .undefined_when(o => o.owner == null)
+                    .when_undefined(o => o.owner = null);
+                cfg.map<string>("version", o => o.version, (o, v) => o.version = v)
+                    .undefined_when(o => o.version == null)
+                    .when_undefined(o => o.version = null);
+                cfg.map<Properties>("data", o => o.data, (o, v) => o.data = v)
+                    .undefined_when(o => o.data == null)
+                    .when_undefined(o => o.data = null);
                 cfg.set_constructor(() => new Tag.empty());
             });
         }

+ 1 - 1
src/lib/Transaction.vala

@@ -118,7 +118,7 @@ namespace Usm {
             Set<CachedPackageManifest> remaining_to_remove;
             try {
                 remaining_to_remove = to_remove
-                    .try_select<CachedPackageManifest>(p => new CachedPackageManifest(p))
+                    .attempt_select<CachedPackageManifest>(p => new CachedPackageManifest(p))
                     .to_set();
 
             }