gloo 1.4.2 → 2.0.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 (131) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/gloo.gemspec +0 -2
  5. data/lib/VERSION +1 -1
  6. data/lib/dependencies.rb +4 -4
  7. data/lib/gloo/app/args.rb +112 -0
  8. data/lib/gloo/app/engine.rb +247 -0
  9. data/lib/gloo/app/engine_context.rb +25 -0
  10. data/lib/gloo/app/info.rb +20 -3
  11. data/lib/gloo/app/log.rb +73 -1
  12. data/lib/gloo/app/mode.rb +27 -0
  13. data/lib/gloo/app/platform.rb +8 -1
  14. data/lib/gloo/app/settings.rb +202 -0
  15. data/lib/gloo/convert/converter.rb +42 -0
  16. data/lib/gloo/convert/string_to_date.rb +21 -0
  17. data/lib/gloo/convert/string_to_datetime.rb +21 -0
  18. data/lib/gloo/convert/string_to_decimal.rb +20 -0
  19. data/lib/gloo/convert/string_to_integer.rb +20 -0
  20. data/lib/gloo/convert/string_to_time.rb +21 -0
  21. data/lib/gloo/core/baseo.rb +31 -0
  22. data/lib/gloo/core/dictionary.rb +245 -0
  23. data/lib/gloo/core/error.rb +61 -0
  24. data/lib/gloo/core/event_manager.rb +45 -0
  25. data/lib/gloo/core/factory.rb +211 -0
  26. data/lib/gloo/core/gloo_system.rb +267 -0
  27. data/lib/gloo/core/heap.rb +53 -0
  28. data/lib/gloo/core/here.rb +36 -0
  29. data/lib/gloo/core/it.rb +36 -0
  30. data/lib/gloo/core/literal.rb +30 -0
  31. data/lib/gloo/core/obj.rb +318 -0
  32. data/lib/gloo/core/obj_finder.rb +30 -0
  33. data/lib/gloo/core/op.rb +40 -0
  34. data/lib/gloo/core/parser.rb +60 -0
  35. data/lib/gloo/core/pn.rb +212 -0
  36. data/lib/gloo/core/tokens.rb +165 -0
  37. data/lib/gloo/core/verb.rb +87 -0
  38. data/lib/gloo/exec/action.rb +48 -0
  39. data/lib/gloo/exec/dispatch.rb +40 -0
  40. data/lib/gloo/exec/exec_env.rb +75 -0
  41. data/lib/gloo/exec/runner.rb +45 -0
  42. data/lib/gloo/exec/script.rb +50 -0
  43. data/lib/gloo/exec/stack.rb +79 -0
  44. data/lib/gloo/expr/expression.rb +119 -0
  45. data/lib/gloo/expr/l_boolean.rb +36 -0
  46. data/lib/gloo/expr/l_decimal.rb +39 -0
  47. data/lib/gloo/expr/l_integer.rb +37 -0
  48. data/lib/gloo/expr/l_string.rb +58 -0
  49. data/lib/gloo/expr/op_div.rb +22 -0
  50. data/lib/gloo/expr/op_minus.rb +22 -0
  51. data/lib/gloo/expr/op_mult.rb +22 -0
  52. data/lib/gloo/expr/op_plus.rb +24 -0
  53. data/lib/gloo/objs/basic/alias.rb +78 -0
  54. data/lib/gloo/objs/basic/boolean.rb +120 -0
  55. data/lib/gloo/objs/basic/container.rb +65 -0
  56. data/lib/gloo/objs/basic/decimal.rb +76 -0
  57. data/lib/gloo/objs/basic/integer.rb +73 -0
  58. data/lib/gloo/objs/basic/script.rb +99 -0
  59. data/lib/gloo/objs/basic/string.rb +77 -0
  60. data/lib/gloo/objs/basic/text.rb +79 -0
  61. data/lib/gloo/objs/basic/untyped.rb +41 -0
  62. data/lib/gloo/objs/cli/banner.rb +1 -1
  63. data/lib/gloo/objs/cli/bar.rb +3 -3
  64. data/lib/gloo/objs/cli/colorize.rb +1 -1
  65. data/lib/gloo/objs/cli/confirm.rb +1 -1
  66. data/lib/gloo/objs/cli/menu.rb +6 -6
  67. data/lib/gloo/objs/cli/menu_item.rb +1 -1
  68. data/lib/gloo/objs/cli/pastel.rb +1 -1
  69. data/lib/gloo/objs/cli/prompt.rb +1 -1
  70. data/lib/gloo/objs/cli/select.rb +2 -2
  71. data/lib/gloo/objs/ctrl/each.rb +279 -0
  72. data/lib/gloo/objs/ctrl/repeat.rb +108 -0
  73. data/lib/gloo/objs/data/markdown.rb +79 -0
  74. data/lib/gloo/objs/data/mysql.rb +5 -5
  75. data/lib/gloo/objs/data/query.rb +4 -4
  76. data/lib/gloo/objs/data/sqlite.rb +1 -1
  77. data/lib/gloo/objs/data/table.rb +112 -0
  78. data/lib/gloo/objs/dev/git.rb +2 -2
  79. data/lib/gloo/objs/dev/stats.rb +4 -4
  80. data/lib/gloo/objs/dt/date.rb +65 -0
  81. data/lib/gloo/objs/dt/datetime.rb +120 -0
  82. data/lib/gloo/objs/dt/dt_tools.rb +100 -0
  83. data/lib/gloo/objs/dt/time.rb +65 -0
  84. data/lib/gloo/objs/ror/erb.rb +116 -0
  85. data/lib/gloo/objs/ror/eval.rb +107 -0
  86. data/lib/gloo/objs/snd/play.rb +1 -1
  87. data/lib/gloo/objs/snd/say.rb +1 -1
  88. data/lib/gloo/objs/system/file_handle.rb +4 -4
  89. data/lib/gloo/objs/system/ssh_exec.rb +1 -1
  90. data/lib/gloo/objs/system/system.rb +1 -1
  91. data/lib/gloo/objs/web/http_get.rb +159 -0
  92. data/lib/gloo/objs/web/http_post.rb +183 -0
  93. data/lib/gloo/objs/web/json.rb +135 -0
  94. data/lib/gloo/objs/web/slack.rb +130 -0
  95. data/lib/gloo/objs/web/teams.rb +117 -0
  96. data/lib/gloo/objs/web/uri.rb +148 -0
  97. data/lib/gloo/persist/disc_mech.rb +87 -0
  98. data/lib/gloo/persist/file_loader.rb +193 -0
  99. data/lib/gloo/persist/file_saver.rb +51 -0
  100. data/lib/gloo/persist/file_storage.rb +46 -0
  101. data/lib/gloo/persist/line_splitter.rb +81 -0
  102. data/lib/gloo/persist/persist_man.rb +153 -0
  103. data/lib/gloo/utils/format.rb +21 -0
  104. data/lib/gloo/utils/stats.rb +206 -0
  105. data/lib/gloo/utils/words.rb +19 -0
  106. data/lib/gloo/verbs/alert.rb +2 -2
  107. data/lib/gloo/verbs/beep.rb +1 -1
  108. data/lib/gloo/verbs/cls.rb +1 -1
  109. data/lib/gloo/verbs/context.rb +62 -0
  110. data/lib/gloo/verbs/create.rb +68 -0
  111. data/lib/gloo/verbs/execute.rb +56 -0
  112. data/lib/gloo/verbs/files.rb +49 -0
  113. data/lib/gloo/verbs/help.rb +1 -1
  114. data/lib/gloo/verbs/if.rb +92 -0
  115. data/lib/gloo/verbs/list.rb +98 -0
  116. data/lib/gloo/verbs/load.rb +45 -0
  117. data/lib/gloo/verbs/move.rb +89 -0
  118. data/lib/gloo/verbs/put.rb +94 -0
  119. data/lib/gloo/verbs/quit.rb +40 -0
  120. data/lib/gloo/verbs/reload.rb +43 -0
  121. data/lib/gloo/verbs/run.rb +75 -0
  122. data/lib/gloo/verbs/save.rb +39 -0
  123. data/lib/gloo/verbs/show.rb +63 -0
  124. data/lib/gloo/verbs/tell.rb +80 -0
  125. data/lib/gloo/verbs/unless.rb +92 -0
  126. data/lib/gloo/verbs/unload.rb +46 -0
  127. data/lib/gloo/verbs/version.rb +3 -3
  128. data/lib/gloo/verbs/wait.rb +42 -0
  129. data/lib/gloo.rb +2 -2
  130. data/lib/run.rb +2 -2
  131. metadata +97 -22
