gloo 0.8.0 → 1.2.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.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +2 -1
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/LICENSE.txt +1 -1
  7. data/gloo.gemspec +12 -4
  8. data/lib/VERSION +1 -1
  9. data/lib/dependencies.rb +4 -4
  10. data/lib/gloo/app/info.rb +3 -1
  11. data/lib/gloo/app/log.rb +1 -29
  12. data/lib/gloo/app/platform.rb +142 -0
  13. data/lib/gloo/objs/cli/banner.rb +2 -2
  14. data/lib/gloo/objs/cli/bar.rb +4 -4
  15. data/lib/gloo/objs/cli/colorize.rb +3 -3
  16. data/lib/gloo/objs/cli/confirm.rb +3 -3
  17. data/lib/gloo/objs/cli/menu.rb +9 -9
  18. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  19. data/lib/gloo/objs/cli/pastel.rb +2 -2
  20. data/lib/gloo/objs/cli/prompt.rb +4 -4
  21. data/lib/gloo/objs/cli/select.rb +4 -4
  22. data/lib/gloo/objs/data/mysql.rb +9 -9
  23. data/lib/gloo/objs/data/sqlite.rb +10 -10
  24. data/lib/gloo/objs/dev/git.rb +7 -7
  25. data/lib/gloo/objs/dev/stats.rb +8 -5
  26. data/lib/gloo/objs/snd/play.rb +1 -1
  27. data/lib/gloo/objs/snd/say.rb +2 -2
  28. data/lib/gloo/objs/system/file_handle.rb +9 -9
  29. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  30. data/lib/gloo/objs/system/system.rb +2 -2
  31. data/lib/gloo/verbs/alert.rb +7 -7
  32. data/lib/gloo/verbs/beep.rb +1 -1
  33. data/lib/gloo/verbs/cls.rb +2 -2
  34. data/lib/gloo/verbs/help.rb +7 -189
  35. data/lib/gloo/verbs/version.rb +3 -3
  36. data/lib/gloo.rb +5 -1
  37. data/lib/run.rb +5 -1
  38. metadata +41 -177
  39. data/Gemfile.lock +0 -171
  40. data/lib/gloo/app/args.rb +0 -112
  41. data/lib/gloo/app/engine.rb +0 -230
  42. data/lib/gloo/app/help.rb +0 -156
  43. data/lib/gloo/app/mode.rb +0 -27
  44. data/lib/gloo/app/settings.rb +0 -186
  45. data/lib/gloo/convert/converter.rb +0 -35
  46. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  47. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  48. data/lib/gloo/convert/string_to_integer.rb +0 -20
  49. data/lib/gloo/core/baseo.rb +0 -30
  50. data/lib/gloo/core/dictionary.rb +0 -181
  51. data/lib/gloo/core/error.rb +0 -61
  52. data/lib/gloo/core/event_manager.rb +0 -44
  53. data/lib/gloo/core/factory.rb +0 -210
  54. data/lib/gloo/core/gloo_system.rb +0 -266
  55. data/lib/gloo/core/heap.rb +0 -52
  56. data/lib/gloo/core/here.rb +0 -36
  57. data/lib/gloo/core/it.rb +0 -36
  58. data/lib/gloo/core/literal.rb +0 -30
  59. data/lib/gloo/core/obj.rb +0 -303
  60. data/lib/gloo/core/obj_finder.rb +0 -30
  61. data/lib/gloo/core/op.rb +0 -40
  62. data/lib/gloo/core/parser.rb +0 -59
  63. data/lib/gloo/core/pn.rb +0 -188
  64. data/lib/gloo/core/tokens.rb +0 -165
  65. data/lib/gloo/core/verb.rb +0 -86
  66. data/lib/gloo/exec/action.rb +0 -48
  67. data/lib/gloo/exec/dispatch.rb +0 -40
  68. data/lib/gloo/exec/exec_env.rb +0 -74
  69. data/lib/gloo/exec/runner.rb +0 -45
  70. data/lib/gloo/exec/script.rb +0 -49
  71. data/lib/gloo/exec/stack.rb +0 -78
  72. data/lib/gloo/expr/expression.rb +0 -118
  73. data/lib/gloo/expr/l_boolean.rb +0 -36
  74. data/lib/gloo/expr/l_decimal.rb +0 -39
  75. data/lib/gloo/expr/l_integer.rb +0 -37
  76. data/lib/gloo/expr/l_string.rb +0 -58
  77. data/lib/gloo/expr/op_div.rb +0 -22
  78. data/lib/gloo/expr/op_minus.rb +0 -22
  79. data/lib/gloo/expr/op_mult.rb +0 -22
  80. data/lib/gloo/expr/op_plus.rb +0 -24
  81. data/lib/gloo/help/app/application.txt +0 -22
  82. data/lib/gloo/help/app/configuration.txt +0 -7
  83. data/lib/gloo/help/app/default_help.txt +0 -14
  84. data/lib/gloo/help/app/logging.txt +0 -16
  85. data/lib/gloo/help/core/color.txt +0 -31
  86. data/lib/gloo/help/core/error.txt +0 -33
  87. data/lib/gloo/help/core/events.txt +0 -21
  88. data/lib/gloo/help/core/gloo_system.txt +0 -57
  89. data/lib/gloo/help/core/here.txt +0 -30
  90. data/lib/gloo/help/core/it.txt +0 -23
  91. data/lib/gloo/help/core/ops.txt +0 -16
  92. data/lib/gloo/help/core/pathname.txt +0 -29
  93. data/lib/gloo/help/objs/basic/alias.txt +0 -36
  94. data/lib/gloo/help/objs/basic/boolean.txt +0 -28
  95. data/lib/gloo/help/objs/basic/container.txt +0 -33
  96. data/lib/gloo/help/objs/basic/decimal.txt +0 -28
  97. data/lib/gloo/help/objs/basic/integer.txt +0 -27
  98. data/lib/gloo/help/objs/basic/script.txt +0 -29
  99. data/lib/gloo/help/objs/basic/string.txt +0 -28
  100. data/lib/gloo/help/objs/basic/text.txt +0 -27
  101. data/lib/gloo/help/objs/basic/untyped.txt +0 -22
  102. data/lib/gloo/help/objs/cli/banner.txt +0 -49
  103. data/lib/gloo/help/objs/cli/bar.txt +0 -37
  104. data/lib/gloo/help/objs/cli/colorize.txt +0 -33
  105. data/lib/gloo/help/objs/cli/confirm.txt +0 -26
  106. data/lib/gloo/help/objs/cli/menu.txt +0 -44
  107. data/lib/gloo/help/objs/cli/menu_item.txt +0 -26
  108. data/lib/gloo/help/objs/cli/pastel.txt +0 -43
  109. data/lib/gloo/help/objs/cli/prompt.txt +0 -27
  110. data/lib/gloo/help/objs/cli/select.txt +0 -34
  111. data/lib/gloo/help/objs/ctrl/each.txt +0 -48
  112. data/lib/gloo/help/objs/ctrl/repeat.txt +0 -38
  113. data/lib/gloo/help/objs/data/markdown.txt +0 -25
  114. data/lib/gloo/help/objs/data/mysql.txt +0 -40
  115. data/lib/gloo/help/objs/data/query.txt +0 -37
  116. data/lib/gloo/help/objs/data/sqlite.txt +0 -26
  117. data/lib/gloo/help/objs/data/table.txt +0 -46
  118. data/lib/gloo/help/objs/dev/git_repo.txt +0 -36
  119. data/lib/gloo/help/objs/dev/stats.txt +0 -36
  120. data/lib/gloo/help/objs/dt/date.txt +0 -23
  121. data/lib/gloo/help/objs/dt/datetime.txt +0 -24
  122. data/lib/gloo/help/objs/dt/time.txt +0 -23
  123. data/lib/gloo/help/objs/ror/erb.txt +0 -37
  124. data/lib/gloo/help/objs/ror/eval.txt +0 -24
  125. data/lib/gloo/help/objs/snd/play.txt +0 -23
  126. data/lib/gloo/help/objs/snd/say.txt +0 -28
  127. data/lib/gloo/help/objs/system/file.txt +0 -48
  128. data/lib/gloo/help/objs/system/ssh_exec.txt +0 -30
  129. data/lib/gloo/help/objs/system/system.txt +0 -32
  130. data/lib/gloo/help/objs/web/http_get.txt +0 -35
  131. data/lib/gloo/help/objs/web/http_post.txt +0 -34
  132. data/lib/gloo/help/objs/web/json.txt +0 -34
  133. data/lib/gloo/help/objs/web/slack.txt +0 -33
  134. data/lib/gloo/help/objs/web/teams.txt +0 -30
  135. data/lib/gloo/help/objs/web/uri.txt +0 -38
  136. data/lib/gloo/help/verbs/alert.txt +0 -33
  137. data/lib/gloo/help/verbs/beep.txt +0 -25
  138. data/lib/gloo/help/verbs/cls.txt +0 -24
  139. data/lib/gloo/help/verbs/context.txt +0 -43
  140. data/lib/gloo/help/verbs/create.txt +0 -33
  141. data/lib/gloo/help/verbs/execute.txt +0 -27
  142. data/lib/gloo/help/verbs/help.txt +0 -34
  143. data/lib/gloo/help/verbs/if.txt +0 -37
  144. data/lib/gloo/help/verbs/list.txt +0 -34
  145. data/lib/gloo/help/verbs/load.txt +0 -38
  146. data/lib/gloo/help/verbs/move.txt +0 -42
  147. data/lib/gloo/help/verbs/put.txt +0 -38
  148. data/lib/gloo/help/verbs/quit.txt +0 -25
  149. data/lib/gloo/help/verbs/run.txt +0 -41
  150. data/lib/gloo/help/verbs/save.txt +0 -26
  151. data/lib/gloo/help/verbs/show.txt +0 -30
  152. data/lib/gloo/help/verbs/tell.txt +0 -34
  153. data/lib/gloo/help/verbs/unless.txt +0 -38
  154. data/lib/gloo/help/verbs/version.txt +0 -32
  155. data/lib/gloo/help/verbs/wait.txt +0 -29
  156. data/lib/gloo/objs/basic/alias.rb +0 -78
  157. data/lib/gloo/objs/basic/boolean.rb +0 -120
  158. data/lib/gloo/objs/basic/container.rb +0 -76
  159. data/lib/gloo/objs/basic/decimal.rb +0 -76
  160. data/lib/gloo/objs/basic/integer.rb +0 -73
  161. data/lib/gloo/objs/basic/script.rb +0 -99
  162. data/lib/gloo/objs/basic/string.rb +0 -77
  163. data/lib/gloo/objs/basic/text.rb +0 -87
  164. data/lib/gloo/objs/basic/untyped.rb +0 -41
  165. data/lib/gloo/objs/ctrl/each.rb +0 -279
  166. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  167. data/lib/gloo/objs/data/markdown.rb +0 -84
  168. data/lib/gloo/objs/data/query.rb +0 -176
  169. data/lib/gloo/objs/data/table.rb +0 -140
  170. data/lib/gloo/objs/dt/date.rb +0 -50
  171. data/lib/gloo/objs/dt/datetime.rb +0 -62
  172. data/lib/gloo/objs/dt/time.rb +0 -50
  173. data/lib/gloo/objs/ror/erb.rb +0 -116
  174. data/lib/gloo/objs/ror/eval.rb +0 -107
  175. data/lib/gloo/objs/web/http_get.rb +0 -159
  176. data/lib/gloo/objs/web/http_post.rb +0 -183
  177. data/lib/gloo/objs/web/json.rb +0 -135
  178. data/lib/gloo/objs/web/slack.rb +0 -130
  179. data/lib/gloo/objs/web/teams.rb +0 -117
  180. data/lib/gloo/objs/web/uri.rb +0 -148
  181. data/lib/gloo/persist/file_loader.rb +0 -191
  182. data/lib/gloo/persist/file_saver.rb +0 -49
  183. data/lib/gloo/persist/file_storage.rb +0 -45
  184. data/lib/gloo/persist/line_splitter.rb +0 -81
  185. data/lib/gloo/persist/persist_man.rb +0 -120
  186. data/lib/gloo/utils/format.rb +0 -21
  187. data/lib/gloo/utils/stats.rb +0 -205
  188. data/lib/gloo/utils/words.rb +0 -19
  189. data/lib/gloo/verbs/context.rb +0 -62
  190. data/lib/gloo/verbs/create.rb +0 -68
  191. data/lib/gloo/verbs/execute.rb +0 -56
  192. data/lib/gloo/verbs/if.rb +0 -92
  193. data/lib/gloo/verbs/list.rb +0 -98
  194. data/lib/gloo/verbs/load.rb +0 -45
  195. data/lib/gloo/verbs/move.rb +0 -89
  196. data/lib/gloo/verbs/put.rb +0 -94
  197. data/lib/gloo/verbs/quit.rb +0 -40
  198. data/lib/gloo/verbs/run.rb +0 -75
  199. data/lib/gloo/verbs/save.rb +0 -39
  200. data/lib/gloo/verbs/show.rb +0 -64
  201. data/lib/gloo/verbs/tell.rb +0 -79
  202. data/lib/gloo/verbs/unless.rb +0 -92
  203. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,42 +0,0 @@
