gloo 0.5.4 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/gloo/app/args.rb +48 -6
  5. data/lib/gloo/app/engine.rb +60 -38
  6. data/lib/gloo/app/help.rb +137 -16
  7. data/lib/gloo/app/info.rb +3 -1
  8. data/lib/gloo/app/log.rb +23 -0
  9. data/lib/gloo/app/mode.rb +2 -0
  10. data/lib/gloo/app/settings.rb +98 -47
  11. data/lib/gloo/convert/converter.rb +35 -0
  12. data/lib/gloo/convert/string_to_datetime.rb +1 -1
  13. data/lib/gloo/convert/string_to_decimal.rb +1 -1
  14. data/lib/gloo/convert/string_to_integer.rb +1 -1
  15. data/lib/gloo/core/dictionary.rb +99 -22
  16. data/lib/gloo/core/error.rb +19 -8
  17. data/lib/gloo/core/event_manager.rb +4 -0
  18. data/lib/gloo/core/factory.rb +11 -0
  19. data/lib/gloo/core/gloo_system.rb +1 -1
  20. data/lib/gloo/core/heap.rb +11 -3
  21. data/lib/gloo/core/here.rb +36 -0
  22. data/lib/gloo/core/it.rb +6 -0
  23. data/lib/gloo/core/literal.rb +5 -0
  24. data/lib/gloo/core/obj.rb +22 -0
  25. data/lib/gloo/core/op.rb +7 -0
  26. data/lib/gloo/core/parser.rb +6 -0
  27. data/lib/gloo/core/pn.rb +38 -0
  28. data/lib/gloo/core/tokens.rb +66 -22
  29. data/lib/gloo/core/verb.rb +12 -0
  30. data/lib/gloo/exec/action.rb +48 -0
  31. data/lib/gloo/exec/dispatch.rb +15 -5
  32. data/lib/gloo/exec/exec_env.rb +74 -0
  33. data/lib/gloo/exec/runner.rb +4 -2
  34. data/lib/gloo/{core → exec}/script.rb +21 -9
  35. data/lib/gloo/exec/stack.rb +78 -0
  36. data/lib/gloo/expr/expression.rb +26 -4
  37. data/lib/gloo/expr/l_boolean.rb +6 -0
  38. data/lib/gloo/expr/l_decimal.rb +5 -0
  39. data/lib/gloo/expr/l_integer.rb +7 -0
  40. data/lib/gloo/expr/l_string.rb +7 -0
  41. data/lib/gloo/expr/op_div.rb +2 -0
  42. data/lib/gloo/expr/op_minus.rb +2 -0
  43. data/lib/gloo/expr/op_mult.rb +2 -0
  44. data/lib/gloo/expr/op_plus.rb +2 -0
  45. data/lib/gloo/help/app/application.txt +22 -0
  46. data/lib/gloo/help/app/configuration.txt +7 -0
  47. data/lib/gloo/help/app/default_help.txt +14 -0
  48. data/lib/gloo/help/app/logging.txt +16 -0
  49. data/lib/gloo/help/core/color.txt +31 -0
  50. data/lib/gloo/help/core/error.txt +33 -0
  51. data/lib/gloo/help/core/events.txt +21 -0
  52. data/lib/gloo/help/core/gloo_system.txt +54 -0
  53. data/lib/gloo/help/core/here.txt +30 -0
  54. data/lib/gloo/help/core/it.txt +23 -0
  55. data/lib/gloo/help/core/ops.txt +16 -0
  56. data/lib/gloo/help/core/pathname.txt +29 -0
  57. data/lib/gloo/help/objs/basic/alias.txt +36 -0
  58. data/lib/gloo/help/objs/basic/boolean.txt +28 -0
  59. data/lib/gloo/help/objs/basic/container.txt +33 -0
  60. data/lib/gloo/help/objs/basic/decimal.txt +28 -0
  61. data/lib/gloo/help/objs/basic/integer.txt +27 -0
  62. data/lib/gloo/help/objs/basic/script.txt +29 -0
  63. data/lib/gloo/help/objs/basic/string.txt +28 -0
  64. data/lib/gloo/help/objs/basic/text.txt +27 -0
  65. data/lib/gloo/help/objs/basic/untyped.txt +22 -0
  66. data/lib/gloo/help/objs/cli/banner.txt +49 -0
  67. data/lib/gloo/help/objs/cli/bar.txt +34 -0
  68. data/lib/gloo/help/objs/cli/colorize.txt +33 -0
  69. data/lib/gloo/help/objs/cli/confirm.txt +26 -0
  70. data/lib/gloo/help/objs/cli/menu.txt +44 -0
  71. data/lib/gloo/help/objs/cli/menu_item.txt +26 -0
  72. data/lib/gloo/help/objs/cli/pastel.txt +43 -0
  73. data/lib/gloo/help/objs/cli/prompt.txt +27 -0
  74. data/lib/gloo/help/objs/cli/select.txt +34 -0
  75. data/lib/gloo/help/objs/ctrl/each.txt +48 -0
  76. data/lib/gloo/help/objs/ctrl/repeat.txt +38 -0
  77. data/lib/gloo/help/objs/data/markdown.txt +25 -0
  78. data/lib/gloo/help/objs/data/table.txt +46 -0
  79. data/lib/gloo/help/objs/dev/git_repo.txt +35 -0
  80. data/lib/gloo/help/objs/dt/date.txt +23 -0
  81. data/lib/gloo/help/objs/dt/datetime.txt +24 -0
  82. data/lib/gloo/help/objs/dt/time.txt +23 -0
  83. data/lib/gloo/help/objs/ror/erb.txt +37 -0
  84. data/lib/gloo/help/objs/ror/eval.txt +24 -0
  85. data/lib/gloo/help/objs/snd/play.txt +23 -0
  86. data/lib/gloo/help/objs/snd/say.txt +28 -0
  87. data/lib/gloo/help/objs/system/file.txt +41 -0
  88. data/lib/gloo/help/objs/system/system.txt +32 -0
  89. data/lib/gloo/help/objs/web/http_get.txt +35 -0
  90. data/lib/gloo/help/objs/web/http_post.txt +32 -0
  91. data/lib/gloo/help/objs/web/json.txt +34 -0
  92. data/lib/gloo/help/objs/web/slack.txt +33 -0
  93. data/lib/gloo/help/objs/web/teams.txt +30 -0
  94. data/lib/gloo/help/objs/web/uri.txt +37 -0
  95. data/lib/gloo/help/verbs/alert.txt +33 -0
  96. data/lib/gloo/help/verbs/beep.txt +25 -0
  97. data/lib/gloo/help/verbs/cls.txt +24 -0
  98. data/lib/gloo/help/verbs/context.txt +43 -0
  99. data/lib/gloo/help/verbs/create.txt +33 -0
  100. data/lib/gloo/help/verbs/execute.txt +27 -0
  101. data/lib/gloo/help/verbs/help.txt +34 -0
  102. data/lib/gloo/help/verbs/if.txt +37 -0
  103. data/lib/gloo/help/verbs/list.txt +34 -0
  104. data/lib/gloo/help/verbs/load.txt +38 -0
  105. data/lib/gloo/help/verbs/move.txt +42 -0
  106. data/lib/gloo/help/verbs/put.txt +38 -0
  107. data/lib/gloo/help/verbs/quit.txt +25 -0
  108. data/lib/gloo/help/verbs/run.txt +41 -0
  109. data/lib/gloo/help/verbs/save.txt +26 -0
  110. data/lib/gloo/help/verbs/show.txt +30 -0
  111. data/lib/gloo/help/verbs/tell.txt +34 -0
  112. data/lib/gloo/help/verbs/unless.txt +38 -0
  113. data/lib/gloo/help/verbs/version.txt +32 -0
  114. data/lib/gloo/help/verbs/wait.txt +29 -0
  115. data/lib/gloo/objs/basic/alias.rb +0 -33
  116. data/lib/gloo/objs/basic/boolean.rb +6 -27
  117. data/lib/gloo/objs/basic/container.rb +0 -33
  118. data/lib/gloo/objs/basic/decimal.rb +8 -28
  119. data/lib/gloo/objs/basic/integer.rb +5 -26
  120. data/lib/gloo/objs/basic/script.rb +1 -27
  121. data/lib/gloo/objs/basic/string.rb +6 -26
  122. data/lib/gloo/objs/basic/text.rb +0 -25
  123. data/lib/gloo/objs/basic/untyped.rb +0 -26
  124. data/lib/gloo/objs/cli/banner.rb +0 -29
  125. data/lib/gloo/objs/cli/bar.rb +0 -29
  126. data/lib/gloo/objs/cli/colorize.rb +4 -34
  127. data/lib/gloo/objs/cli/confirm.rb +6 -36
  128. data/lib/gloo/objs/cli/menu.rb +6 -36
  129. data/lib/gloo/objs/cli/menu_item.rb +0 -33
  130. data/lib/gloo/objs/cli/pastel.rb +4 -27
  131. data/lib/gloo/objs/cli/prompt.rb +4 -28
  132. data/lib/gloo/objs/cli/select.rb +4 -31
  133. data/lib/gloo/objs/ctrl/each.rb +33 -33
  134. data/lib/gloo/objs/ctrl/repeat.rb +8 -29
  135. data/lib/gloo/objs/data/markdown.rb +0 -25
  136. data/lib/gloo/objs/data/table.rb +4 -32
  137. data/lib/gloo/objs/dev/git.rb +12 -30
  138. data/lib/gloo/objs/dt/date.rb +3 -25
  139. data/lib/gloo/objs/dt/datetime.rb +4 -26
  140. data/lib/gloo/objs/dt/time.rb +3 -25
  141. data/lib/gloo/objs/ror/erb.rb +11 -45
  142. data/lib/gloo/objs/ror/eval.rb +11 -38
  143. data/lib/gloo/objs/snd/play.rb +2 -25
  144. data/lib/gloo/objs/snd/say.rb +9 -31
  145. data/lib/gloo/objs/system/file_handle.rb +0 -38
  146. data/lib/gloo/objs/system/system.rb +16 -46
  147. data/lib/gloo/objs/web/http_get.rb +57 -83
  148. data/lib/gloo/objs/web/http_post.rb +8 -31
  149. data/lib/gloo/objs/web/json.rb +11 -31
  150. data/lib/gloo/objs/web/slack.rb +7 -34
  151. data/lib/gloo/objs/web/teams.rb +13 -48
  152. data/lib/gloo/objs/web/uri.rb +0 -29
  153. data/lib/gloo/persist/file_loader.rb +8 -0
  154. data/lib/gloo/persist/file_saver.rb +6 -0
  155. data/lib/gloo/persist/file_storage.rb +2 -0
  156. data/lib/gloo/persist/line_splitter.rb +2 -0
  157. data/lib/gloo/persist/persist_man.rb +6 -0
  158. data/lib/gloo/verbs/alert.rb +30 -44
  159. data/lib/gloo/verbs/beep.rb +0 -30
  160. data/lib/gloo/verbs/cls.rb +0 -30
  161. data/lib/gloo/verbs/context.rb +9 -39
  162. data/lib/gloo/verbs/create.rb +17 -32
  163. data/lib/gloo/verbs/execute.rb +52 -0
  164. data/lib/gloo/verbs/help.rb +151 -115
  165. data/lib/gloo/verbs/if.rb +46 -44
  166. data/lib/gloo/verbs/list.rb +36 -54
  167. data/lib/gloo/verbs/load.rb +8 -37
  168. data/lib/gloo/verbs/move.rb +12 -51
  169. data/lib/gloo/verbs/put.rb +28 -52
  170. data/lib/gloo/verbs/quit.rb +0 -31
  171. data/lib/gloo/verbs/run.rb +23 -39
  172. data/lib/gloo/verbs/save.rb +0 -33
  173. data/lib/gloo/verbs/show.rb +6 -31
  174. data/lib/gloo/verbs/tell.rb +31 -31
  175. data/lib/gloo/verbs/unless.rb +47 -46
  176. data/lib/gloo/verbs/version.rb +0 -30
  177. data/lib/gloo/verbs/wait.rb +0 -31
  178. metadata +79 -3
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,38 @@
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
@@ -0,0 +1,32 @@
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
@@ -0,0 +1,29 @@
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
@@ -73,39 +73,6 @@ module Gloo
73
73
  return ln.resolve