@@ -0,0 +1,99 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # A Script.
5
+ # A set of commands to be run.
6
+ #
7
+
8
+ module Gloo
9
+ module Objs
10
+ class Script < Gloo::Core::Obj
11
+
12
+ KEYWORD = 'script'.freeze
13
+ KEYWORD_SHORT = 'cmd'.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
+ # Set the value as an array.
38
+ #
39
+ def set_array_value( arr )
40
+ self.value = arr
41
+ end
42
+
43
+ #
44
+ # Add a line (cmd) to the script.
45
+ #
46
+ def add_line( line )
47
+ if self.value_string?
48
+ first = self.value
49
+ self.set_array_value []
50
+ self.value << first unless first.empty?
51
+ elsif self.value_is_blank?
52
+ self.set_array_value []
53
+ end
54
+ self.value << line.strip
55
+ end
56
+
57
+ #
58
+ # Does this object support multi-line values?
59
+ # Initially only true for scripts.
60
+ #
61
+ def multiline_value?
62
+ return true
63
+ end
64
+
65
+ #
66
+ # Get the number of lines in this script.
67
+ #
68
+ def line_count
69
+ return self.value.count if self.value_is_array?
70
+
71
+ if self.value_string?
72
+ return self.value.strip.empty? ? 0 : 1
73
+ end
74
+
75
+ return 0
76
+ end
77
+
78
+ # ---------------------------------------------------------------------
79
+ # Messages
80
+ # ---------------------------------------------------------------------
81
+
82
+ #
83
+ # Get a list of message names that this object receives.
84
+ #
85
+ def self.messages
86
+ return super + [ 'run' ]
87
+ end
88
+
89
+ #
90
+ # Send the object the unload message.
91
+ #
92
+ def msg_run
93
+ s = Gloo::Exec::Script.new( @engine, self )
94
+ s.run
95
+ end
96
+
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,77 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # A String.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class String < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'string'.freeze
12
+ KEYWORD_SHORT = 'str'.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
+ self.value = new_value.to_s
33
+ end
34
+
35
+ # ---------------------------------------------------------------------
36
+ # Messages
37
+ # ---------------------------------------------------------------------
38
+
39
+ #
40
+ # Get a list of message names that this object receives.
41
+ #
42
+ def self.messages
43
+ return super + %w[up down size]
44
+ end
45
+
46
+ #
47
+ # Get the size of the string.
48
+ #
49
+ def msg_size
50
+ s = value.size
51
+ @engine.heap.it.set_to s
52
+ return s
53
+ end
54
+
55
+ #
56
+ # Convert string to upper case
57
+ #
58
+ def msg_up
59
+ s = value.upcase
60
+ set_value s
61
+ @engine.heap.it.set_to s
62
+ return s
63
+ end
64
+
65
+ #
66
+ # Convert string to lower case
67
+ #
68
+ def msg_down
69
+ s = value.downcase
70
+ set_value s
71
+ @engine.heap.it.set_to s
72
+ return s
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,79 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # A [multiline] block of text.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class Text < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'text'.freeze
12
+ KEYWORD_SHORT = 'txt'.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
+ self.value = new_value.to_s
33
+ end
34
+
35
+ #
36
+ # Does this object support multi-line values?
37
+ # Initially only true for scripts.
38
+ #
39
+ def multiline_value?
40
+ return false
41
+ end
42
+
43
+ #
44
+ # Get the number of lines of text.
45
+ #
46
+ def line_count
47
+ return value.split( "\n" ).count
48
+ end
49
+
50
+ # ---------------------------------------------------------------------
51
+ # Messages
52
+ # ---------------------------------------------------------------------
53
+
54
+ #
55
+ # Get a list of message names that this object receives.
56
+ #
57
+ def self.messages
58
+ return super + %w[edit page]
59
+ end
60
+
61
+ #
62
+ # Show the contents of the file, paginated.
63
+ #
64
+ def msg_page
65
+ return unless value
66
+
67
+ @engine.platform.show( value, false, true )
68
+ end
69
+
70
+ #
71
+ # Edit the text in the default editor.
72
+ #
73
+ def msg_edit
74
+ self.value = @engine.platform.edit( self.value )
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,41 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # An Untyped Object.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class Untyped < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'untyped'.freeze
12
+ KEYWORD_SHORT = 'un'.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
+ # Messages
30
+ # ---------------------------------------------------------------------
31
+
32
+ #
33
+ # Get a list of message names that this object receives.
34
+ #
35
+ def self.messages
36
+ return super # + [ "run" ]
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -8,7 +8,7 @@ require 'pastel'
8
8
 