1
- MOVE VERB
2
- NAME: move
3
- SHORTCUT: mv
4
-
5
- DESCRIPTION
6
- Move an object to a new parent.
7
-
8
- SYNTAX
9
- move <path.to.object> to <new.parent>
10
-
11
- PARAMETERS
12
- path.to.object - The object that we want to move.
13
- new.parent - The new location for the object.
14
-
15
- RESULT
16
- The object will now be in the new location.
17
-
18
- ERRORS
19
- Object to move was not specified
20
- - The <path.to.object> is not specified.
21
-
22
- Could not find object to move
23
- - The <path.to.object> cannot be resolved.
24
-
25
- Move' must include 'to' parent object
26
- - The 'to' keyword is missing.
27
- - The <new.parent> is not specified.
28
-
29
- Could not resolve target
30
- - The <new.parent> cannot be resolved.
31
-
32
- EXAMPLE
33
-
34
- can [can] :
35
- two [string] : def
36
- data [can] :
37
- one [string] : abc
38
- on_load [script] :
39
- move can.two to can.data
40
-
41
- SEE ALSO
42
- create
@@ -1,38 +0,0 @@
1
- PUT VERB
2
- NAME: put
3
- SHORTCUT: p
4
-
5
- DESCRIPTION
6
- Put a value into an object.
7
- The value is the result of an expression.
8
-
9
- SYNTAX
10
- put <expression> into <dst.path>
11
-
12
- PARAMETERS
13
- expression - The expression that is evaluated.
14
- dst.path - The path to the destination object.
15
-
16
- RESULT
17
- <it> will contain the result of the evaluation.
18
-
19
- ERRORS
20
- Missing Expression
21
- - The 'into' keyword is missing.
22
- - No source expression is provided.
23
-
24
- Target (into) missing
25
- - The destination is not specified.
26
-
27
- Target could not be resolved
28
- - The destination of the put cannot be resolved.
29
-
30
- EXAMPLE
31
-
32
- > put 'one' into str
33
- > put "two" into str
34
- > put 123 into x
35
- > put 3 + 5 into x
36
- > put TRUE into flag
37
-
38
- SEE ALSO
@@ -1,25 +0,0 @@
1
- QUIT VERB
2
- NAME: quit
3
- SHORTCUT: q
4
-
5
- DESCRIPTION
6
- Stop running the gloo application.
7
- Cleanup and shutdown.
8
-
9
- SYNTAX
10
- quit
11
-
12
- PARAMETERS
13
- None
14
-
15
- RESULT
16
- None
17
-
18
- ERRORS
19
- None
20
-
21
- EXAMPLE
22
-
23
- > quit
24
-
25
- SEE ALSO
@@ -1,41 +0,0 @@
1
- RUN VERB
2
- NAME: run
3
- SHORTCUT: r
4
-
5
- DESCRIPTION
6
- Run a script or other object.
7
- This is the same as sending a 'run' message to the object.
8
-
9
- SYNTAX
10
- run <path.to.object>
11
- run ~> <expression>
12
-
13
- PARAMETERS
14
- path.to.object
15
- - Reference to the object which will be run.
16
- - The object must be a runnable object such as a script.
17
-
18
- expression
19
- - Evaluate the expression and run it.
20
-
21
-
22
- RESULT
23
- The result depends on the object that is run.
24
-
25
- ERRORS
26
- Missing Expression!
27
- - No expression is provided as parameter to the verb.
28
-
29
- EXAMPLE
30
-
31
- > run my.script
32
-
33
- > create s as script : "show 3 + 4"
34
- > run s
35
-
36
- Run a script in an evaluated expression:
37
- > create s as string : "show 3 + 4"
38
- > run ~> s
39
-
40
- SEE ALSO
41
- tell
@@ -1,26 +0,0 @@
1
- SAVE VERB
2
- NAME: save
3
- SHORTCUT: >
4
-
5
- DESCRIPTION
6
- Save a previously loaded object to .gloo file. The path will be for the
7
- root level object that was loaded earlier.
8
-
9
- SYNTAX
10
- save <path.to.object>
11
-
12
- PARAMETERS
13
- path.to.object - Name of the object file that is to be saved.
14
-
15
- RESULT
16
- The file is updated with the latest object state.
17
-
18
- ERRORS
19
- None
20
-
21
- EXAMPLE
22
-
23
- > save my_obj
24
-
25
- SEE ALSO
26
- load
@@ -1,30 +0,0 @@
1
- SHOW VERB
2
- NAME: show
3
- SHORTCUT: =
4
-
5
- DESCRIPTION
6
- Show an object's value.
7
-
8
- SYNTAX
9
- show <path.to.object>
10
-
11
- PARAMETERS
12
- path.to.object - The object that we want to see.
13
-
14
- RESULT
15
- The object's value is shown.
16
- <it> will contain the object's value.
17
-
18
- ERRORS
19
- None
20
-
21
- EXAMPLE
22
-
23
- > show "me"
24
- > show "hello " "world"
25
- > show 132 * 23
26
-
27
- > create x : "boo"
28
- > show x
29
-
30
- SEE ALSO
@@ -1,34 +0,0 @@
1
- TELL VERB
2
- NAME: tell
3
- SHORTCUT: ->
4
-
5
- DESCRIPTION
6
- Send a message to an object.
7
- Ask the object to perform an action.
8
-
9
- SYNTAX
10
- tell <path.to.object> to <message>
11
-
12
- PARAMETERS
13
- path.to.object - The object that we want to see.
14
- message - The message to send.
15
-
16
- RESULT
17
- The result depends on the message that is sent.
18
-
19
- ERRORS
20
- Missing message!
21
- - No message was specified, or the 'to' keyword is missing.
22
-
23
- Object was not found
24
- - The target of the message was not found.
25
-
26
- EXAMPLE
27
-
28
- > tell an.obj to unload
29
- > tell the.script to run
30
- > tell my.str to up
31
- > tell the.container to count
32
-
33
- SEE ALSO
34
- run
@@ -1,38 +0,0 @@
1
- UNLESS VERB
2
- NAME: unless
3
- SHORTCUT: if!
4
-
5
- DESCRIPTION
6
- Unless an expression is true, do something.
7
- This is the opposite of the if verb.
8
-
9
- SYNTAX
10
- unless <true> do <command>
11
-
12
- PARAMETERS
13
- true - Does the expression evaluate to true?
14
- command - Execute command if the expression is not true.
15
-
16
- RESULT
17
- Unchanged if the expression is true.
18
- If not true, then the result will be based on the command
19
- specified after the 'do' keyword.
20
-
21
- ERRORS
22
- Missing Expression!
23
- - No expression is provided as parameter to the verb.
24
-
25
- Other errors depend on the command that is run.
26
-
27
- EXAMPLE
28
-
29
- unless [container] :
30
- x [bool] : true
31
- false_msg [string] : It is NOT true!
32
- on_load [script] :
33
- unless unless.x do show "first time: " + unless.false_msg
34
- put false into unless.x
35
- unless unless.x do show "second time: " + unless.false_msg
36
-
37
- SEE ALSO
38
- if
@@ -1,32 +0,0 @@
1
- VERSION VERB
2
- NAME: version
3
- SHORTCUT: v
4
-
5
- DESCRIPTION
6
- Show the application version information.
7
-
8
- This is the same as showing the version by running gloo
9
- with the --version command line parameter.
10
-
11
- SYNTAX
12
- version
13
-
14
- PARAMETERS
15
- None
16
-
17
- RESULT
18
- None
19
-
20
- ERRORS
21
- None
22
-
23
- EXAMPLE
24
-
25
- > version
26
- > v
27
-
28
- This is the same as running this from the command line:
29
-
30
- > gloo --version
31
-
32
- SEE ALSO
@@ -1,29 +0,0 @@
1
- WAIT VERB
2
- NAME: wait
3
- SHORTCUT: w
4
-
5
- DESCRIPTION
6
- Wait for the given number of seconds.
7
-
8
- SYNTAX
9
- wait <seconds>
10
-
11
- PARAMETERS
12
- seconds - The number of seconds.
13
- If no value is given, we'll wait for 1 second.
14
-
15
- RESULT
16
- None
17
-
18
- ERRORS
19
- None
20
-
21
- EXAMPLE
22
-
23
- > wait
24
- > wait 3
25
-
26
- > create x as int : 10
27
- > wait x
28
-
29
- SEE ALSO
@@ -1,78 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A String.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Alias < Gloo::Core::Obj
10
-
11
- KEYWORD = 'alias'.freeze
12
- KEYWORD_SHORT = 'ln'.freeze
13
- ALIAS_REFERENCE = '*'.freeze
14
-
15
- #
16
- # The name of the object type.
17
- #
18
- def self.typename
19
- return KEYWORD
20
- end
21
-
22
- #
23
- # The short name of the object type.
24
- #
25
- def self.short_typename
26
- return KEYWORD_SHORT
27
- end
28
-
29
- #
30
- # Set the value with any necessary type conversions.
31
- #
32
- def set_value( new_value )
33
- self.value = new_value.to_s
34
- end
35
-
36
- # ---------------------------------------------------------------------
37
- # Messages
38
- # ---------------------------------------------------------------------
39
-
40
- #
41
- # Get a list of message names that this object receives.
42
- #
43
- def self.messages
44
- return super + %w[resolve]
45
- end
46
-
47
- #
48
- # Check to see if the referenced object exists.
49
- #
50
- def msg_resolve
51
- pn = Gloo::Core::Pn.new( self.value )
52
- s = pn.exists?
53
- $engine.heap.it.set_to s
54
- return s
55
- end
56
-
57
- # ---------------------------------------------------------------------
58
- # Resolve
59
- # ---------------------------------------------------------------------
60
-
61
- #
62
- # Is the object an alias If so, then resolve it.
63
- # The ref_name is the name used to refer to the object.
64
- # If it ends with the * then we won't resolve the alias since
65
- # we are trying to refer to the alias itself.
66
- #
67
- def self.resolve_alias( obj, ref_name = nil )
68
- return nil unless obj
69
- return obj unless obj.type_display == Gloo::Objs::Alias.typename
70
- return obj if ref_name&.end_with?( ALIAS_REFERENCE )
71
-
72
- ln = Gloo::Core::Pn.new( obj.value )
73
- return ln.resolve
74
- end
75
-
76
- end
77
- end
78
- end
@@ -1,120 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An object with an boolean value.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Boolean < Gloo::Core::Obj
10
-
11
- KEYWORD = 'boolean'.freeze
12
- KEYWORD_SHORT = 'bool'.freeze
13
- TRUE = 'true'.freeze
14
- FALSE = 'false'.freeze
15
-
16
- #
17
- # The name of the object type.
18
- #
19
- def self.typename
20
- return KEYWORD
21
- end
22
-
23
- #
24
- # The short name of the object type.
25
- #
26
- def self.short_typename
27
- return KEYWORD_SHORT
28
- end
29
-
30
- #
31
- # Set the value with any necessary type conversions.
32
- #
33
- def set_value( new_value )
34
- self.value = Gloo::Objs::Boolean.coerse_to_bool( new_value )
35
- end
36
-
37
- #
38
- # Coerse the new value to a boolean value.
39
- #
40
- def self.coerse_to_bool( new_value )
41
- return false if new_value.nil?
42
-
43
- # I should be able to use this:
44
- # if new_value.kind_of?( String )
45
- # but it doesn't work. I don't know why.
46
- if new_value.class.name == 'String'
47
- return true if new_value.strip.downcase == TRUE
48
- return false if new_value.strip.downcase == FALSE
49
- return true if new_value.strip.downcase == 't'
50
- return false if new_value.strip.downcase == 'f'
51
- elsif new_value.class.name == 'Integer'
52
- return new_value.zero? ? false : true
53
- end
54
-
55
- return new_value == true
56
- end
57
-
58
- #
59
- # Is the given token a boolean?
60
- #
61
- def self.boolean?( token )
62
- return true if token == true
63
- return true if token == false
64
-
65
- if token.class.name == 'String'
66
- return true if token.strip.downcase == TRUE
67
- return true if token.strip.downcase == FALSE
68
- end
69
- return false
70
- end
71
-
72
- #
73
- # Get the value for display purposes.
74
- #
75
- def value_display
76
- return value ? TRUE : FALSE
77
- end
78
-
79
- # ---------------------------------------------------------------------
80
- # Messages
81
- # ---------------------------------------------------------------------
82
-
83
- #
84
- # Get a list of message names that this object receives.
85
- #
86
- def self.messages
87
- return super + %w[not true false]
88
- end
89
-
90
- #
91
- # Set the value to the opposite of what it is.
92
- #
93
- def msg_not
94
- v = !value
95
- set_value v
96
- $engine.heap.it.set_to v
97
- return v
98
- end
99
-
100
- #
101
- # Set the value to true.
102
- #
103
- def msg_true
104
- set_value true
105
- $engine.heap.it.set_to true
106
- return true
107
- end
108
-
109
- #
110
- # Set the value to false.
111
- #
112
- def msg_false
113
- set_value false
114
- $engine.heap.it.set_to false
115
- return false
116
- end
117
-
118
- end
119
- end
120
- end
@@ -1,76 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # An object that contains a collection of other objects.
5
- #
6
- require 'tty-table'
7
- require 'pastel'
8
-
9
- module Gloo
10
- module Objs
11
- class Container < Gloo::Core::Obj
12
-
13
- KEYWORD = 'container'.freeze
14
- KEYWORD_SHORT = 'can'.freeze
15
-
16
- #
17
- # The name of the object type.
18
- #
19
- def self.typename
20
- return KEYWORD
21
- end
22
-
23
- #
24
- # The short name of the object type.
25
- #
26
- def self.short_typename
27
- return KEYWORD_SHORT
28
- end
29
-
30
- # ---------------------------------------------------------------------
31
- # Messages
32
- # ---------------------------------------------------------------------
33
-
34
- #
35
- # Get a list of message names that this object receives.
36
- #
37
- def self.messages
38
- return super + %w[count delete_children show_key_value_table]
39
- end
40
-
41
- #
42
- # Count the number of children in the container.
43
- #
44
- def msg_count
45
- i = child_count
46
- $engine.heap.it.set_to i
47
- return i
48
- end
49
-
50
- #
51
- # Delete all children in the container.
52
- #
53
- def msg_delete_children
54
- self.delete_children
55
- end
56
-
57
- #
58
- # Show the given table data.
59
- #
60
- def msg_show_key_value_table
61
- data = self.children.map { |o| [ o.name, o.value ] }
62
- pastel = ::Pastel.new
63
- table = TTY::Table.new rows: data
64
- pad = [ 0, 1, 0, 1 ]
65
- rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
66
- r.border.style = :blue
67
- r.filter = proc do |val, _row_index, col_index|
68
- col_index.zero? ? pastel.blue( val ) : pastel.white( val )
69
- end
70
- end
71
- puts "\n #{rendered}\n\n"
72
- end
73
-
74
- end
75
- end
76
- end
@@ -1,76 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # An object with a decimal value.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Decimal < Gloo::Core::Obj
10
-
11
- KEYWORD = 'decimal'.freeze
12
- KEYWORD_SHORT = 'num'.freeze
13
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- #
29
- # Set the value with any necessary type conversions.
30
- #
31
- def set_value( new_value )
32
- if new_value.nil?
33
- self.value = 0.0
34
- return
35
- end
36
-
37
- unless new_value.is_a? Numeric
38
- self.value = $engine.converter.convert( new_value, 'Decimal', 0.0 )
39
- return
40
- end
41
-
42
- self.value = new_value.to_f
43
- end
44
-
45
- # ---------------------------------------------------------------------
46
- # Messages
47
- # ---------------------------------------------------------------------
48
-
49
- #
50
- # Get a list of message names that this object receives.
51
- #
52
- def self.messages
53
- return super + %w[round]
54
- end
55
-
56
- #
57
- # Round the value to a whole value.
58
- # If a parameter is included in the message,
59
- # round to the precision given.
60
- #
61
- def msg_round
62
- data = 0
63
- if @params&.token_count&.positive?
64
- expr = Gloo::Expr::Expression.new( @params.tokens )
65
- data = expr.evaluate.to_i
66
- end
67
-
68
- i = self.value.round( data )
69
- set_value i
70
- $engine.heap.it.set_to i
71
- return i
72
- end
73
-
74
- end
75
- end
76
- end