gloo 0.6.1 → 0.7.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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/gloo/app/args.rb +48 -6
  4. data/lib/gloo/app/engine.rb +58 -39
  5. data/lib/gloo/app/help.rb +126 -25
  6. data/lib/gloo/app/info.rb +3 -1
  7. data/lib/gloo/app/log.rb +23 -0
  8. data/lib/gloo/app/mode.rb +2 -0
  9. data/lib/gloo/app/settings.rb +75 -68
  10. data/lib/gloo/convert/converter.rb +35 -0
  11. data/lib/gloo/convert/string_to_datetime.rb +1 -1
  12. data/lib/gloo/convert/string_to_decimal.rb +1 -1
  13. data/lib/gloo/convert/string_to_integer.rb +1 -1
  14. data/lib/gloo/core/dictionary.rb +99 -22
  15. data/lib/gloo/core/error.rb +19 -8
  16. data/lib/gloo/core/event_manager.rb +4 -0
  17. data/lib/gloo/core/factory.rb +11 -0
  18. data/lib/gloo/core/gloo_system.rb +1 -1
  19. data/lib/gloo/core/heap.rb +11 -3
  20. data/lib/gloo/core/it.rb +6 -0
  21. data/lib/gloo/core/literal.rb +5 -0
  22. data/lib/gloo/core/obj.rb +14 -0
  23. data/lib/gloo/core/op.rb +7 -0
  24. data/lib/gloo/core/parser.rb +6 -0
  25. data/lib/gloo/core/pn.rb +36 -0
  26. data/lib/gloo/core/tokens.rb +66 -22
  27. data/lib/gloo/core/verb.rb +4 -0
  28. data/lib/gloo/exec/exec_env.rb +13 -1
  29. data/lib/gloo/expr/expression.rb +26 -4
  30. data/lib/gloo/expr/l_boolean.rb +6 -0
  31. data/lib/gloo/expr/l_decimal.rb +5 -0
  32. data/lib/gloo/expr/l_integer.rb +7 -0
  33. data/lib/gloo/expr/l_string.rb +7 -0
  34. data/lib/gloo/expr/op_div.rb +2 -0
  35. data/lib/gloo/expr/op_minus.rb +2 -0
  36. data/lib/gloo/expr/op_mult.rb +2 -0
  37. data/lib/gloo/expr/op_plus.rb +2 -0
  38. data/lib/gloo/help/app/application.txt +22 -0
  39. data/lib/gloo/help/app/configuration.txt +7 -0
  40. data/lib/gloo/help/app/default_help.txt +14 -0
  41. data/lib/gloo/help/app/logging.txt +16 -0
  42. data/lib/gloo/help/core/color.txt +31 -0
  43. data/lib/gloo/help/core/error.txt +33 -0
  44. data/lib/gloo/help/core/events.txt +21 -0
  45. data/lib/gloo/help/core/gloo_system.txt +54 -0
  46. data/lib/gloo/help/core/here.txt +30 -0
  47. data/lib/gloo/help/core/it.txt +23 -0
  48. data/lib/gloo/help/core/ops.txt +16 -0
  49. data/lib/gloo/help/core/pathname.txt +29 -0
  50. data/lib/gloo/help/objs/basic/alias.txt +36 -0
  51. data/lib/gloo/help/objs/basic/boolean.txt +28 -0
  52. data/lib/gloo/help/objs/basic/container.txt +33 -0
  53. data/lib/gloo/help/objs/basic/decimal.txt +28 -0
  54. data/lib/gloo/help/objs/basic/integer.txt +27 -0
  55. data/lib/gloo/help/objs/basic/script.txt +29 -0
  56. data/lib/gloo/help/objs/basic/string.txt +28 -0
  57. data/lib/gloo/help/objs/basic/text.txt +27 -0
  58. data/lib/gloo/help/objs/basic/untyped.txt +22 -0
  59. data/lib/gloo/help/objs/cli/banner.txt +49 -0
  60. data/lib/gloo/help/objs/cli/bar.txt +34 -0
  61. data/lib/gloo/help/objs/cli/colorize.txt +33 -0
  62. data/lib/gloo/help/objs/cli/confirm.txt +26 -0
  63. data/lib/gloo/help/objs/cli/menu.txt +44 -0
  64. data/lib/gloo/help/objs/cli/menu_item.txt +26 -0
  65. data/lib/gloo/help/objs/cli/pastel.txt +43 -0
  66. data/lib/gloo/help/objs/cli/prompt.txt +27 -0
  67. data/lib/gloo/help/objs/cli/select.txt +34 -0
  68. data/lib/gloo/help/objs/ctrl/each.txt +48 -0
  69. data/lib/gloo/help/objs/ctrl/repeat.txt +38 -0
  70. data/lib/gloo/help/objs/data/markdown.txt +25 -0
  71. data/lib/gloo/help/objs/data/table.txt +46 -0
  72. data/lib/gloo/help/objs/dev/git_repo.txt +35 -0
  73. data/lib/gloo/help/objs/dt/date.txt +23 -0
  74. data/lib/gloo/help/objs/dt/datetime.txt +24 -0
  75. data/lib/gloo/help/objs/dt/time.txt +23 -0
  76. data/lib/gloo/help/objs/ror/erb.txt +37 -0
  77. data/lib/gloo/help/objs/ror/eval.txt +24 -0
  78. data/lib/gloo/help/objs/snd/play.txt +23 -0
  79. data/lib/gloo/help/objs/snd/say.txt +28 -0
  80. data/lib/gloo/help/objs/system/file.txt +41 -0
  81. data/lib/gloo/help/objs/system/system.txt +32 -0
  82. data/lib/gloo/help/objs/web/http_get.txt +35 -0
  83. data/lib/gloo/help/objs/web/http_post.txt +32 -0
  84. data/lib/gloo/help/objs/web/json.txt +34 -0
  85. data/lib/gloo/help/objs/web/slack.txt +33 -0
  86. data/lib/gloo/help/objs/web/teams.txt +30 -0
  87. data/lib/gloo/help/objs/web/uri.txt +37 -0
  88. data/lib/gloo/help/verbs/alert.txt +33 -0
  89. data/lib/gloo/help/verbs/beep.txt +25 -0
  90. data/lib/gloo/help/verbs/cls.txt +24 -0
  91. data/lib/gloo/help/verbs/context.txt +43 -0
  92. data/lib/gloo/help/verbs/create.txt +33 -0
  93. data/lib/gloo/help/verbs/help.txt +34 -0
  94. data/lib/gloo/help/verbs/if.txt +37 -0
  95. data/lib/gloo/help/verbs/list.txt +34 -0
  96. data/lib/gloo/help/verbs/load.txt +38 -0
  97. data/lib/gloo/help/verbs/move.txt +42 -0
  98. data/lib/gloo/help/verbs/put.txt +38 -0
  99. data/lib/gloo/help/verbs/quit.txt +25 -0
  100. data/lib/gloo/help/verbs/run.txt +41 -0
  101. data/lib/gloo/help/verbs/save.txt +26 -0
  102. data/lib/gloo/help/verbs/show.txt +30 -0
  103. data/lib/gloo/help/verbs/tell.txt +34 -0
  104. data/lib/gloo/help/verbs/unless.txt +38 -0
  105. data/lib/gloo/help/verbs/version.txt +32 -0
  106. data/lib/gloo/help/verbs/wait.txt +29 -0
  107. data/lib/gloo/objs/basic/alias.rb +0 -33
  108. data/lib/gloo/objs/basic/boolean.rb +6 -27
  109. data/lib/gloo/objs/basic/container.rb +0 -33
  110. data/lib/gloo/objs/basic/decimal.rb +8 -28
  111. data/lib/gloo/objs/basic/integer.rb +5 -26
  112. data/lib/gloo/objs/basic/script.rb +0 -26
  113. data/lib/gloo/objs/basic/string.rb +6 -26
  114. data/lib/gloo/objs/basic/text.rb +0 -25
  115. data/lib/gloo/objs/basic/untyped.rb +0 -26
  116. data/lib/gloo/objs/cli/banner.rb +0 -29
  117. data/lib/gloo/objs/cli/bar.rb +0 -29
  118. data/lib/gloo/objs/cli/colorize.rb +4 -34
  119. data/lib/gloo/objs/cli/confirm.rb +6 -36
  120. data/lib/gloo/objs/cli/menu.rb +4 -34
  121. data/lib/gloo/objs/cli/menu_item.rb +0 -33
  122. data/lib/gloo/objs/cli/pastel.rb +4 -27
  123. data/lib/gloo/objs/cli/prompt.rb +4 -28
  124. data/lib/gloo/objs/cli/select.rb +4 -31
  125. data/lib/gloo/objs/ctrl/each.rb +33 -33
  126. data/lib/gloo/objs/ctrl/repeat.rb +8 -29
  127. data/lib/gloo/objs/data/markdown.rb +0 -25
  128. data/lib/gloo/objs/data/table.rb +4 -32
  129. data/lib/gloo/objs/dev/git.rb +12 -30
  130. data/lib/gloo/objs/dt/date.rb +3 -25
  131. data/lib/gloo/objs/dt/datetime.rb +4 -26
  132. data/lib/gloo/objs/dt/time.rb +3 -25
  133. data/lib/gloo/objs/ror/erb.rb +11 -45
  134. data/lib/gloo/objs/ror/eval.rb +11 -38
  135. data/lib/gloo/objs/snd/play.rb +2 -25
  136. data/lib/gloo/objs/snd/say.rb +9 -31
  137. data/lib/gloo/objs/system/file_handle.rb +0 -38
  138. data/lib/gloo/objs/system/system.rb +16 -46
  139. data/lib/gloo/objs/web/http_get.rb +57 -83
  140. data/lib/gloo/objs/web/http_post.rb +8 -31
  141. data/lib/gloo/objs/web/json.rb +11 -31
  142. data/lib/gloo/objs/web/slack.rb +7 -34
  143. data/lib/gloo/objs/web/teams.rb +13 -48
  144. data/lib/gloo/objs/web/uri.rb +0 -29
  145. data/lib/gloo/persist/file_loader.rb +8 -0
  146. data/lib/gloo/persist/file_saver.rb +6 -0
  147. data/lib/gloo/persist/file_storage.rb +2 -0
  148. data/lib/gloo/persist/line_splitter.rb +2 -0
  149. data/lib/gloo/persist/persist_man.rb +6 -0
  150. data/lib/gloo/verbs/alert.rb +30 -44
  151. data/lib/gloo/verbs/beep.rb +0 -30
  152. data/lib/gloo/verbs/cls.rb +0 -30
  153. data/lib/gloo/verbs/context.rb +9 -39
  154. data/lib/gloo/verbs/create.rb +17 -32
  155. data/lib/gloo/verbs/help.rb +151 -115
  156. data/lib/gloo/verbs/if.rb +46 -44
  157. data/lib/gloo/verbs/list.rb +36 -54
  158. data/lib/gloo/verbs/load.rb +8 -37
  159. data/lib/gloo/verbs/move.rb +12 -51
  160. data/lib/gloo/verbs/put.rb +28 -52
  161. data/lib/gloo/verbs/quit.rb +0 -31
  162. data/lib/gloo/verbs/run.rb +23 -39
  163. data/lib/gloo/verbs/save.rb +0 -33
  164. data/lib/gloo/verbs/show.rb +6 -31
  165. data/lib/gloo/verbs/tell.rb +31 -31
  166. data/lib/gloo/verbs/unless.rb +47 -46
  167. data/lib/gloo/verbs/version.rb +0 -30
  168. data/lib/gloo/verbs/wait.rb +0 -31
  169. metadata +72 -3
  170. data/lib/gloo/help/help.md +0 -16
