gloo 0.5.2 → 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 (176) 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 +13 -2
  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/help.txt +34 -0
  101. data/lib/gloo/help/verbs/if.txt +37 -0
  102. data/lib/gloo/help/verbs/list.txt +34 -0
  103. data/lib/gloo/help/verbs/load.txt +38 -0
  104. data/lib/gloo/help/verbs/move.txt +42 -0
  105. data/lib/gloo/help/verbs/put.txt +38 -0
  106. data/lib/gloo/help/verbs/quit.txt +25 -0
  107. data/lib/gloo/help/verbs/run.txt +41 -0
  108. data/lib/gloo/help/verbs/save.txt +26 -0
  109. data/lib/gloo/help/verbs/show.txt +30 -0
  110. data/lib/gloo/help/verbs/tell.txt +34 -0
  111. data/lib/gloo/help/verbs/unless.txt +38 -0
  112. data/lib/gloo/help/verbs/version.txt +32 -0
  113. data/lib/gloo/help/verbs/wait.txt +29 -0
  114. data/lib/gloo/objs/basic/alias.rb +0 -33
  115. data/lib/gloo/objs/basic/boolean.rb +6 -27
  116. data/lib/gloo/objs/basic/container.rb +0 -33
  117. data/lib/gloo/objs/basic/decimal.rb +8 -28
  118. data/lib/gloo/objs/basic/integer.rb +5 -26
  119. data/lib/gloo/objs/basic/script.rb +1 -27
  120. data/lib/gloo/objs/basic/string.rb +6 -26
  121. data/lib/gloo/objs/basic/text.rb +0 -25
  122. data/lib/gloo/objs/basic/untyped.rb +0 -26
  123. data/lib/gloo/objs/cli/banner.rb +0 -29
  124. data/lib/gloo/objs/cli/bar.rb +0 -29
  125. data/lib/gloo/objs/cli/colorize.rb +4 -34
  126. data/lib/gloo/objs/cli/confirm.rb +6 -36
  127. data/lib/gloo/objs/cli/menu.rb +6 -36
  128. data/lib/gloo/objs/cli/menu_item.rb +0 -33
  129. data/lib/gloo/objs/cli/pastel.rb +4 -27
  130. data/lib/gloo/objs/cli/prompt.rb +4 -28
  131. data/lib/gloo/objs/cli/select.rb +4 -31
  132. data/lib/gloo/objs/ctrl/each.rb +33 -33
  133. data/lib/gloo/objs/ctrl/repeat.rb +8 -29
  134. data/lib/gloo/objs/data/markdown.rb +0 -25
  135. data/lib/gloo/objs/data/table.rb +4 -32
  136. data/lib/gloo/objs/dev/git.rb +12 -30
  137. data/lib/gloo/objs/dt/date.rb +3 -25
  138. data/lib/gloo/objs/dt/datetime.rb +4 -26
  139. data/lib/gloo/objs/dt/time.rb +3 -25
  140. data/lib/gloo/objs/ror/erb.rb +11 -45
  141. data/lib/gloo/objs/ror/eval.rb +11 -38
  142. data/lib/gloo/objs/snd/play.rb +2 -25
  143. data/lib/gloo/objs/snd/say.rb +9 -31
  144. data/lib/gloo/objs/system/file_handle.rb +0 -38
  145. data/lib/gloo/objs/system/system.rb +16 -46
  146. data/lib/gloo/objs/web/http_get.rb +57 -83
  147. data/lib/gloo/objs/web/http_post.rb +24 -31
  148. data/lib/gloo/objs/web/json.rb +11 -31
  149. data/lib/gloo/objs/web/slack.rb +7 -34
  150. data/lib/gloo/objs/web/teams.rb +13 -48
  151. data/lib/gloo/objs/web/uri.rb +0 -29
  152. data/lib/gloo/persist/file_loader.rb +8 -0
  153. data/lib/gloo/persist/file_saver.rb +6 -0
  154. data/lib/gloo/persist/file_storage.rb +2 -0
  155. data/lib/gloo/persist/line_splitter.rb +2 -0
  156. data/lib/gloo/persist/persist_man.rb +6 -0
  157. data/lib/gloo/verbs/alert.rb +30 -44
  158. data/lib/gloo/verbs/beep.rb +0 -30
  159. data/lib/gloo/verbs/cls.rb +0 -30
  160. data/lib/gloo/verbs/context.rb +9 -39
  161. data/lib/gloo/verbs/create.rb +17 -32
  162. data/lib/gloo/verbs/help.rb +151 -115
  163. data/lib/gloo/verbs/if.rb +46 -44
  164. data/lib/gloo/verbs/list.rb +36 -54
  165. data/lib/gloo/verbs/load.rb +8 -37
  166. data/lib/gloo/verbs/move.rb +12 -51
  167. data/lib/gloo/verbs/put.rb +28 -52
  168. data/lib/gloo/verbs/quit.rb +0 -31
  169. data/lib/gloo/verbs/run.rb +23 -39
  170. data/lib/gloo/verbs/save.rb +0 -33
  171. data/lib/gloo/verbs/show.rb +6 -31
  172. data/lib/gloo/verbs/tell.rb +31 -31
  173. data/lib/gloo/verbs/unless.rb +47 -46
  174. data/lib/gloo/verbs/version.rb +0 -30
  175. data/lib/gloo/verbs/wait.rb +0 -31
  176. metadata +77 -3