74
74
  end
75
75
 
76
- # ---------------------------------------------------------------------
77
- # Help
78
- # ---------------------------------------------------------------------
79
-
80
- #
81
- # Get help for this object type.
82
- #
83
- def self.help
84
- return <<~TEXT
85
- ALIAS OBJECT TYPE
86
- NAME: alias
87
- SHORTCUT: ln
88
-
89
- DESCRIPTION
90
- A pointer to another object.
91
- Normal path-name references will refere to the aliased object.
92
- To refer to the alias itself, add an * at the end of the path-name.
93
- This is neeed, for example, to set the value of the alias.
94
- The value of the alias is merely the path-name of the
95
- referenced object.
96
-
97
- CHILDREN
98
- None
99
-
100
- MESSAGES
101
- The alias will reflect the mesages of the object to which
102
- it points.
103
- The alias itself can receive the following message:
104
- resolve - Check to see if the object referenced exists.
105
- Sets it to true or false.
106
- TEXT
107
- end
108
-
109
76
  end
110
77
  end
111
78
  end
@@ -84,7 +84,9 @@ module Gloo
84
84
  return super + %w[not true false]
85
85
  end
86
86
 
87
+ #
87
88
  # Set the value to the opposite of what it is.
89
+ #
88
90
  def msg_not