@@ -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
@@ -94,32 +94,6 @@ module Gloo
94
94
  s.run
95
95
  end
96
96
 
97
- # ---------------------------------------------------------------------
98
- # Help
99
- # ---------------------------------------------------------------------
100
-
101
- #
102
- # Get help for this object type.
103
- #
104
- def self.help
105
- return <<~TEXT
106
- SCRIPT OBJECT TYPE
107
- NAME: script
108
- SHORTCUT: cmd
109
-
110
- DESCRIPTION
111
- An exectutable script.
112
-
113
- CHILDREN
114
- None
115
-
116
- MESSAGES
117
- run - Run the script.
118
- The script can be run by telling the object or run.
119
- It can all be executed with the run verb.
120
- TEXT
121
- end
122
-
123
97
  end
124
98
  end
125
99
  end
@@ -43,14 +43,18 @@ module Gloo
43
43
  return super + %w[up down size]
44
44
  end
45
45
 
46
+ #
46
47
  # Get the size of the string.
48
+ #
47
49
  def msg_size
48
50
  s = value.size
49
51
  $engine.heap.it.set_to s
50
52
  return s
51
53
  end
52
54
 
55
+ #
53
56
  # Convert string to upper case
57
+ #
54
58
  def msg_up
55
59
  s = value.upcase
