Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

feat: add package model #9

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft

Conversation

naipotato
Copy link
Collaborator

This is completely WIP atm. Just pushing to get some feedback

src/models/Package.vala Outdated Show resolved Hide resolved
@dar5hak
Copy link
Owner

dar5hak commented Oct 5, 2021

The general approach LGTM.

@dar5hak dar5hak changed the title add package model feat: add package model Oct 5, 2021
Copy link
Collaborator

@devnix devnix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it looks great!

Comment on lines 92 to 165
class Vamp.Repository : Object {
public string type { get; set; }
public string url { get; set; }
public string directory { get; set; }

public static Repository from_json (Json.Node node) {
assert (node.get_node_type () == OBJECT);
return (Repository) Json.gobject_deserialize (typeof (Repository), node);
}

public Json.Node to_json () {
return Json.gobject_serialize (this);
}
}

class Vamp.FundingInfo : Object {
public string type { get; set; }
public string url { get; set; }

public static FundingInfo from_json (Json.Node node) {
assert (node.get_node_type () == OBJECT);
return (FundingInfo) Json.gobject_deserialize (typeof (FundingInfo), node);
}

public Json.Node to_json () {
return Json.gobject_serialize (this);
}
}

class Vamp.Person : Object {
public string name { get; set; }
public string email { get; set; }
public string url { get; set; }

public static Person from_json (Json.Node node) {
assert (node.get_node_type () == OBJECT);
return (Person) Json.gobject_deserialize (typeof (Person), node);
}

public Json.Node to_json () {
return Json.gobject_serialize (this);
}
}

class Vamp.Bugs : Object {
public string url { get; set; }
public string email { get; set; }

public static Bugs from_json (Json.Node node) {
assert (node.get_node_type () == OBJECT);
return (Bugs) Json.gobject_deserialize (typeof (Bugs), node);
}

public Json.Node to_json () {
return Json.gobject_serialize (this);
}
}

Gee.List<string> string_list_from_json (Json.Node node) {
assert (node.get_node_type () == ARRAY);

var array = node.get_array ();
var result = new Gee.ArrayList<string> ();

array.foreach_element ((_, __, element_node) => {
if (element_node.get_value_type () == Type.STRING) {
return;
}

result.add(element_node.get_string ());
});

return result;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have one file per public class: https://docs.elementary.io/develop/writing-apps/code-style#classes-and-files

Also: we will have this classes on the Vamp namespace or in a more specific namespace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in another comment, since Vala namespaces have no real advantages (literally not even in terms of member accessibility), my idea was simply not to use them unless strictly necessary: for example, if we are exposing a public API or if we want to simulate static classes.

@dar5hak
Copy link
Owner

dar5hak commented Oct 5, 2021

Great! vala-lint thinks those parentheses inside the regex are method calls!

.vscode/settings.json Outdated Show resolved Hide resolved
@devnix
Copy link
Collaborator

devnix commented Oct 5, 2021

Great! vala-lint thinks those parentheses inside the regex are method calls!

Oomph! Should we open a bug report?

@dar5hak
Copy link
Owner

dar5hak commented Oct 5, 2021

There's already an open issue: vala-lang/vala-lint#141

@colinkiama
Copy link
Collaborator

colinkiama commented Dec 1, 2021

There's already an open issue: vala-lang/vala-lint#141

They do take ages to merge in changes (doesn't seem to have dedicated maintainers) so lets just ignore the problem for now.

The rule that's being broken is the space-before-paren.

We can make vala-lint ignore the line containing the regex by adding this at the end of the line: // vala-lint=space-before-paren, line-length.

@dar5hak
Copy link
Owner

dar5hak commented Dec 1, 2021

@colinkiama Yeah, we ignored space-before-paren already in 3a7f9d1. Just not line-length.

@dar5hak dar5hak marked this pull request as ready for review March 30, 2022 17:17
@naipotato naipotato marked this pull request as draft April 13, 2022 13:09
@naipotato
Copy link
Collaborator Author

Going to do some changes before merging

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants