gloo 0.3.0 → 0.5.3

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.rubocop.yml +73 -0
  4. data/Gemfile +2 -2
  5. data/Gemfile.lock +86 -83
  6. data/Rakefile +7 -6
  7. data/bin/console +4 -4
  8. data/gloo.gemspec +22 -18
  9. data/lib/gloo.rb +6 -6
  10. data/lib/gloo/app/args.rb +30 -31
  11. data/lib/gloo/app/engine.rb +80 -30
  12. data/lib/gloo/app/help.rb +17 -11
  13. data/lib/gloo/app/info.rb +3 -3
  14. data/lib/gloo/app/log.rb +17 -17
  15. data/lib/gloo/app/mode.rb +4 -4
  16. data/lib/gloo/app/settings.rb +51 -41
  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/core/baseo.rb +7 -7
  21. data/lib/gloo/core/dictionary.rb +30 -27
  22. data/lib/gloo/core/error.rb +50 -0
  23. data/lib/gloo/core/event_manager.rb +17 -23
  24. data/lib/gloo/core/factory.rb +149 -39
  25. data/lib/gloo/core/gloo_system.rb +121 -54
  26. data/lib/gloo/core/heap.rb +15 -13
  27. data/lib/gloo/core/it.rb +5 -5
  28. data/lib/gloo/core/literal.rb +7 -7
  29. data/lib/gloo/core/obj.rb +138 -79
  30. data/lib/gloo/core/obj_finder.rb +9 -14
  31. data/lib/gloo/core/op.rb +8 -8
  32. data/lib/gloo/core/parser.rb +27 -26
  33. data/lib/gloo/core/pn.rb +68 -52
  34. data/lib/gloo/core/script.rb +7 -7
  35. data/lib/gloo/core/tokens.rb +39 -41
  36. data/lib/gloo/core/verb.rb +30 -19
  37. data/lib/gloo/exec/dispatch.rb +30 -0
  38. data/lib/gloo/exec/runner.rb +43 -0
  39. data/lib/gloo/expr/expression.rb +36 -43
  40. data/lib/gloo/expr/l_boolean.rb +7 -6
  41. data/lib/gloo/expr/l_decimal.rb +34 -0
  42. data/lib/gloo/expr/l_integer.rb +5 -4
  43. data/lib/gloo/expr/l_string.rb +13 -15
  44. data/lib/gloo/expr/op_div.rb +5 -5
  45. data/lib/gloo/expr/op_minus.rb +5 -5
  46. data/lib/gloo/expr/op_mult.rb +5 -5
  47. data/lib/gloo/expr/op_plus.rb +7 -7
  48. data/lib/gloo/objs/basic/alias.rb +111 -0
  49. data/lib/gloo/objs/basic/boolean.rb +63 -38
  50. data/lib/gloo/objs/basic/container.rb +71 -12
  51. data/lib/gloo/objs/basic/decimal.rb +96 -0
  52. data/lib/gloo/objs/basic/integer.rb +45 -16
  53. data/lib/gloo/objs/basic/script.rb +62 -38
  54. data/lib/gloo/objs/basic/string.rb +47 -15
  55. data/lib/gloo/objs/basic/text.rb +69 -21
  56. data/lib/gloo/objs/basic/untyped.rb +35 -10
  57. data/lib/gloo/objs/cli/banner.rb +137 -0
  58. data/lib/gloo/objs/cli/bar.rb +141 -0
  59. data/lib/gloo/objs/cli/colorize.rb +54 -24
  60. data/lib/gloo/objs/cli/confirm.rb +63 -29
  61. data/lib/gloo/objs/cli/menu.rb +236 -0
  62. data/lib/gloo/objs/cli/menu_item.rb +128 -0
  63. data/lib/gloo/objs/cli/pastel.rb +120 -0
  64. data/lib/gloo/objs/cli/prompt.rb +73 -31
  65. data/lib/gloo/objs/cli/select.rb +153 -0
  66. data/lib/gloo/objs/ctrl/each.rb +128 -61
  67. data/lib/gloo/objs/ctrl/repeat.rb +129 -0
  68. data/lib/gloo/objs/data/markdown.rb +109 -0
  69. data/lib/gloo/objs/data/table.rb +168 -0
  70. data/lib/gloo/objs/dev/git.rb +98 -64
  71. data/lib/gloo/objs/dt/date.rb +72 -0
  72. data/lib/gloo/objs/dt/datetime.rb +84 -0
  73. data/lib/gloo/objs/dt/time.rb +72 -0
  74. data/lib/gloo/objs/ror/erb.rb +82 -41
  75. data/lib/gloo/objs/ror/eval.rb +73 -31
  76. data/lib/gloo/objs/snd/play.rb +71 -0
  77. data/lib/gloo/objs/snd/say.rb +120 -0
  78. data/lib/gloo/objs/system/file_handle.rb +129 -48
  79. data/lib/gloo/objs/system/system.rb +84 -38
  80. data/lib/gloo/objs/web/http_get.rb +103 -46
  81. data/lib/gloo/objs/web/http_post.rb +70 -44
  82. data/lib/gloo/objs/web/json.rb +155 -0
  83. data/lib/gloo/objs/web/slack.rb +89 -58
  84. data/lib/gloo/objs/web/teams.rb +88 -53
  85. data/lib/gloo/objs/web/uri.rb +160 -0
  86. data/lib/gloo/persist/file_loader.rb +95 -85
  87. data/lib/gloo/persist/file_saver.rb +12 -12
  88. data/lib/gloo/persist/file_storage.rb +15 -15
  89. data/lib/gloo/persist/line_splitter.rb +79 -0
  90. data/lib/gloo/persist/persist_man.rb +63 -39
  91. data/lib/gloo/utils/words.rb +2 -2
  92. data/lib/gloo/verbs/alert.rb +67 -16
  93. data/lib/gloo/verbs/beep.rb +70 -0
  94. data/lib/gloo/verbs/cls.rb +67 -0
  95. data/lib/gloo/verbs/context.rb +61 -21
  96. data/lib/gloo/verbs/create.rb +52 -21
  97. data/lib/gloo/verbs/help.rb +186 -27
  98. data/lib/gloo/verbs/if.rb +55 -21
  99. data/lib/gloo/verbs/list.rb +55 -24
  100. data/lib/gloo/verbs/load.rb +47 -12
  101. data/lib/gloo/verbs/move.rb +128 -0
  102. data/lib/gloo/verbs/put.rb +90 -34
  103. data/lib/gloo/verbs/quit.rb +43 -12
  104. data/lib/gloo/verbs/run.rb +63 -18
  105. data/lib/gloo/verbs/save.rb +45 -10
  106. data/lib/gloo/verbs/show.rb +56 -22
  107. data/lib/gloo/verbs/tell.rb +45 -13
  108. data/lib/gloo/verbs/unless.rb +56 -21
  109. data/lib/gloo/verbs/version.rb +42 -12
  110. data/lib/gloo/verbs/wait.rb +73 -0
  111. data/lib/run.rb +5 -5
  112. metadata +90 -12