56
60
  set_value s
@@ -58,7 +62,9 @@ module Gloo
58
62
  return s
59
63
  end
60
64
 
65
+ #
61
66
  # Convert string to lower case
67
+ #
62
68
  def msg_down
63
69
  s = value.downcase
64
70
  set_value s
@@ -66,32 +72,6 @@ module Gloo
66
72
  return s
67
73
  end
68
74
 
69
- # ---------------------------------------------------------------------
70
- # Help
71
- # ---------------------------------------------------------------------
72
-
73
- #
74
- # Get help for this object type.
75
- #
76
- def self.help
77
- return <<~TEXT
78
- STRING OBJECT TYPE
79
- NAME: string
80
- SHORTCUT: str
81
-
82
- DESCRIPTION
83
- A string value.
84
-
85
- CHILDREN
86
- None
87
-
88
- MESSAGES
89
- up - Convert the string to uppercase.
90
- down - Convert the string to lowercase.
91
- size - Get the size of the string.
92
- TEXT
93
- end
94
-
95
75
  end
96
76
  end
97
77
  end
@@ -82,31 +82,6 @@ module Gloo
82
82
  set_value File.read( tmp )
83
83
  end
84
84
 
85
- # ---------------------------------------------------------------------
86
- # Help
87
- # ---------------------------------------------------------------------
88
-
89
- #
90
- # Get help for this object type.
91
- #
92
- def self.help
93
- return <<~TEXT
94
- TEXT OBJECT TYPE
95
- NAME: text
96
- SHORTCUT: txt
97
-
98
- DESCRIPTION
99
- A longer, multi-line text string.
100
-
101
- CHILDREN
102
- None
103
-
104
- MESSAGES
105
- edit - Edit the text field in the default editor.
106
- page - Show the text, paginated.
107
- TEXT
108
- end
109
-
110
85
  end