@@ -38,7 +38,7 @@ module Gloo
38
38
  # Initially only true for scripts.
39
39
  #
40
40
  def multiline_value?
41
- return false
41
+ return true
42
42
  end
43
43
 
44
44
  #
@@ -56,7 +56,16 @@ module Gloo
56
56
  # Get a list of message names that this object receives.
57
57
  #
58
58
  def self.messages
59
- return super + %w[get parse]
59
+ return super + %w[get parse pretty]
60
+ end
61
+
62
+ #
63
+ # Make the JSON pretty.
64
+ #
65
+ def msg_pretty
66
+ pretty = JSON.pretty_generate( self.value )
67
+ puts pretty
68
+ set_value pretty
60
69
  end
61
70
 
62
71
  #
@@ -121,35 +130,6 @@ module Gloo
121
130
  end
122
131
  end
123
132
 
124
- # ---------------------------------------------------------------------
125
- # Help
126
- # ---------------------------------------------------------------------
127
-
128
- #
129
- # Get help for this object type.
130
- #
131
- def self.help
132
- return <<~TEXT
133
- JSON OBJECT TYPE
134
- NAME: json
135
- SHORTCUT: json
136
-
137
- DESCRIPTION
138
- JSON data in a text string.
139
-
140
- CHILDREN
141
- None
142
-
143
- MESSAGES
144
- get - get a value from the JSON data
145
- Example: tell myjson to get ("title")
146
- The additional parameter is the path to the value.
147
- parse - parse the JSON data and put values in the
148
- object specified by the additional parameter
149
- Example: tell myjson to parse ("path.to.objects")
150
- TEXT
151
- end
152
-
153
133
  end
154
134
  end
155
135
  end
@@ -81,16 +81,20 @@ module Gloo
81
81
  # Children
82
82
  # ---------------------------------------------------------------------
83
83
 
84
+ #
84
85
  # Does this object have children to add when an object
85
86
  # is created in interactive mode?
86
87
  # This does not apply during obj load, etc.
88
+ #
87
89
  def add_children_on_create?
88
90
  return true
89
91
  end
90
92
 
93
+ #
91
94
  # Add children to this object.
92
95
  # This is used by containers to add children needed
93
96
  # for default configurations.
97
+ #
94
98
  def add_default_children
95
99
  fac = $engine.factory
96
100
  fac.create_string URL, 'https://hooks.slack.com/services/...', self
