-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add package model #9
base: main
Are you sure you want to change the base?
Conversation
The general approach LGTM. |
There was a problem hiding this 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!
src/models/Package.vala
Outdated
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; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Great! vala-lint thinks those parentheses inside the regex are method calls! |
Oomph! Should we open a bug report? |
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 We can make vala-lint ignore the line containing the regex by adding this at the end of the line: |
@colinkiama Yeah, we ignored |
The parse result for `repository` was set to "false" even when parsing was successful
Going to do some changes before merging |
This is completely WIP atm. Just pushing to get some feedback