89
91
  v = !value
90
92
  set_value v
@@ -92,47 +94,24 @@ module Gloo
92
94
  return v
93
95
  end
94
96
 
97
+ #
95
98
  # Set the value to true.
99
+ #
96
100
  def msg_true
97
101
  set_value true
98
102
  $engine.heap.it.set_to true
99
103
  return true
100
104
  end
101
105
 
106
+ #
102
107
  # Set the value to false.
108
+ #
103
109
  def msg_false
104
110
  set_value false
105
111
  $engine.heap.it.set_to false
106
112
  return false
107
113
  end
108
114
 
109
- # ---------------------------------------------------------------------
110
- # Help
111
- # ---------------------------------------------------------------------
112
-
113
- #
114
- # Get help for this object type.
115
- #
116
- def self.help
117
- return <<~TEXT
118
- BOOLEAN OBJECT TYPE
119
- NAME: boolean
120
- SHORTCUT: bool
121
-
122
- DESCRIPTION
123
- A boolean value.
124
- Value will be either true or false.
125
-
126
- CHILDREN
127
- None
128
-
129
- MESSAGES
130
- not - Set the boolean to the opposite of what it is now.
131
- true - Set the boolean to true.
132
- false - Set the boolean to false.
133
- TEXT
134
- end
135
-
136
115
  end