@@ -9,11 +9,11 @@ require 'active_support/inflector'
9
9
  module Gloo
10
10
  module Utils
11
11
  class Words
12
-
12
+
13
13
  def self.pluralize( word )
14
14
  return word.pluralize
15
15
  end
16
-
16
+
17
17
  end
18
18
  end
19
19
  end
@@ -7,36 +7,87 @@
7
7
  module Gloo
8
8
  module Verbs
9
9
  class Alert < Gloo::Core::Verb
10
-
11
- KEYWORD = 'alert'
12
- KEYWORD_SHORT = '!'
13
10
 
14
- #
11
+ KEYWORD = 'alert'.freeze
12
+ KEYWORD_SHORT = '!'.freeze
13
+
14
+ #
15
15
  # Run the verb.
16
- #
16
+ #
17
17
  def run
18
- if @tokens.token_count > 1
19
- expr = Gloo::Expr::Expression.new( @tokens.params )
20
- result = expr.evaluate
21
- $engine.heap.it.set_to result
22
- system( '/usr/bin/osascript -e "display notification \"' + result.to_s + '\" with title \"OutlineScript\" "' )
23
- end
18
+ return unless @tokens.token_count > 1
19
+
20
+ expr = Gloo::Expr::Expression.new( @tokens.params )
21
+ result = expr.evaluate
22
+ $engine.heap.it.set_to result
23
+ self.post_alert result
24
+ end
25
+
26
+ #
27
+ # Post the alert for the specific platform.
28
+ # Notice is not posted if we're in quiet mode.
29
+ #
30
+ def post_alert( msg )
31
+ return if $engine.args.quiet?
32
+
33
+ post_osx msg
34
+ end
35
+
36
+ #
37
+ # Post the alert on the Mac OSX.
38
+ #
39
+ def post_osx( msg )
40
+ cmd1 = '/usr/bin/osascript -e "display notification \"'
41
+ cmd2 = '\" with title \"Gloo\" "'
42
+ system( cmd1 + msg.to_s + cmd2 )
24
43
  end
25
-
26
- #
44
+
45
+ #
27
46
  # Get the Verb's keyword.
28
- #
47
+ #
29
48
  def self.keyword
30
49
  return KEYWORD
31
50
  end