@@ -111,7 +115,9 @@ module Gloo
111
115
  return super + [ 'run' ]
112
116
  end
113
117
 
114
- # Post the content to the endpoint.
118
+ #
119
+ # Post the content to the Slack channel.
120
+ #
115
121
  def msg_run
116
122
  uri = uri_value
117
123
  return unless uri
@@ -119,39 +125,6 @@ module Gloo
119
125
  Gloo::Objs::HttpPost.post_json uri, body_as_json, true
120
126
  end
121
127
 
122
- # ---------------------------------------------------------------------
123
- # Help
124
- # ---------------------------------------------------------------------
125
-
126
- #
127
- # Get help for this object type.
128
- #
129
- def self.help
130
- return <<~TEXT
131
- SLACK OBJECT TYPE
132
- NAME: slack
133
- SHORTCUT: slack
134
-
135
- DESCRIPTION
136
- Send message to channel in Slack.
137
-
138
- CHILDREN
139
- uri - string - 'https://hooks.slack.com/services/...'
140
- The URI with access to the Slack channel.
141
- message - string - 'textual message'
142
- Message to send to Slack.
143
- username - string - 'Slack Bot'
144
- Attribute the message to this user.
145
- channel - string - 'general'
146
- The name of the channel for the post.
147
- icon_emoji - string - ':ghost:'
148
- The emoji to use for the attribution.
149
-
150
- MESSAGES
151
- run - Post the message to Slack.
152
- TEXT
153
- end
154
-
155
128
  end
156
129
  end
157
130
  end
@@ -14,9 +14,11 @@ module Gloo
14
14
  KEYWORD = 'teams'.freeze
15
15
  KEYWORD_SHORT = 'team'.freeze
16
16
  URL = 'uri'.freeze
17
+ DEFAULT_URL = 'https://outlook.office.com/webhook/...'.freeze
17
18
  MSG = 'message'.freeze
18
19
  TITLE = 'title'.freeze
19
20
  COLOR = 'color'.freeze
21
+ DEFAULT_COLOR = '008000'.freeze
20
22
 
21
23
  #
22
24
  # The name of the object type.
@@ -67,34 +69,26 @@ module Gloo
67
69
  # Children
68
70
  # ---------------------------------------------------------------------
69
71
 
72
+ #
70
73
  # Does this object have children to add when an object
71
74
  # is created in interactive mode?
72
75
  # This does not apply during obj load, etc.
76
+ #
73
77
  def add_children_on_create?
74
78
  return true
75
79
  end
76
80
 
81
+ #
77
82
  # Add children to this object.
78
83
  # This is used by containers to add children needed
79
84
  # for default configurations.
85
+ #
80
86
  def add_default_children
81
87
  fac = $engine.factory
82
- fac.create( { :name => URL,
83
- :type => 'string',
84
- :value => 'https://outlook.office.com/webhook/...',
85
- :parent => self } )
86
- fac.create( { :name => TITLE,
87
- :type => 'string',
88
- :value => '',
89
- :parent => self } )
90
- fac.create( { :name => COLOR,
91
- :type => 'color',
92
- :value => '008000',
93
- :parent => self } )
94
- fac.create( { :name => MSG,
95
- :type => 'string',
96
- :value => '',
97
- :parent => self } )
88
+ fac.create_string URL, DEFAULT_URL, self
89
+ fac.create_string TITLE, '', self
90
+ fac.create_string COLOR, DEFAULT_COLOR, self
91
+ fac.create_string MSG, '', self
98
92
  end
99
93
 
100
94
  # ---------------------------------------------------------------------
@@ -108,7 +102,9 @@ module Gloo
108
102
  return super + [ 'run' ]
109
103
  end
110
104
 
111
- # Post the content to the endpoint.
105
+ #
106
+ # Post the content to Microsoft Teams.
107
+ #
112
108
  def msg_run
113
109
  uri = uri_value
114
110
  return unless uri
