diff --git a/README.md b/README.md index a4f4da41..a1c07a96 100644 --- a/README.md +++ b/README.md @@ -164,10 +164,12 @@ legend: ⭐ priority , 🧪 tests If you are interested in "fontend" / desktop technologies check out separate project that works on extending Rye lanuage with GUI, Game engine and a Webview. It integrates these cool Go libraries: - * Fyne - Cross platform Material design inspired GUI framework ⭐ + * Fyne - Cross platform Material design inspired GUI framework ⭐⭐ * Ebitengine - 2d game engine * Webview - Webview GUI +![Fyne Feedback example](https://ryelang.org/rye-fyne-2.png) + **[Visit Rye-front repo](https://github.com/refaktor/rye-front)** ## Follow development diff --git a/code-of-repo-conduct.md b/code-of-repo-conduct.md new file mode 100644 index 00000000..64edb02d --- /dev/null +++ b/code-of-repo-conduct.md @@ -0,0 +1,34 @@ +# Code of repository conduct + +With recent HN post a lot of new people came to follow development of Rye. We probably all want Rye updates and general state of Rye repository to +be "a good product" to follow too. + +Here we try to come up with some directives, we could follow to achieve this. Everybody is are welcome to propose changes. + +We shouldn't have too many principles (or rules), we are not trying to create a bureaucracy here. Just the really necessary ones, the rest is advice or knowledge base ... + +## Principles we really try to follow + +1. Main branch shouldn't be left in a failed state (the red cross) +2. PRs that are meant for merging should also pass all checks +3. Each new builtin should have a docstring written and at least few tests + +## Q&A + +### How to create commits / PR-s / merge them so that feed and release notes are as informative as possible? + +_work-in-progress-text-propose-changes_ + +If there is only one commit per PR then the message is stored and used (check this). + +If there are multiple commits's then messages get lost unless we merge with *Squash and merge*. This joins messages together and uses them (positive) but also joins all code changes into one commit. +A) If reason for multiple commits is iterating on a set of changes, or making them comple (adding tests, making golint-ci pass, ...) then this makes sense. +B) If PR is composed of multiple commits each for different set of changes then some information is lost with Squash. + +* Should the choice be per-case based? +* What to do in case (B) then? +* Is there a third option? +* Should in case of (B) these be multiple PR-s anyway? + + + diff --git a/evaldo/builtins_spreadsheet.go b/evaldo/builtins_spreadsheet.go index 60a1cf4b..7964d60f 100644 --- a/evaldo/builtins_spreadsheet.go +++ b/evaldo/builtins_spreadsheet.go @@ -35,7 +35,6 @@ var Builtins_spreadsheet = map[string]*env.Builtin{ cols[i] = k.Value } } - fmt.Println(cols) spr := env.NewSpreadsheet(cols) switch data1 := arg1.(type) { case env.Block: @@ -78,7 +77,7 @@ var Builtins_spreadsheet = map[string]*env.Builtin{ "to-spreadsheet": { Argsn: 1, - Doc: "Create a spreadsheet by accepting block of dicts", + Doc: "Create a spreadsheet by accepting block or list of dicts", Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) (res env.Object) { switch block := arg0.(type) { case env.Block: @@ -118,8 +117,45 @@ var Builtins_spreadsheet = map[string]*env.Builtin{ } return *spr + case env.List: + data := block.Data + if len(data) == 0 { + return MakeBuiltinError(ps, "List is empty", "to-spreadsheet") + } + k := make(map[string]struct{}) + for _, obj := range data { + switch dict := obj.(type) { + case map[string]any: + for key := range dict { + k[key] = struct{}{} + } + default: + return MakeBuiltinError(ps, "List must contain only dicts", "to-spreadsheet") + } + } + var keys []string + for key := range k { + keys = append(keys, key) + } + spr := env.NewSpreadsheet(keys) + for _, obj := range data { + row := make([]any, len(keys)) + switch dict := obj.(type) { + case map[string]any: + for i, key := range keys { + data, ok := dict[key] + if !ok { + data = env.Void{} + } + row[i] = data + } + } + spr.AddRow(*env.NewSpreadsheetRow(row, spr)) + } + return *spr + default: - return MakeArgError(ps, 1, []env.Type{env.BlockType}, "to-spreadsheet") + return MakeArgError(ps, 1, []env.Type{env.BlockType, env.ListType}, "to-spreadsheet") } }, },