32
51
 
33
- #
52
+ #
34
53
  # Get the Verb's keyword shortcut.
35
- #
54
+ #
36
55
  def self.keyword_shortcut
37
56
  return KEYWORD_SHORT
38
57
  end
39
58
 
59
+ # ---------------------------------------------------------------------
60
+ # Help
61
+ # ---------------------------------------------------------------------
62
+
63
+ #
64
+ # Get help for this verb.
65
+ #
66
+ def self.help
67
+ return <<~TEXT
68
+ ALERT VERB
69
+ NAME: alert
70
+ SHORTCUT: !
71
+
72
+ DESCRIPTION
73
+ Show a pop-up notification.
74
+ This has only been implemented for the Mac OSX as of yet.
75
+
76
+ SYNTAX
77
+ alert <messsage>
78
+
79
+ PARAMETERS
80
+ messsage - The message that will be displayed in the alert.
81
+
82
+ RESULT
83
+ On the Mac, a notification will popup on screen.
84
+ <it> will be set to the message.
85
+
86
+ ERRORS
87
+ None
88
+ TEXT
89
+ end
90
+
40
91
  end
41
92
  end
42
93
  end
@@ -0,0 +1,70 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # Play a standard system beep sound.
5
+ #
6
+
7
+ module Gloo
8
+ module Verbs
9
+ class Beep < Gloo::Core::Verb
10
+
11
+ KEYWORD = 'beep'.freeze
12
+ KEYWORD_SHORT = 'b'.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
+ print 7.chr
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
+ # ---------------------------------------------------------------------
39
+ # Help
40
+ # ---------------------------------------------------------------------
41
+
42
+ #
43
+ # Get help for this verb.
44
+ #
45
+ def self.help
46
+ return <<~TEXT
47
+ BEEP VERB
48
+ NAME: beep
49
+ SHORTCUT: b
50
+
51
+ DESCRIPTION
52
+ Play a standard system beep sound.
53
+
54
+ SYNTAX
55
+ beep
56
+
57
+ PARAMETERS
58
+ None
59
+
60
+ RESULT
61
+ None
62
+
63
+ ERRORS
64
+ None
65
+ TEXT
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,67 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # Clear the screen.
5
+ #
6
+
7
+ module Gloo
8
+ module Verbs
9
+ class Cls < Gloo::Core::Verb
10
+
11
+ KEYWORD = 'cls'.freeze
12
+ KEYWORD_SHORT = 'cls'.freeze
13
+
14
+ #
15
+ # Run the verb.
16
+ #
17
+ def run
18
+ $engine&.clear_screen
19
+ end
20
+
21
+ #
22
+ # Get the Verb's keyword.
23
+ #
24
+ def self.keyword
25
+ return KEYWORD
26
+ end
27
+
28
+ #
29
+ # Get the Verb's keyword shortcut.
30
+ #
31
+ def self.keyword_shortcut
32
+ return KEYWORD_SHORT
33
+ end
34
+
35
+ # ---------------------------------------------------------------------
36
+ # Help
37
+ # ---------------------------------------------------------------------
38
+
39
+ #
40
+ # Get help for this verb.
41
+ #
42
+ def self.help
43
+ return <<~TEXT
44
+ CLS VERB
45
+ NAME: cls
46
+ SHORTCUT: cls
47
+
48
+ DESCRIPTION
49
+ Clear the console screen.
50
+
51
+ SYNTAX
52
+ cls
53
+
54
+ PARAMETERS
55
+ None
56
+
57
+ RESULT
58
+ The screen is cleared and cursor set to the top.
59
+
60
+ ERRORS
61
+ None
62
+ TEXT
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -8,45 +8,85 @@
8
8
  module Gloo
9
9
  module Verbs
10
10
  class Context < Gloo::Core::Verb
11
-
12
- KEYWORD = 'context'
13
- KEYWORD_SHORT = '@'
14
11
 
15
- #
12
+ KEYWORD = 'context'.freeze
13
+ KEYWORD_SHORT = '@'.freeze
14
+
15
+ #
16
16
  # Run the verb.
17
- #
17
+ #
18
18
  def run
19
- if @tokens.token_count == 1
20
- show_context
21
- else
22
- path = @tokens.second
23
- $engine.heap.context.set_to path
24
- $engine.heap.it.set_to path
25
- $log.debug "Context set to #{$engine.heap.context}"
26
- end
19
+ set_context if @tokens.token_count > 1
20
+ show_context
21
+ end
22
+
23
+ #
24
+ # Set the context to the given path.
25
+ #
26
+ def set_context
27
+ path = @tokens.second
28
+ $engine.heap.context.set_to path
29
+ $engine.heap.it.set_to path
30
+ $log.debug "Context set to #{$engine.heap.context}"
27
31
  end