9
9
  module Gloo
10
10
  module Objs
11
- class Banner < GlooLang::Core::Obj
11
+ class Banner < Gloo::Core::Obj
12
12
 
13
13
  KEYWORD = 'banner'.freeze
14
14
  KEYWORD_SHORT = 'ban'.freeze
@@ -7,7 +7,7 @@ require 'tty-progressbar'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class Bar < GlooLang::Core::Obj
10
+ class Bar < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'bar'.freeze
13
13
  KEYWORD_SHORT = 'bar'.freeze
@@ -100,7 +100,7 @@ module Gloo
100
100
  def msg_advance
101
101
  x = 1
102
102
  if @params&.token_count&.positive?
103
- expr = GlooLang::Expr::Expression.new( @engine, @params.tokens )
103
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
104
104
  x = expr.evaluate.to_i
105
105
  end
106
106
 
@@ -116,7 +116,7 @@ module Gloo
116
116
 
117
117
  x = 1
118
118
  if @params&.token_count&.positive?
119
- expr = GlooLang::Expr::Expression.new( @engine, @params.tokens )
119
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
120
120
  x = expr.evaluate.to_i
121
121
  end
122
122
 
@@ -7,7 +7,7 @@ require 'colorized_string'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class Colorize < GlooLang::Core::Obj
10
+ class Colorize < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'colorize'.freeze
13
13
  KEYWORD_SHORT = 'color'.freeze
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Confirm < GlooLang::Core::Obj
9
+ class Confirm < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'confirm'.freeze
12
12
  KEYWORD_SHORT = 'confirm'.freeze
