gloo 0.8.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/lib/gloo/verbs/if.rb DELETED
@@ -1,92 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # If something is true, do something.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class If < Gloo::Core::Verb
10
-
11
- KEYWORD = 'if'.freeze
12
- KEYWORD_SHORT = 'if'.freeze
13
- THEN = 'then'.freeze
14
- MISSING_EXPR_ERR = 'Missing Expression!'.freeze
15
-
16
- #
17
- # Run the verb.
18
- #
19
- def run
20
- value = value_tokens
21
- return if value.nil?
22
-
23
- return unless evals_true( value )
24
-
25
- run_then
26
- end
27
-
28
- #
29
- # Get the Verb's keyword.
30
- #
31
- def self.keyword
32
- return KEYWORD
33
- end
34
-
35
- #
36
- # Get the Verb's keyword shortcut.
37
- #
38
- def self.keyword_shortcut
39
- return KEYWORD_SHORT
40
- end
41
-
42
- # ---------------------------------------------------------------------
43
- # Private functions
44
- # ---------------------------------------------------------------------
45
-
46
- private
47
-
48
- #
49
- # Get the list of tokens that represent the parameters
50
- # of the if command.
51
- #
52
- def value_tokens
53
- value = @tokens.before_token( THEN )
54
- if value && value.count > 1
55
- # The first token is the verb, so we drop it.
56
- value = value[ 1..-1 ]
57
- else
58
- $engine.err MISSING_EXPR_ERR
59
- end
60
-
61
- return value
62
- end
63
-
64
- #
65
- # Does the given value evalute to true?
66
- #
67
- def evals_true( value )
68
- eval_result = false
69
- if value.count.positive?
70
- expr = Gloo::Expr::Expression.new( value )
71
- result = expr.evaluate
72
- eval_result = true if result == true
73
- eval_result = true if result.is_a?( Numeric ) && result != 0
74
- end
75
-
76
- return eval_result
77
- end
78
-
79
- #
80
- # Run the 'then' command.
81
- #
82
- def run_then
83
- cmd = @tokens.expr_after( THEN )
84
- i = $engine.parser.parse_immediate cmd
85
- return unless i
86
-
87
- i.run
88
- end
89
-
90
- end
91
- end
92
- end
@@ -1,98 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # List out an object and it's children.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class List < Gloo::Core::Verb
10
-
11
- KEYWORD = 'list'.freeze
12
- KEYWORD_SHORT = '.'.freeze
13
- TARGET_MISSING_ERR = 'Object does not exist: '.freeze
14
-
15
- #
16
- # Run the verb.
17
- #
18
- def run
19
- levels = determine_levels
20
- target = self.determine_target
21
- obj = target.resolve
22
- if obj
23
- show_target( obj, levels )
24
- else
25
- $engine.err "#{TARGET_MISSING_ERR} #{target}"
26
- end
27
- end
28
-
29
- #
30
- # Determine the target object for the show command.
31
- #
32
- def determine_target
33
- return $engine.heap.context if @tokens.token_count == 1
34
-
35
- return Gloo::Core::Pn.new( @tokens.second )
36
- end
37
-
38
- #
39
- # Get the Verb's keyword.
40
- #
41
- def self.keyword
42
- return KEYWORD
43
- end
44
-
45
- #
46
- # Get the Verb's keyword shortcut.
47
- #
48
- def self.keyword_shortcut
49
- return KEYWORD_SHORT
50
- end
51
-
52
- # ---------------------------------------------------------------------
53
- # Private functions
54
- # ---------------------------------------------------------------------
55
-
56
- private
57
-
58
- #
59
- # Show the target object.
60
- #
61
- def show_target( obj, levels, indent = '' )
62
- show_obj( obj, indent )
63
- return if levels.zero?
64
-
65
- obj.children.each do |o|
66
- show_target( o, levels - 1, "#{indent} " )
67
- end
68
- end
69
-
70
- #
71
- # Show object in standard format.
72
- #
73
- def show_obj( obj, indent = ' ' )
74
- if obj.multiline_value? && obj.value_is_array?
75
- $log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
76
- obj.value.each do |line|
77
- $log.show "#{indent} #{line}"
78
- end
79
- else
80
- $log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
81
- end
82
- end
83
-
84
- #
85
- # Determine how many levels to show.
86
- #
87
- def determine_levels
88
- # Check settings for the default value.
89
- levels = $settings.list_indent
90
- return levels if levels
91
-
92
- # Last chance: use the default
93
- return 1
94
- end
95
-
96
- end
97
- end
98
- end
@@ -1,45 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Save an object to a file or other persistance mechcanism.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Load < Gloo::Core::Verb
10
-
11
- KEYWORD = 'load'.freeze
12
- KEYWORD_SHORT = '<'.freeze
13
- MISSING_EXPR_ERR = 'Missing Expression!'.freeze
14
-
15
- #
16
- # Run the verb.
17
- #
18
- def run
19
- fn = @tokens.second
20
-
21
- if fn
22
- $log.debug "Getting ready to load file: #{fn}"
23
- $engine.persist_man.load fn
24
- else
25
- $engine.err MISSING_EXPR_ERR
26
- end
27
- end
28
-
29
- #
30
- # Get the Verb's keyword.
31
- #
32
- def self.keyword
33
- return KEYWORD
34
- end
35
-
36
- #
37
- # Get the Verb's keyword shortcut.
38
- #
39
- def self.keyword_shortcut
40
- return KEYWORD_SHORT
41
- end
42
-
43
- end
44
- end
45
- end
@@ -1,89 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Move an object to a new parent.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Move < Gloo::Core::Verb
10
-
11
- KEYWORD = 'move'.freeze
12
- KEYWORD_SHORT = 'mv'.freeze
13
- TO = 'to'.freeze
14
- MISSING_SRC_ERR = 'Object to move was not specified!'.freeze
15
- MISSING_SRC_OBJ_ERR = 'Could not find object to move: '.freeze
16
- MISSING_DST_ERR = "Move' must include 'to' parent object!".freeze
17
- MISSING_DST_OBJ_ERR = 'Could not resolve target: '.freeze
18
-
19
- #
20
- # Run the verb.
21
- #
22
- def run
23
- dst = lookup_dst
24
- return if dst.nil?
25
-
26
- o = lookup_obj
27
- return unless o
28
-
29
- o.parent.remove_child o
30
- dst.add_child o
31
- end
32
-
33
- #
34
- # Get the Verb's keyword.
35
- #
36
- def self.keyword
37
- return KEYWORD
38
- end
39
-
40
- #
41
- # Get the Verb's keyword shortcut.
42
- #
43
- def self.keyword_shortcut
44
- return KEYWORD_SHORT
45
- end
46
-
47
- # ---------------------------------------------------------------------
48
- # Private functions
49
- # ---------------------------------------------------------------------
50
-
51
- private
52
-
53
- #
54
- # Lookup the object that we're moving.
55
- #
56
- def lookup_obj
57
- arr = @tokens.before_token( TO )
58
- if arr.count == 1
59
- $engine.err MISSING_SRC_ERR
60
- return
61
- end
62
-
63
- name = arr[ 1 ]
64
- pn = Gloo::Core::Pn.new name
65
- o = pn.resolve
66
-
67
- $engine.err( "#{MISSING_SRC_OBJ_ERR} #{name}" ) unless o
68
- return o
69
- end
70
-
71
- #
72
- # Lookup destination, the new parent object.
73
- #
74
- def lookup_dst
75
- dst = @tokens.after_token( TO )
76
- unless dst
77
- $engine.err MISSING_DST_ERR
78
- return nil
79
- end
80
-
81
- pn = Gloo::Core::Pn.new dst
82
- o = pn.resolve
83
- $engine.err( "#{MISSING_DST_OBJ_ERR} '#{dst}'" ) unless o
84
- return o
85
- end
86
-
87
- end
88
- end
89
- end
@@ -1,94 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Create an object, optionally of a type.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Put < Gloo::Core::Verb
10
-
11
- KEYWORD = 'put'.freeze
12
- KEYWORD_SHORT = 'p'.freeze
13
- INTO = 'into'.freeze
14
- MISSING_EXPR_ERR = 'Missing Expression!'.freeze
15
- INTO_MISSING_ERR = 'Target (into) missing!'.freeze
16
- TARGET_ERR = 'Target could not be resolved: '.freeze
17
-
18
- #
19
- # Run the verb.
20
- #
21
- def run
22
- value = fetch_value_tokens
23
- return if value.nil?
24
-
25
- target = lookup_target
26
- return if target.nil?
27
-
28
- update_target target, value
29
- end
30
-
31
- #
32
- # Get the Verb's keyword.
33
- #
34
- def self.keyword
35
- return KEYWORD
36
- end
37
-
38
- #
39
- # Get the Verb's keyword shortcut.
40
- #
41
- def self.keyword_shortcut
42
- return KEYWORD_SHORT
43
- end
44
-
45
- # ---------------------------------------------------------------------
46
- # Private functions
47
- # ---------------------------------------------------------------------
48
-
49
- private
50
-
51
- #
52
- # Get the value that is being put.
53
- #
54
- def fetch_value_tokens
55
- value = @tokens.before_token( INTO )
56
- if value.nil? || ( value.count <= 1 )
57
- $engine.err MISSING_EXPR_ERR
58
- return nil
59
- end
60
-
61
- # The first token is the verb, so we drop it.
62
- return value[ 1..-1 ]
63
- end
64
-
65
- #
66
- # Lookup the target of the put command.
67
- #
68
- def lookup_target
69
- target = @tokens.after_token( INTO )
70
- return target if target
71
-
72
- $engine.err INTO_MISSING_ERR
73
- return nil
74
- end
75
-
76
- #
77
- # Update the target with the new value.
78
- #
79
- def update_target( target, value )
80
- pn = Gloo::Core::Pn.new target
81
- o = pn.resolve
82
- if o.nil?
83
- $engine.err "#{TARGET_ERR} #{target}"
84
- elsif value.count.positive?
85
- expr = Gloo::Expr::Expression.new( value )
86
- result = expr.evaluate
87
- o.set_value result
88
- $engine.heap.it.set_to result
89
- end
90
- end
91
-
92
- end
93
- end
94
- end
@@ -1,40 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Quit the running gloo engine.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Quit < Gloo::Core::Verb
10
-
11
- KEYWORD = 'quit'.freeze
12
- KEYWORD_SHORT = 'q'.freeze
13
-
14
- #
15
- # Run the verb.
16
- #
17
- # We'll mark the application as not running and let the
18
- # engine stop gracefully next time through the loop.
19
- #
20
- def run
21
- $engine.stop_running
22
- end
23
-
24
- #
25
- # Get the Verb's keyword.
26
- #
27
- def self.keyword
28
- return KEYWORD
29
- end
30
-
31
- #
32
- # Get the Verb's keyword shortcut.
33
- #
34
- def self.keyword_shortcut
35
- return KEYWORD_SHORT
36
- end
37
-
38
- end
39
- end
40
- end
@@ -1,75 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Run a script.
5
- # Shortcut for telling a script to run.
6
- #
7
-
8
- module Gloo
9
- module Verbs
10
- class Run < Gloo::Core::Verb
11
-
12
- KEYWORD = 'run'.freeze
13
- KEYWORD_SHORT = 'r'.freeze
14
- EVALUATE_RUN = '~>'.freeze
15
- MISSING_EXPR_ERR = 'Missing Expression!'.freeze
16
-
17
- #
18
- # Run the verb.
19
- #
20
- def run
21
- if @tokens.token_count < 2
22
- $engine.err MISSING_EXPR_ERR
23
- return
24
- end
25
-
26
- if @tokens.second == EVALUATE_RUN
27
- run_expression
28
- else
29
- run_script
30
- end
31
- end
32
-
33
- #
34
- # Get the Verb's keyword.
35
- #
36
- def self.keyword
37
- return KEYWORD
38
- end
39
-
40
- #
41
- # Get the Verb's keyword shortcut.
42
- #
43
- def self.keyword_shortcut
44
- return KEYWORD_SHORT
45
- end
46
-
47
- # ---------------------------------------------------------------------
48
- # Private functions
49
- # ---------------------------------------------------------------------
50
-
51
- private
52
-
53
- #
54
- # Run a script specified by pathname
55
- #
56
- def run_script
57
- Gloo::Exec::Runner.run @tokens.second
58
- end
59
-
60
- #
61
- # Evaluate an expression and run that.
62
- #
63
- def run_expression
64
- unless @tokens.token_count > 2
65
- $engine.err MISSING_EXPR_ERR
66
- return
67
- end
68
-
69
- expr = Gloo::Expr::Expression.new( @tokens.params[ 1..-1 ] )
70
- $engine.parser.run expr.evaluate
71
- end
72
-
73
- end
74
- end
75
- end
@@ -1,39 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Save an object to a file or other persistance mechcanism.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Save < Gloo::Core::Verb
10
-
11
- KEYWORD = 'save'.freeze
12
- KEYWORD_SHORT = '>'.freeze
13
-
14
- #
15
- # Run the verb.
16
- #
17
- def run
18
- # TODO: Not currently using folders or keeping
19
- # track of where the object was loaded from.
20
- $engine.persist_man.save @tokens.second
21
- end
22
-
23
- #
24
- # Get the Verb's keyword.
25
- #
26
- def self.keyword
27
- return KEYWORD
28
- end
29
-
30
- #
31
- # Get the Verb's keyword shortcut.
32
- #
33
- def self.keyword_shortcut
34
- return KEYWORD_SHORT
35
- end
36
-
37
- end
38
- end
39
- end
@@ -1,64 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Show a single object's value.
5
- #
6
- require 'colorized_string'
7
-
8
- module Gloo
9
- module Verbs
10
- class Show < Gloo::Core::Verb
11
-
12
- KEYWORD = 'show'.freeze
13
- KEYWORD_SHORT = '='.freeze
14
-
15
- #
16
- # Run the verb.
17
- #
18
- def run
19
- if @tokens.token_count > 1
20
- expr = Gloo::Expr::Expression.new( @tokens.params )
21
- result = expr.evaluate
22
- $log.show get_formatted_string( result )
23
- $engine.heap.it.set_to result
24
- else
25
- $log.show ''
26
- end
27
- end
28
-
29
- #
30
- # Get the Verb's keyword.
31
- #
32
- def self.keyword
33
- return KEYWORD
34
- end
35
-
36
- #
37
- # Get the Verb's keyword shortcut.
38
- #
39
- def self.keyword_shortcut
40
- return KEYWORD_SHORT
41
- end
42
-
43
- # ---------------------------------------------------------------------
44
- # Private functions
45
- # ---------------------------------------------------------------------
46
-
47
- private
48
-
49
- #
50
- # Get the formatted string.
51
- #
52
- def get_formatted_string( str )
53
- if @params&.token_count&.positive?
54
- expr = Gloo::Expr::Expression.new( @params.tokens )
55
- val = expr.evaluate
56
- color = val.to_sym
57
- return ColorizedString[ str.to_s ].colorize( color )
58
- end
59
- return str
60
- end
61
-
62
- end
63
- end
64
- end
@@ -1,79 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # Create an object, optionally of a type.
5
- #
6
-
7
- module Gloo
8
- module Verbs
9
- class Tell < Gloo::Core::Verb
10
-
11
- KEYWORD = 'tell'.freeze
12
- KEYWORD_SHORT = '->'.freeze
13
- TO = 'to'.freeze
14
- OBJ_NOT_FOUND_ERR = 'Object was not found: '.freeze
15
- UNKNOWN_MSG_ERR = 'Missing message!'.freeze
16
-
17
- #
18
- # Run the verb.
19
- #
20
- def run
21
- setup_msg
22
- return unless @msg
23
-
24
- setup_target
25
- dispatch_msg
26
- end
27
-
28
- #
29
- # Get the Verb's keyword.
30
- #
31
- def self.keyword
32
- return KEYWORD
33
- end
34
-
35
- #
36
- # Get the Verb's keyword shortcut.
37
- #
38
- def self.keyword_shortcut
39
- return KEYWORD_SHORT
40
- end
41
-
42
- # ---------------------------------------------------------------------
43
- # Private functions
44
- # ---------------------------------------------------------------------
45
-
46
- private
47
-
48
- #
49
- # Lookup the message to send.
50
- #
51
- def setup_msg
52
- @msg = @tokens.after_token( TO )
53
-
54
- $engine.err( UNKNOWN_MSG_ERR ) unless @msg
55
- end
56
-
57
- #
58
- # Setup the target of the message.
59
- #
60
- def setup_target
61
- @obj_name = @tokens.second
62
- pn = Gloo::Core::Pn.new @obj_name
63
- @target_obj = pn.resolve
64
- end
65
-
66
- #
67
- # Dispatch the message to the target object.
68
- #
69
- def dispatch_msg
70
- if @target_obj
71
- Gloo::Exec::Dispatch.message @msg, @target_obj, @params
72
- else
73
- $engine.err "#{OBJ_NOT_FOUND_ERR} #{@obj_name}"
74
- end
75
- end
76
-
77
- end
78
- end
79
- end