28
-
29
- #
32
+
33
+ #
30
34
  # Show the current context.
31
- #
35
+ #
32
36
  def show_context
33
37
  $log.show "Context: #{$engine.heap.context}"
34
38
  end
35
-
36
- #
39
+
40
+ #
37
41
  # Get the Verb's keyword.
38
- #
42
+ #
39
43
  def self.keyword
40
44
  return KEYWORD
41
45
  end
42
46
 
43
- #
47
+ #
44
48
  # Get the Verb's keyword shortcut.
45
- #
49
+ #
46
50
  def self.keyword_shortcut
47
51
  return KEYWORD_SHORT
48
52
  end
49
53
 
54
+ # ---------------------------------------------------------------------
55
+ # Help
56
+ # ---------------------------------------------------------------------
57
+
58
+ #
59
+ # Get help for this verb.
60
+ #
61
+ def self.help
62
+ return <<~TEXT
63
+ CONTEXT VERB
64
+ NAME: context
65
+ SHORTCUT: @
66
+
67
+ DESCRIPTION
68
+ Get or set the current context.
69
+ When no parameter is provided, the context will be shown.
70
+ Whe the optional path paramter is provided, the context will
71
+ be set to that path.
72
+ Use 'context root' to set the context back to the root level.
73
+
74
+ SYNTAX
75
+ context <path.to.new.context>
76
+
77
+ PARAMETERS
78
+ path.to.new.context - Optional. The path to the new context.
79
+
80
+ RESULT
81
+ Context is optionally set.
82
+ <it> will be set to the new context path when we are changing context.
83
+ Context is show in either case.
84
+
85
+ ERRORS
86
+ None
87
+ TEXT
88
+ end
89
+
50
90
  end
51
91
  end
52
92
  end
@@ -7,46 +7,77 @@
7
7
  module Gloo
8
8
  module Verbs
9
9
  class Create < Gloo::Core::Verb
10
-
11
- KEYWORD = 'create'
12
- KEYWORD_SHORT = '`'
13
- AS = 'as'
14
- VAL = ':'
15
-
16
- #
10
+
11
+ KEYWORD = 'create'.freeze
12
+ KEYWORD_SHORT = '`'.freeze
13
+ AS = 'as'.freeze
14
+ VAL = ':'.freeze
15
+
16
+ #
17
17
  # Run the verb.
18
- #
18
+ #
19
19
  def run
20
20
  name = @tokens.second
21
21
  type = @tokens.after_token( AS )
22
22
  value = @tokens.after_token( VAL )
23
-
24
- if Gloo::Expr::LString.is_string?( value )
23
+
24
+ if Gloo::Expr::LString.string?( value )
25
25
  value = Gloo::Expr::LString.strip_quotes( value )
26
26
  end
27
- obj = $engine.factory.create( name, type, value )
28
-
29
- if obj && obj.add_children_on_create?
30
- obj.add_default_children
31
- end
32
-
27
+ obj = $engine.factory.create( { name: name, type: type, value: value } )
28
+
29
+ obj.add_default_children if obj&.add_children_on_create?
33
30
  $engine.heap.it.set_to value
34
31
  end
35
-
36
- #
32
+
33
+ #
37
34
  # Get the Verb's keyword.
38
- #
35
+ #
39
36
  def self.keyword
40
37
  return KEYWORD
41
38
  end
42
39
 
43
- #
40
+ #
44
41
  # Get the Verb's keyword shortcut.
45
- #
42
+ #
46
43
  def self.keyword_shortcut
47
44
  return KEYWORD_SHORT
48
45
  end
49
46
 
47
+ # ---------------------------------------------------------------------
48
+ # Help
49
+ # ---------------------------------------------------------------------
50
+
51
+ #
52
+ # Get help for this verb.
53
+ #
54
+ def self.help
55
+ return <<~TEXT
56
+ CREATE VERB
57
+ NAME: create
58
+ SHORTCUT: `
59
+
60
+ DESCRIPTION
61
+ Create a new object of given type with given value.
62
+ Both type and value are optional when creating an object.
63
+
64
+ SYNTAX
65
+ create <new.object.path> as <type> : <value>
66
+
67
+ PARAMETERS
68
+ new.object.path - The path and name of the new object
69
+ type - The type of the new object
70
+ value - The initial value for the new object
71
+
72
+ RESULT
73
+ The new object will be created and added to the object heap.
74
+ <it> will be set to the new object's intitial value.
75
+
76
+ ERRORS
77
+ None
78
+ TEXT
79
+ end
80
+
50
81
  end
51
82
  end
52
83
  end