@@ -116,37 +112,6 @@ module Gloo
116
112
  Gloo::Objs::HttpPost.post_json uri, body_as_json, true
117
113
  end
118
114
 
119
- # ---------------------------------------------------------------------
120
- # Help
121
- # ---------------------------------------------------------------------
122
-
123
- #
124
- # Get help for this object type.
125
- #
126
- def self.help
127
- return <<~TEXT
128
- TEAMS OBJECT TYPE
129
- NAME: teams
130
- SHORTCUT: team
131
-
132
- DESCRIPTION
133
- Send message to channel in Teams.
134
-
135
- CHILDREN
136
- uri - string - 'https://outlook.office.com/webhook/...'
137
- The URI with access to the Teams channel.
138
- title - string
139
- Message title; header.
140
- color - string - '008000'
141
- Color theme for the message.
142
- message - string
143
- The message to post in Teams.
144
-
145
- MESSAGES
146
- run - Post the message to Teams.
147
- TEXT
148
- end
149
-
150
115
  end
151
116
  end
152
117
  end
@@ -126,35 +126,6 @@ module Gloo
126
126
  `#{cmd_with_param}`
127
127
  end
128
128
 
129
- # ---------------------------------------------------------------------
130
- # Help
131
- # ---------------------------------------------------------------------
132
-
133
- #
134
- # Get help for this object type.
135
- #
136
- def self.help
137
- return <<~TEXT
138
- URI OBJECT TYPE
139
- NAME: uri
140
- SHORTCUT: url
141
-
142
- DESCRIPTION
143
- A URI or URL.
144
-
145
- CHILDREN
146
- None
147
-
148
- MESSAGES
149
- open - open the URL in the default browser
150
- get_scheme - get the URI scheme; example: http
151
- get_host - get the URI host; example: google.com
152
- get_path - get the URI resource path; example: /post
153
- get_query - get the URI query parameterse; example: id=121
154
- get_fragment - get the URI fragment
155
- TEXT
156
- end
157
-
158
129
  end
159
130
  end
160
131
  end
@@ -14,7 +14,9 @@ module Gloo
14
14
 
15
15
  attr_reader :obj
16
16
 
17
+ #
17
18
  # Set up a file storage for an object.
19
+ #
18
20
  def initialize( pn )
19
21
  @pn = pn
20
22
  @tabs = 0
@@ -67,8 +69,10 @@ module Gloo
67
69
  end
68
70
  end
69
71
 
72
+ #
70
73
  # Is this line a comment or a blank line?
71
74
  # If so we'll skip it.
75
+ #
72
76
  def skip_line?( line )
73
77
  line = line.strip
74
78
  return true if line.empty?
@@ -77,7 +81,9 @@ module Gloo
77
81
  return false
78
82
  end
79
83
 
84
+ #
80
85
  # Determine the relative indent level for the line.
86
+ #
81
87
  def determine_indent( line )
82
88
  tabs = tab_count( line )
83
89
  @indent = 0 # same level as prior line
@@ -93,7 +99,9 @@ module Gloo
93
99
  puts "tabs: #{@tabs}, indent: #{@indent}, line: #{line}" if @debug
94
100
  end
95
101
 
102
+ #
96
103
  # Process one line and add objects.
104
+ #
97
105
  def process_line( line )
98
106
  # reset multiline unless we're actually indented
99
107
  if @in_multiline && @multi_indent > @indent
@@ -8,7 +8,9 @@ module Gloo
8
8
  module Persist
9
9
  class FileSaver
10
10
 
11
+ #
11
12
  # Set up a file storage for an object.
13
+ #
12
14
  def initialize( pn, obj )
13
15
  @pn = pn
14
16
  @obj = obj
@@ -22,13 +24,17 @@ module Gloo
22
24
  File.write( @pn, data )
23
25
  end
24
26
 
27
+ #
25
28
  # Get string of tabs for indentation.
29
+ #
26
30
  def tabs( indent = 0 )
27
31
  return "\t" * indent
