gloo 6.0.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +9 -3
- data/README.md +38 -7
- data/docs/application.md +164 -0
- data/docs/getting_started.md +112 -0
- data/docs/iterators.md +294 -0
- data/docs/language_objects.md +190 -0
- data/docs/language_scripting.md +62 -0
- data/docs/language_syntax.md +307 -0
- data/docs/objects.md +77 -0
- data/docs/operators.md +62 -0
- data/docs/plugins.md +54 -0
- data/docs/verbs.md +64 -0
- data/gloo.gemspec +3 -1
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +10 -0
- data/lib/gloo/app/platform.rb +29 -2
- data/lib/gloo/app/settings.rb +1 -1
- data/lib/gloo/core/gloo_system.rb +52 -1
- data/lib/gloo/docs/doc_data.rb +160 -0
- data/lib/gloo/docs/help_shell.rb +285 -0
- data/lib/gloo/docs/markdown_renderer.rb +39 -0
- data/lib/gloo/objs/basic/alias.rb +53 -0
- data/lib/gloo/objs/basic/boolean.rb +30 -0
- data/lib/gloo/objs/basic/container.rb +38 -0
- data/lib/gloo/objs/basic/decimal.rb +30 -0
- data/lib/gloo/objs/basic/integer.rb +58 -0
- data/lib/gloo/objs/basic/script.rb +31 -0
- data/lib/gloo/objs/basic/string.rb +51 -4
- data/lib/gloo/objs/basic/string_msgs.rb +20 -0
- data/lib/gloo/objs/basic/text.rb +51 -4
- data/lib/gloo/objs/basic/untyped.rb +21 -0
- data/lib/gloo/objs/ctrl/each.rb +63 -1
- data/lib/gloo/objs/ctrl/function.rb +69 -0
- data/lib/gloo/objs/ctrl/repeat.rb +41 -0
- data/lib/gloo/objs/dt/date.rb +43 -0
- data/lib/gloo/objs/dt/datetime.rb +50 -0
- data/lib/gloo/objs/dt/time.rb +43 -0
- data/lib/gloo/objs/str_utils/cipher.rb +59 -0
- data/lib/gloo/objs/str_utils/outline.rb +65 -1
- data/lib/gloo/objs/str_utils/password.rb +56 -0
- data/lib/gloo/objs/system/erb.rb +39 -0
- data/lib/gloo/objs/system/file_handle.rb +56 -0
- data/lib/gloo/objs/system/system.rb +29 -0
- data/lib/gloo/objs/web/http_get.rb +35 -0
- data/lib/gloo/objs/web/http_post.rb +33 -0
- data/lib/gloo/objs/web/json.rb +40 -0
- data/lib/gloo/objs/web/uri.rb +40 -0
- data/lib/gloo/shell/command_node.rb +39 -0
- data/lib/gloo/shell/context.rb +93 -0
- data/lib/gloo/shell/runner.rb +315 -0
- data/lib/gloo/verbs/break.rb +32 -0
- data/lib/gloo/verbs/check.rb +49 -0
- data/lib/gloo/verbs/cls.rb +18 -0
- data/lib/gloo/verbs/context.rb +47 -0
- data/lib/gloo/verbs/create.rb +42 -0
- data/lib/gloo/verbs/eval.rb +27 -0
- data/lib/gloo/verbs/execute.rb +27 -0
- data/lib/gloo/verbs/exists.rb +54 -2
- data/lib/gloo/verbs/files.rb +22 -0
- data/lib/gloo/verbs/help.rb +43 -178
- data/lib/gloo/verbs/if.rb +52 -0
- data/lib/gloo/verbs/invoke.rb +62 -0
- data/lib/gloo/verbs/list.rb +32 -0
- data/lib/gloo/verbs/load.rb +55 -2
- data/lib/gloo/verbs/log.rb +44 -0
- data/lib/gloo/verbs/move.rb +36 -1
- data/lib/gloo/verbs/put.rb +35 -0
- data/lib/gloo/verbs/quit.rb +19 -0
- data/lib/gloo/verbs/redirect.rb +52 -2
- data/lib/gloo/verbs/reload.rb +27 -0
- data/lib/gloo/verbs/run.rb +39 -0
- data/lib/gloo/verbs/save.rb +26 -0
- data/lib/gloo/verbs/show.rb +54 -0
- data/lib/gloo/verbs/tell.rb +32 -0
- data/lib/gloo/verbs/throw.rb +29 -0
- data/lib/gloo/verbs/unless.rb +50 -0
- data/lib/gloo/verbs/unload.rb +23 -0
- data/lib/gloo/verbs/version.rb +37 -3
- data/lib/gloo/verbs/wait.rb +26 -0
- metadata +22 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d840aa7f080d3daedcc5bbb7311b5403d40ea859edef9d88caca22b76caee6c
|
|
4
|
+
data.tar.gz: c324e249c1a307000b1de509573a5c03de4420bae941efb69ea0b1adcd927d47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48cb54242371f5b6589ba0baacf71da8b75c4f1118fecb6ba78eccb17be0f03d920551f0d93d6512802827c7bfa0cae462cf05a993f77061f525d9d6277c9e8d
|
|
7
|
+
data.tar.gz: 1bc77db8417820182b27b1f7b797f1587e21dc595d89d06b3250f8db983df149d9564f258bee5b4139182e3af95ceb9dfb23b07b533fcea5bbfe9f803a50eac1
|
data/CLAUDE.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
@/Users/ecrane/dev/gloo_meta/CLAUDE.md
|
|
2
|
-
|
|
3
1
|
# Gloo — Core Interpreter
|
|
4
2
|
|
|
5
3
|
This is the main gloo language implementation, packaged as a Ruby gem.
|
|
@@ -19,7 +17,7 @@ gloo/
|
|
|
19
17
|
│ │ ├── str_utils/
|
|
20
18
|
│ │ ├── system/ ruby, file_handle, system
|
|
21
19
|
│ │ └── web/ http_get, http_post, json, uri, erb
|
|
22
|
-
│ ├── verbs/ One file per verb (
|
|
20
|
+
│ ├── verbs/ One file per verb (29 total)
|
|
23
21
|
│ ├── persist/ File loading/saving
|
|
24
22
|
│ ├── convert/ Type conversion
|
|
25
23
|
│ └── plugin/ Plugin system
|
|
@@ -27,6 +25,14 @@ gloo/
|
|
|
27
25
|
└── test.gloo/ Gloo-language integration tests
|
|
28
26
|
```
|
|
29
27
|
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
This project is the authoritative source for gloo language documentation — not the `vaults/gloo` Obsidian vault, whose old `doc/` folder was renamed to `doc_deprecated/` and retired.
|
|
31
|
+
|
|
32
|
+
- **Narrative reference** — `docs/*.md`, ten flat files: `getting_started.md`, `application.md`, `language_objects.md`, `language_syntax.md`, `language_scripting.md`, `operators.md`, `iterators.md`, `objects.md`, `verbs.md`, `plugins.md`. Linked from the root `README.md`. Convention: no markdown link syntax between pages (plain-text pointers instead, e.g. "see Put" not `[Put](put.md)`) since these are read both on GitHub and in a terminal; `---` separates sections that came from different source material.
|
|
33
|
+
- **Verb/object reference** — each verb (`lib/gloo/verbs/*.rb`) and object type (`lib/gloo/objs/**/*.rb`) class defines `self.doc_data` (name, shortcut, description, syntax, parameters, result, errors, examples, notes — see `lib/gloo/docs/doc_data.rb`), rendered by the in-app interactive help shell (`help`/`?`, see `lib/gloo/docs/help_shell.rb`). When adding or changing a verb or object type, add/update its `doc_data` too.
|
|
34
|
+
- Core-lib gems (`gloo_core_libraries`) follow the same `doc_data` pattern for their own verbs/objects; a narrative `doc/` folder per gem is planned but not yet built.
|
|
35
|
+
|
|
30
36
|
## Test Suites
|
|
31
37
|
|
|
32
38
|
### Ruby unit tests — `test/`
|
data/README.md
CHANGED
|
@@ -1,24 +1,55 @@
|
|
|
1
1
|
# Gloo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## About This Project
|
|
4
4
|
|
|
5
|
+
gloo is a personal passion project — a custom interpreted programming language
|
|
6
|
+
built in Ruby that I've been designing and building over several years. It's
|
|
7
|
+
under active, ongoing development, so expect the design (especially around
|
|
8
|
+
GUI support) to keep evolving.
|
|
9
|
+
|
|
10
|
+
This is shared publicly for visibility, not as a maintained open-source
|
|
11
|
+
project. I'm not actively seeking contributions right now, but feel free to
|
|
12
|
+
open an issue if something's broken or you're curious about the design —
|
|
13
|
+
just know response times may be slow.
|
|
5
14
|
|
|
6
|
-
## Installation
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
## Installation
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
The gloo gem is published on [RubyGems](https://rubygems.org/gems/gloo) and
|
|
19
|
+
can be installed with:
|
|
11
20
|
|
|
21
|
+
```
|
|
22
|
+
gem install gloo
|
|
23
|
+
```
|
|
12
24
|
|
|
13
25
|
## Usage
|
|
14
26
|
|
|
15
27
|
Run gloo:
|
|
16
28
|
|
|
17
|
-
|
|
29
|
+
```
|
|
30
|
+
gloo
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
See documentation below, or the in-app help for usage.
|
|
18
34
|
|
|
19
35
|
|
|
20
36
|
## Documentation
|
|
21
37
|
|
|
22
|
-
|
|
38
|
+
Read in order for a guided tour of the language, top to bottom, or jump straight to any page — pages toward the bottom are reference material and read fine out of sequence.
|
|
39
|
+
|
|
40
|
+
1. [Getting Started](docs/getting_started.md) — prerequisites, installation, hello world, history and concepts
|
|
41
|
+
2. [Application](docs/application.md) — running gloo, modes, configuration, logging, the in-app help shell
|
|
42
|
+
3. [Language, Objects](docs/language_objects.md) — object naming, keywords, literals, value conversion
|
|
43
|
+
4. [Language, Syntax](docs/language_syntax.md) — color, errors, events, system objects, here/it, pathnames
|
|
44
|
+
5. [Language, Scripting](docs/language_scripting.md) — script files, constants, line continuation
|
|
45
|
+
6. [Objects](docs/objects.md) — a tour of built-in object types (string, container, integer)
|
|
46
|
+
7. [Verbs](docs/verbs.md) — a tour of verbs (run, tell, put)
|
|
47
|
+
8. [Operators](docs/operators.md) — math and comparison operators
|
|
48
|
+
9. [Iterators](docs/iterators.md) — each, repeat
|
|
49
|
+
10. [Plugins](docs/plugins.md) — core libraries and user extensions
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## License
|
|
23
53
|
|
|
24
|
-
|
|
54
|
+
This project is licensed under the [MIT License](LICENSE.txt) — see
|
|
55
|
+
`LICENSE.txt` for details.
|
data/docs/application.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Gloo Application
|
|
2
|
+
|
|
3
|
+
**Contents**
|
|
4
|
+
|
|
5
|
+
- The Gloo Home Directory
|
|
6
|
+
- Running Gloo
|
|
7
|
+
- Modes
|
|
8
|
+
- Configuration
|
|
9
|
+
- Logging
|
|
10
|
+
- Help
|
|
11
|
+
|
|
12
|
+
## The Gloo Home Directory
|
|
13
|
+
|
|
14
|
+
Gloo keeps its configuration, projects, and logs under a per-user home directory. This is exposed at runtime through a set of gloo system objects (see Language, Syntax) (`gloo.gloo_home`, and friends):
|
|
15
|
+
|
|
16
|
+
- `gloo.gloo_home` — the gloo home directory
|
|
17
|
+
- `gloo.gloo_config` — the configuration directory (see Configuration, below)
|
|
18
|
+
- `gloo.gloo_projects` — the projects directory (same as `gloo.app` when an app is running)
|
|
19
|
+
- `gloo.gloo_log` — the logging directory (see Logging, below)
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
> show gloo.gloo_home
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Running Gloo
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
gloo [global option] [file]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Running gloo with a file specified will run that file. Once that file is done, gloo will quit. However, by specifying `--cli`, once the file has finished, gloo will remain open in CLI mode.
|
|
32
|
+
|
|
33
|
+
When specifying a file there are a couple ways to reference the gloo file to open:
|
|
34
|
+
|
|
35
|
+
- By Path
|
|
36
|
+
- Use an absolute or relative path to the gloo file.
|
|
37
|
+
- Include the `.gloo` or other file extension when specifying by path.
|
|
38
|
+
- For example:
|
|
39
|
+
```
|
|
40
|
+
gloo ~/folder/file.gloo
|
|
41
|
+
```
|
|
42
|
+
- By Project
|
|
43
|
+
- Use the path within the project folder.
|
|
44
|
+
- Do not include the `.gloo` or other file extension.
|
|
45
|
+
- The location of the project folder is part of the configuration.
|
|
46
|
+
- For example:
|
|
47
|
+
```
|
|
48
|
+
gloo my_project/file.gloo
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Modes
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
--cli - Run in CLI mode
|
|
55
|
+
- If no options are specified, this is the default.
|
|
56
|
+
--app - Run in App mode
|
|
57
|
+
- Requires an extra parameter which is the root path of the project.
|
|
58
|
+
- Running in app mode overrides the default project path for gloo.
|
|
59
|
+
- By default gloo will look for a start.gloo file in the
|
|
60
|
+
root level of the project. That start.gloo file should load other files
|
|
61
|
+
and run the app.
|
|
62
|
+
--script - Run in Script mode
|
|
63
|
+
- Run the script in the file parameter and then quit.
|
|
64
|
+
- If a file is provided as a parameter this option does not need to be specified.
|
|
65
|
+
--test - Run in Test mode
|
|
66
|
+
--version - Show application version
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Configuration
|
|
70
|
+
|
|
71
|
+
When gloo runs, it looks for a configuration file which it expects to find in `~/gloo/config/`. If there is no `gloo.yml` file in that directory, one will be created and default values added.
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
#
|
|
75
|
+
# Gloo configuration
|
|
76
|
+
#
|
|
77
|
+
gloo:
|
|
78
|
+
|
|
79
|
+
#
|
|
80
|
+
# Root directory for projects.
|
|
81
|
+
# Update this with the directory with your gloo projects.
|
|
82
|
+
#
|
|
83
|
+
project_path: /Users/my_user/gloo/projects
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Run this script when starting up gloo.
|
|
87
|
+
# (Only if a script file is not specified.)
|
|
88
|
+
#
|
|
89
|
+
start_with: start
|
|
90
|
+
|
|
91
|
+
#
|
|
92
|
+
# Indentation (spaces) when showing an object outline.
|
|
93
|
+
#
|
|
94
|
+
list_indent: 3
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Show listing the object tree,
|
|
98
|
+
# how many levels of children will be shown?
|
|
99
|
+
# Children at deeper levels will be hidden.
|
|
100
|
+
#
|
|
101
|
+
list_levels: 3
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# Show debug statements in the log?
|
|
105
|
+
#
|
|
106
|
+
debug: false
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Logging
|
|
110
|
+
|
|
111
|
+
Gloo writes to the `gloo.log` and `error.log` files as well as to the console.
|
|
112
|
+
|
|
113
|
+
Debug messages are written to the log only, but other messages are also written to the console unless the application is running in quiet mode.
|
|
114
|
+
|
|
115
|
+
Only error and warning level messages are written to the error log.
|
|
116
|
+
|
|
117
|
+
The application logs folder is in the gloo folder. When gloo is run, the log files will be created if they do not exist. To trim the logs, just delete those log files.
|
|
118
|
+
|
|
119
|
+
Example tail command to watch the gloo log:
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
tail -f ~/gloo/logs/gloo.log
|
|
123
|
+
tail -f ~/gloo/logs/error.log
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Help
|
|
127
|
+
|
|
128
|
+
### Inline Reference
|
|
129
|
+
|
|
130
|
+
Gloo has a built-in `help` verb (shortcut `?`) that enters an interactive help shell:
|
|
131
|
+
|
|
132
|
+
```gloo
|
|
133
|
+
help
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
From the `help>` prompt, look up verbs, object types, settings, extensions, libraries, and narrative doc pages, or get detailed help for a specific verb, object, doc page, loaded library, or loaded extension:
|
|
137
|
+
|
|
138
|
+
- `verbs` — list all verbs
|
|
139
|
+
- `objects` — list all object types
|
|
140
|
+
- `settings` — show application settings
|
|
141
|
+
- `extensions` — list loaded extensions (only loaded extensions are shown; use `load ext {name}` first)
|
|
142
|
+
- `libraries` — list loaded libraries (only loaded libraries are shown; use `load lib {name}` first)
|
|
143
|
+
- `docs` — list all narrative doc pages (this page and its siblings)
|
|
144
|
+
- `verb {name}` — detailed help for one verb (tab-completable)
|
|
145
|
+
- `object {name}` — detailed help for one object type (tab-completable)
|
|
146
|
+
- `doc {name}` — show one narrative doc page (tab-completable)
|
|
147
|
+
- `library {name}` — show a loaded library's README, from the root of its gem (tab-completable, loaded libraries only)
|
|
148
|
+
- `extension {name}` — show a loaded extension's README, from the root of its extension folder (tab-completable, loaded extensions only)
|
|
149
|
+
- `quit` — leave the help shell
|
|
150
|
+
|
|
151
|
+
```gloo
|
|
152
|
+
> help
|
|
153
|
+
help> verbs
|
|
154
|
+
help> verb put
|
|
155
|
+
help> object container
|
|
156
|
+
help> docs
|
|
157
|
+
help> doc getting_started
|
|
158
|
+
help> library db
|
|
159
|
+
help> quit
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Narrative Docs in the Shell
|
|
163
|
+
|
|
164
|
+
This page and its nine siblings (`docs/*.md` in the interpreter's source) are the same files shown by `help> doc {name}` — there's no separate doc server or web mode. A `gloo --doc` local web server was considered and put off in favor of this: one system, no separate build/serve step.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Getting Started with Gloo
|
|
2
|
+
|
|
3
|
+
**Contents**
|
|
4
|
+
|
|
5
|
+
- Prerequisites
|
|
6
|
+
- Installation
|
|
7
|
+
- Configuration
|
|
8
|
+
- Running Gloo
|
|
9
|
+
- Hello World
|
|
10
|
+
- History
|
|
11
|
+
- Concepts
|
|
12
|
+
- Source Code
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- Ruby
|
|
17
|
+
|
|
18
|
+
Gloo requires Ruby to run. Nothing else is required for the core interpreter.
|
|
19
|
+
|
|
20
|
+
If you don't have Ruby installed, you can download it from here: http://www.ruby-lang.org/en/downloads/
|
|
21
|
+
|
|
22
|
+
MySQL and Postgres are only needed if you plan to use the `gloo-mysql` or `gloo-pg` core library gems to connect to those databases from a gloo script — see Plugins. Install them only if and when you load one of those libraries.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Gloo is distributed as a Ruby gem (https://rubygems.org/gems/gloo). Once you have Ruby installed, you can install Gloo by running the following command:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
gem install gloo
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
See Application Configuration for details on how to configure Gloo.
|
|
35
|
+
|
|
36
|
+
## Running Gloo
|
|
37
|
+
|
|
38
|
+
To start Gloo, run the following command:
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
gloo
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This will start the Gloo application. This is just enough to get going — for the full set of global options and the two ways to point gloo at a file (by path or by project), see Application, Running Gloo.
|
|
45
|
+
|
|
46
|
+
## Hello World
|
|
47
|
+
|
|
48
|
+
Once Gloo is running you can interact with the gloo interpreter. Type the following command to see the "Hello World" message:
|
|
49
|
+
|
|
50
|
+
```gloo
|
|
51
|
+
show "Hello World"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## History
|
|
55
|
+
|
|
56
|
+
### CLI, On Ruby
|
|
57
|
+
|
|
58
|
+
Gloo is a scripting language and a CLI runtime engine. It was built primarily to run on the Mac and has hooks into several Mac technologies. It runs, at least nominally, on Windows and Linux as well.
|
|
59
|
+
|
|
60
|
+
Gloo was built in Ruby as a gem. More than that, it has hooks into ruby, can run ruby code, and shares a lot the way ruby works.
|
|
61
|
+
|
|
62
|
+
### The Name "Gloo" and a Bit of History
|
|
63
|
+
|
|
64
|
+
Like glue, it is meant to hold things together.
|
|
65
|
+
|
|
66
|
+
Gloo follows in a series of languages created by it's author. The first was called 'EDT' which stood for Eric's Data Tools. That first set of tools was followed shortly by 'Sqlman' built in the late 90s. Sqlman evolved into a more generalized tool called "AppBuilder". Those three applications were built in Prograph CPX and ran on pre-OS X Macs.
|
|
67
|
+
|
|
68
|
+
ObjectWise came along as a cross-platform version of AppBuilder. ObjectWise was built in Java on a Sun workstation, and targeted Solaris, Mac OS X, and Windows. It was built around the turn of the millenium. But with job changes, the project went cold for a while and was revived under the name 'Obliner' around 2010. Obliner never gained much traction and never had any substantial use.
|
|
69
|
+
|
|
70
|
+
Then in late 2018, the project with many names took on a new form as a ruby gem. It was intially called 'object-script' but that was soon changed to 'gloo'. Gloo remains under active development. It has one fanatical user, it's author, but that user makes daily use of it in his work, for personal use, and for fun.
|
|
71
|
+
|
|
72
|
+
### Why Another Language?
|
|
73
|
+
|
|
74
|
+
Why another scripting language? Why not just use ruby? Everything in gloo could be done in ruby or any number of other programming or scripting languages. Well, why not? Why should a developer NOT build a programming language as a way to learn and tinker? Why not have a bespoke tool that does just what one wants and that one can change as one pleases? Building a language is an act of invention and creativity. It is an act of rebellion against the machine of best practice and uniformity that corporate jobs often end up being. It is entirely consistent with being a software developer. And why not build a language for the sheer joy of inventing?
|
|
75
|
+
|
|
76
|
+
### Ideas Behind It
|
|
77
|
+
|
|
78
|
+
The following technologies influenced the thinking behind gloo and its predecessors:
|
|
79
|
+
|
|
80
|
+
- HyperCard
|
|
81
|
+
- Userland Frontier
|
|
82
|
+
- Prograph
|
|
83
|
+
- Newton OS
|
|
84
|
+
- Ruby and Rails
|
|
85
|
+
|
|
86
|
+
But each of those could be an essay in and of themselves. Maybe some day they will be.
|
|
87
|
+
|
|
88
|
+
## Concepts
|
|
89
|
+
|
|
90
|
+
### Outline Based Language
|
|
91
|
+
|
|
92
|
+
One of the key ideas of gloo is that code and data is organized in an outline. All data and code is intermixed in the same hierarchy. And data in this case represents what in other languages are variables as well as in memory data structures and data storage. Data and code all in the same space. It is all accessed the same way, with a path through the outline. And variables and data can be inspected just like code. This can be done at time of coding as well as at runtime.
|
|
93
|
+
|
|
94
|
+
### Composition
|
|
95
|
+
|
|
96
|
+
Another key idea is that code is composed of smaller pieces. The best way to think of gloo is a collection of parts that are assembled together to make something useful.
|
|
97
|
+
|
|
98
|
+
### Convention
|
|
99
|
+
|
|
100
|
+
Like Rails, gloo prefers convention over configuration. That is to say that it attempts to make configuration unnecessary unless the user wishes to diverge from the convention. It does not require the programmer to tell it what it can figure out on its own.
|
|
101
|
+
|
|
102
|
+
### Objects & Messages
|
|
103
|
+
|
|
104
|
+
In gloo, everything is an object. The object types are built into the language. (There is a plan to add support for user defined object types.)
|
|
105
|
+
|
|
106
|
+
Objects can have simple values and can also contain other objects.
|
|
107
|
+
|
|
108
|
+
Interaction with objects is done by sending messages to them.
|
|
109
|
+
|
|
110
|
+
## Source Code
|
|
111
|
+
|
|
112
|
+
Gloo source code is in GitHub (https://github.com/ecrane/gloo), although the repository is currently private. It might be made public in the future if there is interest or need.
|
data/docs/iterators.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Iterators
|
|
2
|
+
|
|
3
|
+
**Contents**
|
|
4
|
+
|
|
5
|
+
- Each
|
|
6
|
+
- Each Child
|
|
7
|
+
- Each Directory
|
|
8
|
+
- Each File
|
|
9
|
+
- Each Line
|
|
10
|
+
- Each Word
|
|
11
|
+
- Repeat
|
|
12
|
+
|
|
13
|
+
## Each
|
|
14
|
+
|
|
15
|
+
Perform an action for each item in a collection.
|
|
16
|
+
|
|
17
|
+
There are several variations on this object type. They are:
|
|
18
|
+
|
|
19
|
+
- each child object in a container
|
|
20
|
+
- each directory in a folder
|
|
21
|
+
- each file in a folder
|
|
22
|
+
- each line in a block of text (string)
|
|
23
|
+
- each word in a string
|
|
24
|
+
|
|
25
|
+
The general pattern is that there are three children:
|
|
26
|
+
|
|
27
|
+
- An `in` object that points to the item collection.
|
|
28
|
+
- A reference to the item instance. This reference is updated each time through the loop. Note that the name of this child is used to determine which kind of loop is in play.
|
|
29
|
+
- A `do` script to run for each iteration through the loop.
|
|
30
|
+
|
|
31
|
+
Messages:
|
|
32
|
+
|
|
33
|
+
- `run` — Run the loop for each item in the collection.
|
|
34
|
+
|
|
35
|
+
See examples in the specific variations, below.
|
|
36
|
+
|
|
37
|
+
See also: Object Base.
|
|
38
|
+
|
|
39
|
+
## Each Child
|
|
40
|
+
|
|
41
|
+
Iterate for each child in a container.
|
|
42
|
+
|
|
43
|
+
Children:
|
|
44
|
+
|
|
45
|
+
- `child` (alias)
|
|
46
|
+
- Alias to the child instance.
|
|
47
|
+
- `in` (container)
|
|
48
|
+
- The collection of objects we will iterate over.
|
|
49
|
+
- `do` (script)
|
|
50
|
+
- The action we want to perform for each child in the container.
|
|
51
|
+
|
|
52
|
+
### Group By
|
|
53
|
+
|
|
54
|
+
Group the results by a child property. This is an optional feature. It can be used when we want to do something specific every time a value in the child object changes.
|
|
55
|
+
|
|
56
|
+
Whenever the `group_by` value changes, the `on_group_start` and `on_group_end` scripts are run. This can be used to aggregate results in rows or other groupings.
|
|
57
|
+
|
|
58
|
+
The group by feature adds the following children:
|
|
59
|
+
|
|
60
|
+
- `group_by` (string)
|
|
61
|
+
- The name of the child object we want to group by. This will be a property of the object instance of the `child` container.
|
|
62
|
+
- `on_group_start` (script)
|
|
63
|
+
- The action we want to perform when the `group_by` value changes. This script will be run before the `do` script for the first instance of the child with the new `group_by` value.
|
|
64
|
+
- `on_group_end` (script)
|
|
65
|
+
- The action we want to perform when the `group_by` value changes. This script will be run after the `do` script for the last instance of the `group_by` value.
|
|
66
|
+
|
|
67
|
+
Messages:
|
|
68
|
+
|
|
69
|
+
- `run` — Run the loop for each object in the container.
|
|
70
|
+
|
|
71
|
+
```gloo
|
|
72
|
+
#
|
|
73
|
+
# Show each child in a container.
|
|
74
|
+
#
|
|
75
|
+
each_child [can] :
|
|
76
|
+
|
|
77
|
+
# Iterator on children of a container.
|
|
78
|
+
for [each] :
|
|
79
|
+
child [alias] :
|
|
80
|
+
in [alias] : each_child.objs
|
|
81
|
+
do [script] : show ^.child
|
|
82
|
+
|
|
83
|
+
# Data
|
|
84
|
+
objs [can] :
|
|
85
|
+
1 [string] : one
|
|
86
|
+
2 [string] : two
|
|
87
|
+
3 [string] : three
|
|
88
|
+
|
|
89
|
+
# Run the iterator.
|
|
90
|
+
on_load [script] :
|
|
91
|
+
show 'showing children in container' (white)
|
|
92
|
+
tell each_child.for to run
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
See also: Object Base, Each, Each File, Each Line, Each Word.
|
|
96
|
+
|
|
97
|
+
## Each Directory
|
|
98
|
+
|
|
99
|
+
Iterate for each directory in a folder (directory).
|
|
100
|
+
|
|
101
|
+
Children:
|
|
102
|
+
|
|
103
|
+
- `dir` (file — a directory)
|
|
104
|
+
- The directory instance.
|
|
105
|
+
- `in` (file — a directory)
|
|
106
|
+
- The folder (directory) we will look in for directories.
|
|
107
|
+
- `do` (script)
|
|
108
|
+
- The action we want to perform for each directory in the folder.
|
|
109
|
+
|
|
110
|
+
Messages:
|
|
111
|
+
|
|
112
|
+
- `run` — Run the loop for each directory.
|
|
113
|
+
|
|
114
|
+
```gloo
|
|
115
|
+
#
|
|
116
|
+
# Show each directory.
|
|
117
|
+
#
|
|
118
|
+
each_dir [can] :
|
|
119
|
+
|
|
120
|
+
# Iterator on files in a folder.
|
|
121
|
+
for [each] :
|
|
122
|
+
dir [file] :
|
|
123
|
+
in [file] : /my/folder/
|
|
124
|
+
do [script] : show ^.dir
|
|
125
|
+
|
|
126
|
+
# Run the iterator.
|
|
127
|
+
on_load [script] :
|
|
128
|
+
show 'showing directory' (white)
|
|
129
|
+
tell each_dir.for to run
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See also: Each, Each File.
|
|
133
|
+
|
|
134
|
+
## Each File
|
|
135
|
+
|
|
136
|
+
Iterate for each file in a folder (directory).
|
|
137
|
+
|
|
138
|
+
Children:
|
|
139
|
+
|
|
140
|
+
- `file` (file)
|
|
141
|
+
- The file instance.
|
|
142
|
+
- `in` (file)
|
|
143
|
+
- The folder (directory) we will look in for files.
|
|
144
|
+
- `do` (script)
|
|
145
|
+
- The action we want to perform for each file in the folder.
|
|
146
|
+
- `ext` (string)
|
|
147
|
+
- Optional file extension. Limit to files of this kind.
|
|
148
|
+
|
|
149
|
+
Messages:
|
|
150
|
+
|
|
151
|
+
- `run` — Run the loop for each file in the folder.
|
|
152
|
+
|
|
153
|
+
```gloo
|
|
154
|
+
#
|
|
155
|
+
# Show each file in a folder.
|
|
156
|
+
#
|
|
157
|
+
each_file [can] :
|
|
158
|
+
|
|
159
|
+
# Iterator on files in a folder.
|
|
160
|
+
for [each] :
|
|
161
|
+
file [file] :
|
|
162
|
+
ext [string] : gloo
|
|
163
|
+
in [file] : /my/folder/
|
|
164
|
+
do [script] : show ^.file
|
|
165
|
+
|
|
166
|
+
# Run the iterator.
|
|
167
|
+
on_load [script] :
|
|
168
|
+
show 'showing files in folder' (white)
|
|
169
|
+
tell each_file.for to run
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See also: Object Base, Each, Each Line, Each Word, Each Child, Each Directory.
|
|
173
|
+
|
|
174
|
+
## Each Line
|
|
175
|
+
|
|
176
|
+
Iterate for each line in a text block (string).
|
|
177
|
+
|
|
178
|
+
Children:
|
|
179
|
+
|
|
180
|
+
- `line` (string)
|
|
181
|
+
- The single line of text.
|
|
182
|
+
- `in` (text)
|
|
183
|
+
- The block of text or string.
|
|
184
|
+
- `do` (script)
|
|
185
|
+
- The action we want to perform for each line in the text.
|
|
186
|
+
|
|
187
|
+
Messages:
|
|
188
|
+
|
|
189
|
+
- `run` — Run the loop for each line in the text.
|
|
190
|
+
|
|
191
|
+
```gloo
|
|
192
|
+
#
|
|
193
|
+
# Show each line in a string.
|
|
194
|
+
#
|
|
195
|
+
each_line [can] :
|
|
196
|
+
|
|
197
|
+
# Iterator on children of a container.
|
|
198
|
+
for [each] :
|
|
199
|
+
line [string] :
|
|
200
|
+
in [alias] : ^.in
|
|
201
|
+
do [script] : show ^.line
|
|
202
|
+
|
|
203
|
+
# Data
|
|
204
|
+
in [txt] : BEGIN
|
|
205
|
+
I will now write a poem
|
|
206
|
+
of several lines
|
|
207
|
+
Then I will show it
|
|
208
|
+
and it will be awesome!
|
|
209
|
+
END
|
|
210
|
+
|
|
211
|
+
# Run the iterator.
|
|
212
|
+
on_load [script] :
|
|
213
|
+
show 'showing lines in a text block' (white)
|
|
214
|
+
tell each_line.for to run
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
See also: Object Base, Each, Each Word, Each Child, Each File.
|
|
218
|
+
|
|
219
|
+
## Each Word
|
|
220
|
+
|
|
221
|
+
Iterate for each word in a string.
|
|
222
|
+
|
|
223
|
+
Children:
|
|
224
|
+
|
|
225
|
+
- `word` (string)
|
|
226
|
+
- The word (string).
|
|
227
|
+
- `in` (string)
|
|
228
|
+
- The source string.
|
|
229
|
+
- `do` (script)
|
|
230
|
+
- The action we want to perform for each word in the string.
|
|
231
|
+
|
|
232
|
+
Messages:
|
|
233
|
+
|
|
234
|
+
- `run` — Run the loop for each word in the string.
|
|
235
|
+
|
|
236
|
+
```gloo
|
|
237
|
+
#
|
|
238
|
+
# Show each word in a string.
|
|
239
|
+
#
|
|
240
|
+
each_word [can] :
|
|
241
|
+
|
|
242
|
+
# Iterator on words in a string.
|
|
243
|
+
for [each] :
|
|
244
|
+
word [string] :
|
|
245
|
+
in [string] : one word at a time
|
|
246
|
+
do [script] : show ^.word
|
|
247
|
+
|
|
248
|
+
# Run the iterator.
|
|
249
|
+
on_load [script] :
|
|
250
|
+
show 'showing words in a string' (white)
|
|
251
|
+
tell each_word.for to run
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
See also: Object Base, Each, Each Child, Each File, Each Line.
|
|
255
|
+
|
|
256
|
+
## Repeat
|
|
257
|
+
|
|
258
|
+
Run a script a given number of times.
|
|
259
|
+
|
|
260
|
+
Children:
|
|
261
|
+
|
|
262
|
+
- `times` (integer)
|
|
263
|
+
- Default: `0`
|
|
264
|
+
- The number of times to run the script.
|
|
265
|
+
- `index` (integer)
|
|
266
|
+
- Default: `0`
|
|
267
|
+
- The current iteration when the repeat loop is running.
|
|
268
|
+
- `do` (script)
|
|
269
|
+
- The action we want to perform for iteration of the loop.
|
|
270
|
+
|
|
271
|
+
Messages:
|
|
272
|
+
|
|
273
|
+
- `run` — Run the script for the given number of times.
|
|
274
|
+
|
|
275
|
+
```gloo
|
|
276
|
+
repeat [can] :
|
|
277
|
+
s [string] :
|
|
278
|
+
on_load [script] :
|
|
279
|
+
put $.screen_cols / 2 into repeat.x.times
|
|
280
|
+
tell repeat.x to run
|
|
281
|
+
show repeat.s
|
|
282
|
+
tell repeat.y to run
|
|
283
|
+
show repeat.s
|
|
284
|
+
x [repeat] :
|
|
285
|
+
times [integer] : 30
|
|
286
|
+
index [integer] : 0
|
|
287
|
+
do [script] : put repeat.s + '-' into repeat.s
|
|
288
|
+
y [repeat] :
|
|
289
|
+
times [integer] : 10
|
|
290
|
+
index [integer] : 0
|
|
291
|
+
do [script] : show repeat.y.index
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
See also: Object Base.
|