111
86
  end
112
87
  end
@@ -36,32 +36,6 @@ module Gloo
36
36
  return super # + [ "run" ]
37
37
  end
38
38
 
39
- # ---------------------------------------------------------------------
40
- # Help
41
- # ---------------------------------------------------------------------
42
-
43
- #
44
- # Get help for this object type.
45
- #
46
- def self.help
47
- return <<~TEXT
48
- UNTYPED OBJECT TYPE
49
- NAME: untyped
50
- SHORTCUT: un
51
-
52
- DESCRIPTION
53
- An untyped object.
54
- If no type is specified when an object is created it
55
- will be of this type.
56
-
57
- CHILDREN
58
- None
59
-
60
- MESSAGES
61
- None
62
- TEXT
63
- end
64
-
65
39
  end
66
40
  end
67
41
  end
@@ -103,35 +103,6 @@ module Gloo
103
103
  puts pastel.decorate( t, *c )
104
104
  end
105
105
 
106
- # ---------------------------------------------------------------------
107
- # Help
108
- # ---------------------------------------------------------------------
109
-
110
- #
111
- # Get help for this object type.
112
- #
113
- def self.help
114
- return <<~TEXT
115
- BANNER OBJECT TYPE
116
- NAME: banner
117
- SHORTCUT: ban
118
-
119
- DESCRIPTION
120
- Banner text in large, colored font.
121
-
122
- CHILDREN
123
- text - string
124
- The text for the banner.
125
- style - string
126
- The banner style. See tty-font for options.
127
- color - string
128
- The color for the banner. See pastel for options.
129
-
130
- MESSAGES
131
- show - Show the text banner.
132
- TEXT
133
- end
134
-
135
106
  end
136
107
  end
137
108
  end
@@ -107,35 +107,6 @@ module Gloo
107
107
  @bar.advance x
108
108
  end
109
109
 
110
- # ---------------------------------------------------------------------
111
- # Help
112
- # ---------------------------------------------------------------------
113
-
114
- #
115
- # Get help for this object type.
116
- #
117
- def self.help
118
- return <<~TEXT
119
- BAR OBJECT TYPE
120
- NAME: bar
121
- SHORTCUT: bar
122
-
123
- DESCRIPTION
124
- CLI progress bar
125
-
126
- CHILDREN
127
- name - string
128
- The name of the progress bar.
129
- total - integer - 100
130
- The total for the bar.
131
-
132
- MESSAGES
133
- start - Start the bar.
134
- advance <amount> - Advance by the given amount.
135
- stop - Complete the bar.
136
- TEXT
137
- end
138
-
139
110
  end
140
111
  end
141
112
  end