28
32
  end
29
33
 
34
+ #
30
35
  # Convert an object to textual representation.
31
36
  # This is a recursive function.
37
+ #
32
38
  def get_obj( obj, indent = 0 )
33
39
  t = tabs( indent )
34
40
  str = "#{t}#{obj.name} [#{obj.type_display}] : #{obj.value_display}\n"
@@ -10,7 +10,9 @@ module Gloo
10
10
 
11
11
  attr_reader :obj, :pn
12
12
 
13
+ #
13
14
  # Set up a file storage for an object.
15
+ #
14
16
  def initialize( pn, obj = nil )
15
17
  @obj = obj
16
18
  @pn = pn
@@ -14,7 +14,9 @@ module Gloo
14
14
 
15
15
  attr_reader :obj
16
16
 
17
+ #
17
18
  # Set up a line splitter
19
+ #
18
20
  def initialize( line, tabs )
19
21
  @line = line
20
22
  @tabs = tabs
@@ -12,7 +12,9 @@ module Gloo
12
12
 
13
13
  attr_reader :maps
14
14
 
15
+ #
15
16
  # Contructor for the persistence manager.
17
+ #
16
18
  def initialize
17
19
  @maps = []
18
20
  end
@@ -96,13 +98,17 @@ module Gloo
96
98
  return true
97
99
  end
98
100
 
101
+ #
99
102
  # Get the default file extention.
103
+ #
100
104
  def file_ext
101
105
  return '.gloo'
102
106
  end
103
107
 
108
+ #
104
109
  # Print out all object - persistance mappings.
105
110
  # This is a debugging tool.
111
+ #
106
112
  def show_maps
107
113
  @maps.each do |o|
108
114
  puts " \t #{o.pn} \t #{o.obj.name}"
@@ -11,35 +11,27 @@ module Gloo
11
11
  KEYWORD = 'alert'.freeze
12
12
  KEYWORD_SHORT = '!'.freeze
13
13
 
14
+ MISSING_EXPR_ERR = 'Missing Expression!'.freeze
15
+ NO_RESULT_ERR = 'Expression evaluated with no result!'.freeze
16
+
14
17
  #
15
18
  # Run the verb.
16
19
  #
17
20
  def run
18
- return unless @tokens.token_count > 1
21
+ unless @tokens.token_count > 1
22
+ $engine.err MISSING_EXPR_ERR
23
+ return
24
+ end
19
25
 
20
26
  expr = Gloo::Expr::Expression.new( @tokens.params )
21
27
  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
28
 
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 )
29
+ if result
30
+ $engine.heap.it.set_to result
31
+ post_alert result
32
+ else
33
+ $engine.err NO_RESULT_ERR
34
+ end
43
35
  end
44
36
 
45
37
  #
@@ -57,35 +49,29 @@ module Gloo
57
49
  end
58
50
 
59
51
  # ---------------------------------------------------------------------
60
- # Help
52
+ # Private functions
61
53
  # ---------------------------------------------------------------------
62
54
 
55
+ private
56
+
63
57
  #
64
- # Get help for this verb.
58
+ # Post the alert for the specific platform.
59
+ # Notice is not posted if we're in quiet mode.
65
60
  #
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.
61
+ def post_alert( msg )
62
+ $log.info msg
63
+ return if $engine.args.quiet?
81
64
 
82
- RESULT
83
- On the Mac, a notification will popup on screen.
84
- <it> will be set to the message.
65
+ post_osx msg
66
+ end
85
67
 
86
- ERRORS
87
- None
88
- TEXT
68
+ #
69
+ # Post the alert on the Mac OSX.
70
+ #
71
+ def post_osx( msg )
72
+ cmd1 = '/usr/bin/osascript -e "display notification \"'
73
+ cmd2 = '\" with title \"Gloo\" "'
74
+ system( cmd1 + msg.to_s + cmd2 )
89
75
  end
90
76
 
91
77
  end