@@ -8,7 +8,7 @@
8
8
 
9
9
  module Gloo
10
10
  module Objs
11
- class Menu < GlooLang::Core::Obj
11
+ class Menu < Gloo::Core::Obj
12
12
 
13
13
  KEYWORD = 'menu'.freeze
14
14
  KEYWORD_SHORT = 'menu'.freeze
@@ -138,7 +138,7 @@ module Gloo
138
138
  o = find_child BEFORE_MENU
139
139
  return unless o
140
140
 
141
- GlooLang::Exec::Dispatch.message( @engine, 'run', o )
141
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
142
142
  end
143
143
 
144
144
  #
@@ -149,7 +149,7 @@ module Gloo
149
149
  return unless o
150
150
 
151
151
  o.children.each do |mitem|
152
- mitem = GlooLang::Objs::Alias.resolve_alias( @engine, mitem )
152
+ mitem = Gloo::Objs::Alias.resolve_alias( @engine, mitem )
153
153
  puts " #{mitem.shortcut_value} - #{mitem.description_value}"
154
154
  end
155
155
  end
@@ -162,7 +162,7 @@ module Gloo
162
162
  return nil unless o
163
163
 
164
164
  o.children.each do |mitem|
165
- mitem = GlooLang::Objs::Alias.resolve_alias( @engine, mitem )
165
+ mitem = Gloo::Objs::Alias.resolve_alias( @engine, mitem )
166
166
  return mitem if mitem.shortcut_value.downcase == cmd.downcase
167
167
  end
168
168
 
@@ -176,7 +176,7 @@ module Gloo
176
176
  obj = find_child DEFAULT
177
177
  return unless obj
178
178
 
179
- s = GlooLang::Exec::Script.new( @engine, obj )
179
+ s = Gloo::Exec::Script.new( @engine, obj )
180
180
  s.run
181
181
  end
182
182
 
@@ -198,7 +198,7 @@ module Gloo
198
198
  script = obj.do_script
199
199
  return unless script
200
200
 
201
- s = GlooLang::Exec::Script.new( @engine, script )
201
+ s = Gloo::Exec::Script.new( @engine, script )
202
202
  s.run
203
203
  end
204
204
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class MenuItem < GlooLang::Core::Obj
9
+ class MenuItem < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'menu_item'.freeze
12
12
  KEYWORD_SHORT = 'mitem'.freeze
@@ -7,7 +7,7 @@ require 'pastel'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class Pastel < GlooLang::Core::Obj
10
+ class Pastel < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'pastel'.freeze
13
13
  KEYWORD_SHORT = 'pastel'.freeze
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Prompt < GlooLang::Core::Obj
9
+ class Prompt < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'prompt'.freeze
12
12
  KEYWORD_SHORT = 'ask'.freeze
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Select < GlooLang::Core::Obj
9
+ class Select < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'select'.freeze
12
12
  KEYWORD_SHORT = 'sel'.freeze
@@ -116,7 +116,7 @@ module Gloo
116
116
  prompt = prompt_value
117
117
  return unless prompt
118
118
 
119
- per = GlooLang::App::Settings.page_size( @engine )
119
+ per = Gloo::App::Settings.page_size( @engine )
120
120
  result = @engine.platform.prompt.select( prompt, options, :per_page => per )
121
121
  set_result self.key_for_option( result )
122
122
  end