137
116
  end
138
117
  end
@@ -71,39 +71,6 @@ module Gloo
71
71
  puts "\n #{rendered}\n\n"
72
72
  end
73
73
 
74
- # ---------------------------------------------------------------------
75
- # Help
76
- # ---------------------------------------------------------------------
77
-
78
- #
79
- # Get help for this object type.
80
- #
81
- def self.help
82
- return <<~TEXT
83
- CONTAINER OBJECT TYPE
84
- NAME: container
85
- SHORTCUT: can
86
-
87
- DESCRIPTION
88
- A container of other objects.
89
- A container is similar to a folder in a file system.
90
- It can contain any number of objects including other containers.
91
- The container structure provides direct access to any object
92
- within it through the object.object.object path-name structure.
93
-
94
- CHILDREN
95
- None by default. But any container can have any number of
96
- objects added to it.
97
-
98
- MESSAGES
99
- count - Count the number of children objects in the container.
100
- The result is put in <it>.
101
- delete_children - Delete all children objects from the container.
102
- show_key_value_tbl - Show a table with key (name) and values
103
- for all children in the container.
104
- TEXT
105
- end
106
-
107
74
  end
108
75
  end
109
76
  end
@@ -35,7 +35,7 @@ module Gloo
35
35
  end
36
36
 
37
37
  unless new_value.is_a? Numeric
38
- self.value = $engine.convert( new_value, 'Decimal', 0.0 )
38
+ self.value = $engine.converter.convert( new_value, 'Decimal', 0.0 )
39
39
  return
40
40
  end
41
41
 
@@ -59,38 +59,18 @@ module Gloo
59
59
  # round to the precision given.
60
60
  #
61
61
  def msg_round
62
- i = value + 1
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 )
63
69
  set_value i
64
70
  $engine.heap.it.set_to i
65
71
  return i
66
72
  end
67
73
 
68
- # ---------------------------------------------------------------------
69
- # Help
70
- # ---------------------------------------------------------------------
71
-
72
- #
73
- # Get help for this object type.
74
- #
75
- def self.help
76
- return <<~TEXT
77
- DECIMAL OBJECT TYPE
78
- NAME: decimal
79
- SHORTCUT: num
80
-
81
- DESCRIPTION
82
- A decimal (numeric) value.
83
-
84
- CHILDREN
85
- None
86
-
87
- MESSAGES
88
- round - Round to the nearest whole value.
89
- If an optional parameter is included, round to the
90
- precision specified.
91
- TEXT
92
- end
93
-
94
74
  end
95
75
  end
96
76
  end
@@ -30,7 +30,7 @@ module Gloo
30
30
  #
31
31
  def set_value( new_value )
32
32
  unless new_value.is_a? Numeric
33
- self.value = $engine.convert( new_value, 'Integer', 0 )
33
+ self.value = $engine.converter.convert( new_value, 'Integer', 0 )
34
34
  return
35
35
  end
36
36
 
@@ -48,7 +48,9 @@ module Gloo
48
48
  return super + %w[inc dec]
49
49
  end
50
50
 
51
+ #
51
52
  # Increment the integer
53
+ #
52
54
  def msg_inc
53
55
  i = value + 1
54
56
  set_value i
@@ -56,7 +58,9 @@ module Gloo
56
58
  return i
57
59
  end
58
60
 
61
+ #
59
62
  # Decrement the integer
63
+ #
60
64
  def msg_dec
61
65
  i = value - 1
62
66
  set_value i
@@ -64,31 +68,6 @@ module Gloo
64
68
  return i
65
69
  end
66
70
 
67
- # ---------------------------------------------------------------------
68
- # Help
69
- # ---------------------------------------------------------------------
70
-
71
- #
72
- # Get help for this object type.
73
- #
74
- def self.help
75
- return <<~TEXT
76
- INTEGER OBJECT TYPE
77
- NAME: integer
78
- SHORTCUT: int
79
-
80
- DESCRIPTION
81
- An integer (numeric) value.
82
-
83
- CHILDREN
84
- None
85
-
86
- MESSAGES
87
- inc - Increment the integer value by 1.
88
- dec - Decrement the integer value by 1.
89
- TEXT
90
- end
91
-
92
71
  end
93
72
  end
94
73
  end